Distroless static-debian12 has no git binary, so
routes/research_setup::ensure_repo_workspace's `tokio::process::Command::new("git")`
returned "No such file or directory" for every wizard-materialized
research topic. Silent failure — the topic's repo_workspace_path
stayed NULL, prepare_topic_runtime bailed out, the run was enqueued
against the shared workspace-wide gateway which then 401'd or timed
out on cold auth.
Switching to debian:12-slim + apt-installing git + ca-certificates
(needed by clone-over-https). Same UID 65532 as before so bind-mount
hosts don't need re-chown.
Image size grows from ~40MB to ~80-100MB but this is the correct
base for a service that shells out to git. Static distroless was a
premature optimization once the server's job description grew a
"clone repos" responsibility.
Follow-up: research migrating to the `gix` pure-Rust crate so we can
go back to distroless. Nontrivial refactor of ensure_repo_workspace
so not attempted in this fix.
49 lines
2.3 KiB
Docker
49 lines
2.3 KiB
Docker
# clawmates-server: static musl build into distroless. The same image serves
|
|
# the air-gapped bundle and the cloud registry.
|
|
FROM rust:1.96-slim AS builder
|
|
ARG TARGETARCH
|
|
# git + cmake are needed for the clawhdf5 git dependency (fetched via the git
|
|
# CLI — libgit2 chokes on Gitea smart-HTTP) and its zlib-ng C build (cmake).
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends musl-tools git cmake make pkg-config \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
WORKDIR /src
|
|
COPY Cargo.toml Cargo.lock rust-toolchain.toml ./
|
|
COPY crates ./crates
|
|
COPY tools ./tools
|
|
COPY images/seccomp ./images/seccomp
|
|
COPY migrations ./migrations
|
|
COPY .sqlx ./.sqlx
|
|
# Install the musl target AFTER rust-toolchain.toml is in place, so rustup adds
|
|
# it to the toolchain the workspace pins (channel 1.96.0), not the base image's
|
|
# default. Doing this before the COPY installs into a toolchain cargo won't
|
|
# actually use, and the build then fails with E0463 (no core for musl).
|
|
RUN case "$TARGETARCH" in \
|
|
arm64) echo aarch64-unknown-linux-musl > /rust-target ;; \
|
|
*) echo x86_64-unknown-linux-musl > /rust-target ;; \
|
|
esac \
|
|
&& rustup target add "$(cat /rust-target)"
|
|
ENV SQLX_OFFLINE=true
|
|
# Fetch git deps with the system git (libgit2 fails against Gitea smart-HTTP);
|
|
# build the zlib-ng C dep with the musl cross compiler for the static target.
|
|
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true \
|
|
CC_x86_64_unknown_linux_musl=musl-gcc \
|
|
CC_aarch64_unknown_linux_musl=musl-gcc
|
|
RUN cargo build --release --target "$(cat /rust-target)" -p clawmates-server \
|
|
&& cp "target/$(cat /rust-target)/release/clawmates-server" /clawmates-server
|
|
|
|
FROM debian:12-slim
|
|
# git — required at runtime for research topic repo clones
|
|
# (routes/research_setup::ensure_repo_workspace shells out to `git clone`
|
|
# and `git ls-files`). The distroless variant we had here didn't include
|
|
# a git binary; every wizard-materialized research topic silently failed
|
|
# to clone until this change.
|
|
# ca-certificates — required by `git clone` over HTTPS.
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends git ca-certificates \
|
|
&& rm -rf /var/lib/apt/lists/* \
|
|
&& useradd -u 65532 -M -s /usr/sbin/nologin nonroot
|
|
COPY --from=builder /clawmates-server /usr/local/bin/clawmates-server
|
|
USER 65532
|
|
ENTRYPOINT ["/usr/local/bin/clawmates-server"]
|