fix(docker): ensure ironclaw runtime home exists (#1918)

This commit is contained in:
firat.sertgoz
2026-04-06 09:22:10 +03:00
committed by GitHub
parent 5083aed462
commit 13852ff5e4
3 changed files with 38 additions and 2 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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",
);
}