Skip to content

docker: enable sccache (redis) in the Rust image build (JEF-84)#94

Merged
thejefflarson merged 2 commits into
mainfrom
sccache-image-builds
Jul 12, 2026
Merged

docker: enable sccache (redis) in the Rust image build (JEF-84)#94
thejefflarson merged 2 commits into
mainfrom
sccache-image-builds

Conversation

@thejefflarson

Copy link
Copy Markdown
Owner

Routes rustc through sccache against the shared in-cluster Redis (sccache-redis.dev.svc.cluster.local:6379) in server/Dockerfile. buildkit is now meshed and can reach that Service.

Changes

  • Removed cargo-chef (the chef / planner / cook stages). sccache and cargo-chef's cook cannot coexist: cargo always passes .rmeta metadata externs, sccache hashes every --extern input, and cook leaves the shared target dir in a state where those .rmeta files don't survive into the final cargo build — sccache fatals (Failed to open file for hashing: …/lib*.rmeta) and aborts (JEF-389, confirmed real and backend-independent). Collapsed to a single build stage: COPY source, one cargo build.
  • Install sccache v0.16.0 (arch-aware) in the builder base and set RUSTC_WRAPPER=sccache, CARGO_INCREMENTAL=0, SCCACHE_REDIS=…. Uses the -gnu tarball because the rust base image is rust:1-bookworm (glibc), not musl.
  • Wrap cargo build so sccache is a hard gate (no local fallback — if it can't reach Redis, the build fails) and start its server on a randomised SCCACHE_SERVER_PORT. The random port is required because BuildKit sandboxes share a network namespace, so concurrent builds would collide on sccache's fixed default port 4226 (Address in use).

The ui stage and the runtime/final stage are unchanged; the final stage still copies --from=build /app/target/release/watcher-server (target is baked into the build layer, as before — no target cache mount).

🤖 Generated with Claude Code

thejefflarson and others added 2 commits July 12, 2026 10:11
Route rustc through sccache against the shared in-cluster Redis
(sccache-redis.dev:6379); buildkit is now meshed and can reach it.

- Remove cargo-chef entirely (chef/planner/cook stages) — it can't coexist
  with sccache (extern .rmeta files don't survive cook into the final build,
  sccache fatals; JEF-389). Collapsed to one build stage: COPY source, one
  cargo build.
- sccache is a HARD GATE (no local fallback). SCCACHE_SERVER_PORT is
  randomised per build so concurrent buildkit sandboxes (shared netns) don't
  collide on the fixed default port 4226. CARGO_INCREMENTAL=0 is mandatory.
- -gnu sccache tarball since the rust base is bookworm/glibc, not musl.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013cYVqzH7Xfwea7fAozdQK7
@thejefflarson thejefflarson merged commit dab90ca into main Jul 12, 2026
4 checks passed
@thejefflarson thejefflarson deleted the sccache-image-builds branch July 12, 2026 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant