Rebuild project image with --no-cache when --rebuild is set
Previously --rebuild only passed --no-cache to the base ramekin-agent
docker build. The subsequent docker compose up --build still used
Docker's layer cache for the project image, so custom .ramekin/Dockerfile
changes weren't fully honored.
Running docker compose build --no-cache as a separate step before
docker compose up ensures both layers are rebuilt from scratch.
Assisted-by: Owl Alpha via pi
diff --git a/src/main.rs b/src/main.rs
index c872925..f8c18cf 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -352,7 +352,17 @@ impl Ramekin {
Ok(cmd)
};
- let status = docker_compose(&["up", "-d", "--build"])?
+ if rebuild {
+ let status = docker_compose(&["build", "--no-cache"])?
+ .status()
+ .into_diagnostic()
+ .wrap_err("failed to run docker compose build")?;
+ if !status.success() {
+ bail!("docker compose build failed ({})", status);
+ }
+ }
+
+ let status = docker_compose(&["up", "-d"])?
.status()
.into_diagnostic()
.wrap_err("failed to run docker compose up")?;