forked from vhaudiquet/rhema-claw
The daemon's `bash` always ran on its own host. A deployment that wants the shell isolated, or on a machine with the project's toolchain, had no way to say so, and the web settings had no surface for it. A sandbox choice now persists in the settings table, and the daemon can be seeded from `sandbox` in claw.yaml. `local` keeps the existing shell; `http` wraps `rhema-sandbox-http` in a `ShellSandbox` and gives every handler a `ShellTools` built over it. Chat turns, forge turns, and coding jobs all read the choice per dispatch, so a switch applies on the next turn without a restart. A remote sandbox starts empty. The first command for a workspace probes `/workspace` and, when it is empty, sends the host workspace as a tarball through the protocol's seed route. Later edits stay in the sandbox; the claw does not copy them back. The web settings gain a System > Sandbox page: the two kinds, the URL and a write-only token, a forget-token action, and the effective workspace. `GET /v1/sandbox` never returns the token; `PUT` validates and persists the choice. Tests: the sandbox state and config validation, the HTTP route round trip, and a remote turn that seeds a fresh sandbox and runs its shell there. fmt, clippy with -D warnings, the workspace tests, and the web typecheck and build pass.
69 lines
3.2 KiB
Docker
69 lines
3.2 KiB
Docker
# rhema-claw: the resident forge-watching daemon.
|
|
# Build from the repo root (the context is the repo):
|
|
# docker build -f deploy/docker/claw.Dockerfile .
|
|
|
|
# The builder tag tracks rust-toolchain.toml: the pinned channel is what
|
|
# every commit is tested against. The full image (not -slim) carries the C
|
|
# toolchain rusqlite's bundled SQLite build needs.
|
|
FROM rust:1.98.1 AS builder
|
|
WORKDIR /build
|
|
|
|
# Manifests first: the registry cache this populates survives source edits.
|
|
COPY Cargo.toml Cargo.lock rust-toolchain.toml ./
|
|
COPY crates/rhema-claw/Cargo.toml crates/rhema-claw/Cargo.toml
|
|
COPY integrations/rhema-forge-integration/Cargo.toml integrations/rhema-forge-integration/Cargo.toml
|
|
COPY integrations/rhema-calendar-integration/Cargo.toml integrations/rhema-calendar-integration/Cargo.toml
|
|
COPY tools/Cargo.toml tools/Cargo.toml
|
|
COPY tools/contract/Cargo.toml tools/contract/Cargo.toml
|
|
COPY tools/common/Cargo.toml tools/common/Cargo.toml
|
|
COPY tools/notify/Cargo.toml tools/notify/Cargo.toml
|
|
|
|
# Cargo validates explicit target
|
|
# paths at manifest-parse time, so the fetch needs stub files at every
|
|
# declared target path: src/ for every member, plus examples/tests/benches
|
|
# as declared (default path from the target name, or the explicit `path`).
|
|
# The loop drives off the crates/*/ and integrations/*/ globs because
|
|
# neither glob's */src matches anything until the stub exists — an
|
|
# unmatched glob would hand mkdir a literal path. The real sources land
|
|
# below. (The awk program must stay on one line: a Dockerfile line not
|
|
# ending in a backslash ends the RUN.)
|
|
RUN for crate in crates/*/ integrations/*/ tools/*/; do \
|
|
mkdir -p "$crate/src"; \
|
|
touch "$crate/src/lib.rs" "$crate/src/main.rs"; \
|
|
awk -F'"' '/^\[/ { d = ""; p = 0; if ($0 == "[[example]]") { d = "examples" } else if ($0 == "[[test]]") { d = "tests" } else if ($0 == "[[bench]]") { d = "benches" }; next } d == "" { next } /^name = / && p == 0 { print d "/" $2 ".rs" } /^path = / { p = 1; print $2 }' "$crate/Cargo.toml" \
|
|
| while IFS= read -r target; do \
|
|
mkdir -p "$crate$(dirname "$target")"; \
|
|
touch "$crate$target"; \
|
|
done; \
|
|
done \
|
|
&& cargo fetch
|
|
|
|
# Sources. target/ and .git never land here: the repo-root .dockerignore
|
|
# keeps them out of the context.
|
|
COPY . .
|
|
RUN cargo build --release -p rhema-claw
|
|
|
|
FROM debian:stable-slim
|
|
|
|
# bash and git are load-bearing, not conveniences: the coding agent shells
|
|
# out via `bash -c` and clones/fetches in its per-thread workspaces.
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends bash git tar ca-certificates \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Numeric USER: Kubernetes cannot verify runAsNonRoot against a name.
|
|
RUN useradd --uid 1000 --user-group --create-home claw \
|
|
&& install -d -o 1000 -g 1000 /config /data
|
|
|
|
COPY --from=builder /build/target/release/rhema-claw /usr/local/bin/rhema-claw
|
|
|
|
# The chart passes --config /config/claw.yaml (the ConfigMap mount) and
|
|
# mounts the state PVC at /data; these defaults serve a bare `docker run`.
|
|
ENV XDG_CONFIG_HOME=/config \
|
|
XDG_STATE_HOME=/data/state
|
|
VOLUME /data
|
|
EXPOSE 7799
|
|
|
|
USER 1000:1000
|
|
ENTRYPOINT ["/usr/local/bin/rhema-claw"]
|