Skip to content

chore(docker): pin base images by digest (DEP-02)#455

Merged
intendednull merged 1 commit into
auto-fix/batch-2026-04-28-002530from
auto-fix/issue-313-docker-pin-digests
Apr 28, 2026
Merged

chore(docker): pin base images by digest (DEP-02)#455
intendednull merged 1 commit into
auto-fix/batch-2026-04-28-002530from
auto-fix/issue-313-docker-pin-digests

Conversation

@intendednull
Copy link
Copy Markdown
Owner

Why

Mutable tags bad. rust:latest / rust:slim / nginxinc/nginx-unprivileged:alpine change under foot. Build not reproducible. Tag takeover or malicious re-push = silent supply-chain swap. SEC DEP-02 medium.

Pin to digest. Build same bytes every time. Re-push of tag cannot poison.

What

Four Dockerfiles. Each FROM now tag@sha256:<digest>. Comment above each line records version + pin date + bump command.

File Stage Old New
docker/relay.Dockerfile:2 builder rust:latest rust:1.95-slim-bookworm@sha256:caaf9ca7acd474892186860307d6f28e51fdbc1a4eada459fcff81517cf46a36
docker/relay.Dockerfile:8 runtime rust:slim same pin
docker/replay.Dockerfile:2 builder rust:latest same pin
docker/replay.Dockerfile:8 runtime rust:slim same pin
docker/storage.Dockerfile:2 builder rust:latest same pin
docker/storage.Dockerfile:8 runtime rust:slim same pin
docker/web.Dockerfile:2 builder rust:latest same pin
docker/web.Dockerfile:10 runtime nginxinc/nginx-unprivileged:alpine nginxinc/nginx-unprivileged:1.27-alpine@sha256:65e3e85dbaed8ba248841d9d58a899b6197106c23cb0ff1a132b7bfe0547e4c0

Rust 1.95 = current stable (matches rust-toolchain.toml channel = stable, latest stable as of 2026-04). Same image used for builder + runtime as before — no layout change.

Verify

Digests fetched live from Docker Hub:

docker buildx imagetools inspect rust:1.95-slim-bookworm
  → Digest: sha256:caaf9ca7acd474892186860307d6f28e51fdbc1a4eada459fcff81517cf46a36
docker buildx imagetools inspect nginxinc/nginx-unprivileged:1.27-alpine
  → Digest: sha256:65e3e85dbaed8ba248841d9d58a899b6197106c23cb0ff1a132b7bfe0547e4c0

Both pinned refs re-inspected by digest = resolve = real.

cargo fmt --check clean. cargo check --workspace clean (Dockerfile-only change, Rust untouched). Daemonless sandbox = no full docker build, but registry resolution proves digests valid.

Bump in future

docker buildx imagetools inspect rust:1.<minor>-slim-bookworm
docker buildx imagetools inspect nginxinc/nginx-unprivileged:1.<minor>-alpine

Take top-level Digest: line. Replace @sha256:... and update comment date.

Out of scope

  • SBOM stage — issue body says skip.
  • Switching runtime base to debian:bookworm-slim — separate change, not asked.
  • USER directives — already present.

Refs #313


Generated by Claude Code

Replace mutable tags (`rust:latest`, `rust:slim`,
`nginxinc/nginx-unprivileged:alpine`) with digest-pinned references so
container builds are reproducible and resistant to upstream tag re-push
or registry takeover.

Pinned (verified via `docker buildx imagetools inspect` 2026-04-28):
- rust:1.95-slim-bookworm
  @sha256:caaf9ca7acd474892186860307d6f28e51fdbc1a4eada459fcff81517cf46a36
- nginxinc/nginx-unprivileged:1.27-alpine
  @sha256:65e3e85dbaed8ba248841d9d58a899b6197106c23cb0ff1a132b7bfe0547e4c0

Both builder and runtime stages now use the same pinned rust slim image
across relay/replay/storage/web; web runtime uses the pinned nginx
unprivileged variant. Each `FROM` carries an inline comment recording
the version, pin date, and bump command for traceability.

Considered alternative: pinning runtime stages to `debian:bookworm-slim`
(closer to true minimal base). Rejected for this PR — out of scope per
issue #313, which asks only to pin the existing `FROM` lines without
restructuring the multi-stage layout. Switching runtime base belongs to
a separate change.

SBOM stage explicitly out of scope per the issue body.

Refs #313
@intendednull intendednull merged commit c479670 into auto-fix/batch-2026-04-28-002530 Apr 28, 2026
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.

2 participants