Skip to content

Commit

Permalink
Changes for opday.dev, version 0.1.0 in crates (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
aptakhin authored Mar 30, 2024
1 parent 33697cd commit bcd4647
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ target/
.secrets/*
opday
cargo
docker-compose*.yaml
./docker-compose*.yaml
11 changes: 10 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,24 @@
name = "opday"
version = "0.1.0"
edition = "2021"
authors = [
"Alexander Ptakhin <[email protected]>",
]
description = "Dex(Ops)Experience for deployments and other ops operations made easy"
license = "MIT"
license-file = "LICENSE"
repository = "https://github.com/aptakhin/opday"

[dependencies]
base64 = "0.22.0"
clap = { version = "4.5.3", features = ["derive"] }
env_logger = "0.11.3"
log = "0.4.21"
rstest = "0.18.2"
serde = { version = "1.0.195", features = ["derive"] }
serde_json = "1.0.111"
serde_yaml = "0.9.30"
term = "0.7.0"
toml = "0.8.11"

[dev-dependencies]
rstest = "0.18.2"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Let's call build now:
opday docker build
```

This tool requires local installation of another tools and their availability in the shell: `docker`, `ssh`, `scp`.
This tool requires local installation of another tools and their availability in the shell: `docker`, `ssh`, `rsync`.

# The idea

Expand Down
1 change: 0 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use serde_yaml::Mapping;
pub struct DockerComposeFormat {
pub version: String,
pub services: Mapping,
pub volumes: Option<Mapping>,
}
pub struct Scope {
pub hosts: Vec<String>,
Expand Down
22 changes: 11 additions & 11 deletions src/provider/docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,13 @@ fn deploy(
let mut run_format = DockerComposeFormat {
version: format.version.clone(),
services: Mapping::new(),
volumes: Some(Mapping::new()),
};

for service in format.services.iter() {
// override environment
let mut run_service_map = Mapping::new();
run_service_map.insert(Value::String((&"build").to_string()), "!reset null".into());
// TODO: Add only when we have build
// run_service_map.insert(Value::String((&"build").to_string()), "!reset null".into());
run_service_map.insert(
Value::String((&"environment").to_string()),
Value::Mapping(Mapping::new()),
Expand All @@ -368,15 +368,16 @@ fn deploy(
let src_path_ensure_last_slash = Path::new(&config.path).join("");
let src_path_ensure_last_slash_string = src_path_ensure_last_slash.to_string_lossy();
{
let mut params: Vec<&str> = vec![];
let mut params: Vec<String> = vec![];
if host.private_key.is_some() {
params.push("-i");
params.push(host.private_key.as_ref().unwrap());
params.push("-e".to_owned());
params.push("ssh -i ".to_owned() + &host.private_key.clone().unwrap());
}
params.push("-r");
params.push(src_path_ensure_last_slash_string.as_ref());
params.push(&host0_path);
let _ = execute_command("scp", params, &vec![]).expect("Failed to call host.");
params.push("-r".to_owned());
params.push(src_path_ensure_last_slash_string.to_string());
params.push(host0_path.clone());
let params2: Vec<&str> = params.iter().map(|s| s.as_str()).collect();
let _ = execute_command("rsync", params2, &vec![]).expect("Failed to call host.");
}

let internal_files_export = Path::new(&scope.export_path).join(".opday-generated");
Expand All @@ -399,7 +400,7 @@ fn deploy(
deploy_command += " -f ";
let generate_file_export_path = internal_files_export.join(generate_file_name);
deploy_command += &generate_file_export_path.to_string_lossy();
deploy_command += " up -d";
deploy_command += " up -d --build";

{
let mut params: Vec<&str> = vec![];
Expand Down Expand Up @@ -535,7 +536,6 @@ mod tests {
DockerComposeFormat {
version: "3.7".to_string(),
services: Mapping::new(),
volumes: None,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ version: '3.7'
services:
backend:
image: registry.digitalocean.com/frlr/dkrpublish/test-backend:${BACKEND_TAG}
build: '!reset null'
command: uvicorn app:app --host 0.0.0.0 --port 8000
restart: unless-stopped
ports:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ version: '3.7'
services:
backend:
image: registry.digitalocean.com/frlr/opday/02-backend:${BACKEND_TAG}
build: '!reset null'
command: uvicorn app:app --host 0.0.0.0 --port 8000
restart: unless-stopped
ports:
Expand All @@ -13,6 +14,7 @@ services:

nginx:
image: registry.digitalocean.com/frlr/opday/02-nginx:${NGINX_TAG}
build: '!reset null'
ports:
- "80:80"
- "443:443"

0 comments on commit bcd4647

Please sign in to comment.