From 13852ff5e4fb714bf8598b0c8de6902336d790eb Mon Sep 17 00:00:00 2001 From: "firat.sertgoz" Date: Mon, 6 Apr 2026 09:22:10 +0300 Subject: [PATCH] fix(docker): ensure ironclaw runtime home exists (#1918) --- Dockerfile | 6 +++- ...ests__long_help_output_without_import.snap | 2 +- tests/dockerfile_runtime_home.rs | 32 +++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 tests/dockerfile_runtime_home.rs diff --git a/Dockerfile b/Dockerfile index c91676d65c..89b9366597 100644 --- a/Dockerfile +++ b/Dockerfile @@ -75,7 +75,11 @@ COPY --from=builder /app/target/dist/ironclaw /usr/local/bin/ironclaw COPY --from=builder /app/migrations /app/migrations # Non-root user -RUN adduser --disabled-password --uid 1000 ironclaw +ENV HOME=/home/ironclaw +RUN useradd -m -d /home/ironclaw -u 1000 ironclaw \ + && mkdir -p /home/ironclaw/.ironclaw \ + && chown -R ironclaw:ironclaw /home/ironclaw +WORKDIR /home/ironclaw USER ironclaw EXPOSE 3000 diff --git a/src/cli/snapshots/ironclaw__cli__tests__long_help_output_without_import.snap b/src/cli/snapshots/ironclaw__cli__tests__long_help_output_without_import.snap index 9b65f13456..fa01480e9a 100644 --- a/src/cli/snapshots/ironclaw__cli__tests__long_help_output_without_import.snap +++ b/src/cli/snapshots/ironclaw__cli__tests__long_help_output_without_import.snap @@ -51,7 +51,7 @@ Options: --auto-approve Auto-approve tool execution (shell, file writes, HTTP, etc.) - + Skips interactive approval prompts for standard tools. Destructive operations still require explicit approval. Other safeguards remain active: rate limits, hooks, authentication gates. -h, --help diff --git a/tests/dockerfile_runtime_home.rs b/tests/dockerfile_runtime_home.rs new file mode 100644 index 0000000000..687f10b359 --- /dev/null +++ b/tests/dockerfile_runtime_home.rs @@ -0,0 +1,32 @@ +use std::path::PathBuf; + +fn runtime_dockerfile() -> String { + let repo_root = std::env::var_os("CARGO_MANIFEST_DIR") + .map(PathBuf::from) + .or_else(|| std::env::current_dir().ok()) + .expect("repo root should be discoverable"); + let path = repo_root.join("Dockerfile"); + std::fs::read_to_string(path).expect("Dockerfile should be readable") +} + +#[test] +fn runtime_image_declares_and_prepares_ironclaw_home() { + let dockerfile = runtime_dockerfile(); + + assert!( + dockerfile.contains("useradd -m -d /home/ironclaw -u 1000 ironclaw"), + "runtime image must create the ironclaw user with the expected home directory", + ); + assert!( + dockerfile.contains("ENV HOME=/home/ironclaw"), + "runtime image must set HOME to /home/ironclaw for ~/.ironclaw state", + ); + assert!( + dockerfile.contains("WORKDIR /home/ironclaw"), + "runtime image must start in the ironclaw home directory", + ); + assert!( + dockerfile.contains("mkdir -p /home/ironclaw/.ironclaw"), + "runtime image must pre-create ~/.ironclaw before dropping privileges", + ); +}