diff --git a/.gitignore b/.gitignore index 7d52966..4404f20 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ target/ .secrets/* opday cargo -docker-compose*.yaml +./docker-compose*.yaml diff --git a/Cargo.toml b/Cargo.toml index 53e6438..4f3f33a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,15 +2,24 @@ name = "opday" version = "0.1.0" edition = "2021" +authors = [ + "Alexander Ptakhin ", +] +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" diff --git a/README.md b/README.md index 3a0f0a0..8e776fe 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/config.rs b/src/config.rs index ebaa8a3..9b9e134 100644 --- a/src/config.rs +++ b/src/config.rs @@ -10,7 +10,6 @@ use serde_yaml::Mapping; pub struct DockerComposeFormat { pub version: String, pub services: Mapping, - pub volumes: Option, } pub struct Scope { pub hosts: Vec, diff --git a/src/provider/docker.rs b/src/provider/docker.rs index 00f7d53..a96ee18 100644 --- a/src/provider/docker.rs +++ b/src/provider/docker.rs @@ -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()), @@ -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 = 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"); @@ -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![]; @@ -535,7 +536,6 @@ mod tests { DockerComposeFormat { version: "3.7".to_string(), services: Mapping::new(), - volumes: None, } } diff --git a/tests/01_trivial-backend-no-storage/docker-compose.override-run.prod.yaml b/tests/01_trivial-backend-no-storage/docker-compose.override-run.prod.yaml index 108a960..bcb8434 100644 --- a/tests/01_trivial-backend-no-storage/docker-compose.override-run.prod.yaml +++ b/tests/01_trivial-backend-no-storage/docker-compose.override-run.prod.yaml @@ -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: diff --git a/tests/02_simple-backend-with-database/docker-compose.override-run.prod.yaml b/tests/02_simple-backend-with-database/docker-compose.override-run.prod.yaml index 2142786..dc87abd 100644 --- a/tests/02_simple-backend-with-database/docker-compose.override-run.prod.yaml +++ b/tests/02_simple-backend-with-database/docker-compose.override-run.prod.yaml @@ -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: @@ -13,6 +14,7 @@ services: nginx: image: registry.digitalocean.com/frlr/opday/02-nginx:${NGINX_TAG} + build: '!reset null' ports: - "80:80" - "443:443"