Files
rhema-claw/deploy/docker/claw.Dockerfile
T
vhaudiquet ea26019f0c build: ship gob in the claw image
A coding turn that starts a dev server or a build has to either wait for
it or background it with `&`, and a backgrounded process is gone from the
next turn's view: no id, no logs, no port. gob keeps the process table
that the agent and the operator both read, so the turn returns and a
later one asks what happened.

The release carries a static linux binary for amd64 and arm64. The image
downloads one from a pinned tag (GOB_VERSION, a build arg) and unpacks it
to /usr/local/bin/gob; no package rides along. No other arch is
published, so a build for one fails at the download instead of shipping a
container whose shell has no gob.

The image gains XDG_RUNTIME_DIR=/tmp/run with it. Left unset, gob looks
for /run/user/1000, which nothing creates here, and its daemon dies with
"socket not created" even though the job table is writable. The socket
stays off the volume, where an NFS PVC cannot hold one. The state
(state.db, the run logs) follows XDG_STATE_HOME to /data/state, so jobs
survive a restart of the container.

Checked on the image's own base: gob run, gob add, gob list and gob
shutdown as uid 1000, no flags. The full image still cannot build before
the 0.4.2 sandbox release (cargo fetch rejects the unpublished pin), so
the runtime stage was built from the Dockerfile's own lines.
2026-11-23 22:54:07 +01:00

92 lines
4.4 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 curl git tar ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# gob (github.com/juanibiapina/gob) is the agent's process manager: a turn
# starts a dev server or a build with `gob add`, and a later turn reads its
# logs, status and ports. Without it a long command either blocks the turn
# for its whole run or is backgrounded with `&`, which no later turn can
# find again. The release is a static binary, so nothing rides along but
# the file; its state lands under XDG_STATE_HOME (/data/state, the volume)
# and its socket under XDG_RUNTIME_DIR. Only amd64 and arm64 are published,
# and a build for any other arch fails here rather than shipping a daemon
# with no `gob` on PATH.
ARG GOB_VERSION=3.9.0
RUN arch="$(dpkg --print-architecture)" \
&& curl -fsSL -o /tmp/gob.tar.gz \
"https://github.com/juanibiapina/gob/releases/download/v${GOB_VERSION}/gob_${GOB_VERSION}_linux_${arch}.tar.gz" \
&& tar -xzf /tmp/gob.tar.gz -C /usr/local/bin gob \
&& rm /tmp/gob.tar.gz \
&& gob --version
# 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`.
#
# XDG_RUNTIME_DIR is gob's socket directory. Left unset, gob looks in
# /run/user/1000, which nothing creates here, and its daemon dies with
# "socket not created". A socket does not belong on the volume (an NFS
# PVC cannot hold one), so it lives in the container's own /tmp.
ENV XDG_CONFIG_HOME=/config \
XDG_STATE_HOME=/data/state \
XDG_RUNTIME_DIR=/tmp/run
VOLUME /data
EXPOSE 7799
USER 1000:1000
ENTRYPOINT ["/usr/local/bin/rhema-claw"]