initial commit 🚀

This commit is contained in:
2023-04-07 01:48:03 -03:00
commit 4e6c778b5d
9 changed files with 150 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile
{
"name": "Existing Dockerfile",
"build": {
// Sets the run context to one level up instead of the .devcontainer folder.
"context": "..",
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerfile": "../Dockerfile"
}
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Uncomment the next line to run commands after the container is created.
// "postCreateCommand": "cat /etc/os-release",
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "devcontainer"
}

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
/target
Project
Cargo.lock

13
Cargo.toml Normal file
View File

@@ -0,0 +1,13 @@
[package]
name = "turbo_open"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
clap = { version = "4.0", features = ["derive"] }
[[bin]]
name = "turbo_open"
path = "main.rs"

31
Dockerfile Normal file
View File

@@ -0,0 +1,31 @@
# FROM alpine:latest
# RUN apk update
# RUN apk upgrade
# RUN apk add curl file git
# RUN apk add gcc
# RUN apk add rust-doc
# # RUN apk search rust-std
# # RUN apk add rust-std
# RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -y | sh
# # RUN source $HOME/.cargo/env
# CMD [""]
FROM rust:latest
RUN apt upgrade
RUN apt update
# RUN apt install -y \
# clang \
# gcc \
# g++ \
# zlib1g-dev \
# libmpc-dev \
# libmpfr-dev \
# libgmp-dev
CMD [""]

View File

@@ -0,0 +1,13 @@
FROM mhart/alpine-node:14
RUN apk add curl
COPY [".", "/usr/src"]
WORKDIR "/usr/src"
RUN yarn
ARG NODE_ENV
CMD if [ "$NODE_ENV" = "develop" ] ; then yarn run dev ; else yarn run start ; fi

View File

@@ -0,0 +1,10 @@
version: "2.9"
services:
app:
build: .
volumes:
- .:/usr/src
- /usr/src/node_modules
environment:
NODE_ENV: ${NODE_ENV}

3
build.sh Normal file
View File

@@ -0,0 +1,3 @@
cargo build --release --target=aarch64-apple-darwin
cargo build --release --target=x86_64-unknown-linux-gnu
cargo build --release --target=x86_64-pc-windows-msvc

4
commit.sh Normal file
View File

@@ -0,0 +1,4 @@
cargo fmt
git add .
echo $1
git commit -m "$1"

47
main.rs Normal file
View File

@@ -0,0 +1,47 @@
use clap::Parser;
use std::process::Command;
#[derive(Parser)]
struct Cli {
project_type: String,
path: std::path::PathBuf,
}
fn main() {
let args = Cli::parse();
let path = std::fs::canonicalize(args.path)
.expect("could not read file")
.into_os_string()
.into_string()
.unwrap();
let file_names_collection = [
["Dockerfile", "Dockerfile"],
["docker-compose.yml", "docker-compose.yml"],
];
for file_names in file_names_collection {
let origin_file_path = format!(
"{}/{}/{}",
std::fs::canonicalize("./Dockerfiles/")
.expect("could not read file")
.into_os_string()
.into_string()
.unwrap(),
&args.project_type,
file_names[1]
);
let destiny_path = format!("{}/{}", path, file_names[1]);
std::fs::copy(origin_file_path, destiny_path).ok();
}
let mut child = Command::new("docker-compose")
.arg("-f")
.arg(format!("{}/{}", path, "docker-compose.yml"))
.arg("up")
.spawn()
.expect("failed to execute docker-compose");
let status = child.wait().expect("failed to wait for child process");
if status.success() {
println!("Docker Compose command executed successfully");
} else {
eprintln!("Docker Compose command failed with error code {}", status);
}
}