From f7625f0484428147ac744aa3fee7ec9319474f9f Mon Sep 17 00:00:00 2001 From: Ian Letourneau Date: Wed, 16 Jul 2025 13:44:38 -0400 Subject: [PATCH 1/3] fix(rust): push only the actual image tag --- .../features/continuous_delivery.rs | 2 +- harmony/src/modules/application/rust.rs | 32 +++++++++---------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/harmony/src/modules/application/features/continuous_delivery.rs b/harmony/src/modules/application/features/continuous_delivery.rs index 39513ab..346a749 100644 --- a/harmony/src/modules/application/features/continuous_delivery.rs +++ b/harmony/src/modules/application/features/continuous_delivery.rs @@ -158,7 +158,7 @@ impl< let helm_chart = self.application.build_push_helm_package(&image).await?; info!("Pushed new helm chart {helm_chart}"); - error!("TODO Make building image configurable/skippable"); + error!("TODO Make building image configurable/skippable if image already exists (prompt)"); let image = self.application.build_push_oci_image().await?; info!("Pushed new docker image {image}"); diff --git a/harmony/src/modules/application/rust.rs b/harmony/src/modules/application/rust.rs index 62d732b..ff67754 100644 --- a/harmony/src/modules/application/rust.rs +++ b/harmony/src/modules/application/rust.rs @@ -109,24 +109,20 @@ impl OCICompliant for RustWebapp { // It's async to match the trait definition, though the underlying docker commands are blocking. info!("Starting OCI image build and push for '{}'", self.name); - // 1. Build the local image by calling the synchronous helper function. - let local_image_name = self.local_image_name(); - self.build_docker_image(&local_image_name) + // 1. Build the image by calling the synchronous helper function. + let image_tag = self.image_name(); + self.build_docker_image(&image_tag) .await .map_err(|e| format!("Failed to build Docker image: {}", e))?; - info!( - "Successfully built local Docker image: {}", - local_image_name - ); + info!("Successfully built Docker image: {}", image_tag); - let remote_image_name = self.image_name(); // 2. Push the image to the registry. - self.push_docker_image(&local_image_name, &remote_image_name) + self.push_docker_image(&image_tag) .await .map_err(|e| format!("Failed to push Docker image: {}", e))?; - info!("Successfully pushed Docker image to: {}", remote_image_name); + info!("Successfully pushed Docker image to: {}", image_tag); - Ok(remote_image_name) + Ok(image_tag) } fn local_image_name(&self) -> String { @@ -206,23 +202,25 @@ impl RustWebapp { /// Tags and pushes a Docker image to the configured remote registry. async fn push_docker_image( &self, - image_name: &str, - full_tag: &str, + image_tag: &str, ) -> Result> { - info!("Pushing docker image {full_tag}"); + info!("Pushing docker image {image_tag}"); let docker = Docker::connect_with_socket_defaults().unwrap(); // let push_options = PushImageOptionsBuilder::new().tag(tag); - let mut push_image_stream = - docker.push_image(full_tag, Some(PushImageOptionsBuilder::new().build()), None); + let mut push_image_stream = docker.push_image( + image_tag, + Some(PushImageOptionsBuilder::new().build()), + None, + ); while let Some(msg) = push_image_stream.next().await { println!("Message: {msg:?}"); } - Ok(full_tag.to_string()) + Ok(image_tag.to_string()) } /// Checks the output of a process command for success. From 07f1151e4c81439b4ddd6dddc40be5eecc4e6c38 Mon Sep 17 00:00:00 2001 From: Ian Letourneau Date: Sun, 20 Jul 2025 20:03:26 -0400 Subject: [PATCH 2/3] chore: cleanup of unncessary files & adjust gitignores --- .gitignore | 30 ++++++++++++++++++++----- examples/rust/.gitignore | 3 +++ examples/rust/src/main.rs | 6 ++--- examples/rust/webapp/Dockerfile.harmony | 16 ------------- harmony_composer/src/main.rs | 1 + 5 files changed, 32 insertions(+), 24 deletions(-) create mode 100644 examples/rust/.gitignore delete mode 100644 examples/rust/webapp/Dockerfile.harmony diff --git a/.gitignore b/.gitignore index f478f21..149050f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,25 @@ -target -private_repos -log/ -*.tgz -.gitignore +### General ### +private_repos/ + +### Harmony ### +harmony.log + +### Helm ### +# Chart dependencies +**/charts/*.tgz + +### Rust ### +# Generated by Cargo +# will have compiled files and executables +debug/ +target/ + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +Cargo.lock + +# These are backup files generated by rustfmt +**/*.rs.bk + +# MSVC Windows builds of rustc generate these, which store debugging information +*.pdb diff --git a/examples/rust/.gitignore b/examples/rust/.gitignore new file mode 100644 index 0000000..df77acc --- /dev/null +++ b/examples/rust/.gitignore @@ -0,0 +1,3 @@ +Dockerfile.harmony +.harmony_generated +harmony diff --git a/examples/rust/src/main.rs b/examples/rust/src/main.rs index 0b36621..c89a9f5 100644 --- a/examples/rust/src/main.rs +++ b/examples/rust/src/main.rs @@ -22,7 +22,7 @@ async fn main() { let application = Arc::new(RustWebapp { name: "harmony-example-rust-webapp".to_string(), domain: Url::Url(url::Url::parse("https://rustapp.harmony.example.com").unwrap()), - project_root: PathBuf::from("./examples/rust/webapp"), + project_root: PathBuf::from("./webapp"), // Relative from 'harmony-path' param framework: Some(RustWebFramework::Leptos), }); @@ -30,10 +30,10 @@ async fn main() { features: vec![ Box::new(ContinuousDelivery { application: application.clone(), - }), // TODO add monitoring, backups, multisite ha, etc + }), Box::new(Monitoring { application: application.clone(), - }), + }), // TODO: add backups, multisite ha, etc. ], application, }; diff --git a/examples/rust/webapp/Dockerfile.harmony b/examples/rust/webapp/Dockerfile.harmony deleted file mode 100644 index dffa3ac..0000000 --- a/examples/rust/webapp/Dockerfile.harmony +++ /dev/null @@ -1,16 +0,0 @@ -FROM rust:bookworm as builder -RUN apt-get update && apt-get install -y --no-install-recommends clang wget && wget https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-musl.tgz && tar -xvf cargo-binstall-x86_64-unknown-linux-musl.tgz && cp cargo-binstall /usr/local/cargo/bin && rm cargo-binstall-x86_64-unknown-linux-musl.tgz cargo-binstall && apt-get clean && rm -rf /var/lib/apt/lists/* -RUN cargo binstall cargo-leptos -y -RUN rustup target add wasm32-unknown-unknown -WORKDIR /app -COPY . . -RUN cargo leptos build --release -vv -FROM debian:bookworm-slim -RUN groupadd -r appgroup && useradd -r -s /bin/false -g appgroup appuser -ENV LEPTOS_SITE_ADDR=0.0.0.0:3000 -EXPOSE 3000/tcp -WORKDIR /home/appuser -COPY --from=builder /app/target/site/pkg /home/appuser/pkg -COPY --from=builder /app/target/release/harmony-example-rust-webapp /home/appuser/harmony-example-rust-webapp -USER appuser -CMD /home/appuser/harmony-example-rust-webapp \ No newline at end of file diff --git a/harmony_composer/src/main.rs b/harmony_composer/src/main.rs index 648977e..639ddc3 100644 --- a/harmony_composer/src/main.rs +++ b/harmony_composer/src/main.rs @@ -155,6 +155,7 @@ async fn compile_harmony( let cargo_exists = Command::new("which") .arg("cargo") + .stdout(Stdio::null()) .status() .expect("couldn't get `which cargo` status") .success(); From d9959378a624b8cf706f8c471443ebe1e33e19bb Mon Sep 17 00:00:00 2001 From: Jean-Gabriel Gill-Couture Date: Thu, 3 Jul 2025 10:53:02 -0400 Subject: [PATCH 3/3] log(composer): Log check_path_str value when error --- harmony_composer/src/main.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/harmony_composer/src/main.rs b/harmony_composer/src/main.rs index 648977e..49b6cc0 100644 --- a/harmony_composer/src/main.rs +++ b/harmony_composer/src/main.rs @@ -98,7 +98,9 @@ async fn main() { .expect("couldn't check if path exists") { true => (), - false => todo!("implement couldn't find path logic"), + false => todo!( + "path {check_script_str} not found. Other paths currently unsupported." + ), }; let check_output = Command::new(check_script)