mirror of
https://github.com/nearai/ironclaw.git
synced 2026-09-02 23:56:24 +08:00
fix(docker): ensure ironclaw runtime home exists (#1918)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
32
tests/dockerfile_runtime_home.rs
Normal file
32
tests/dockerfile_runtime_home.rs
Normal 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",
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user