feat(docker): reduce base image vulnerabilities - #540
Conversation
📝 WalkthroughWalkthroughThe Dockerfile runtime stage now uses a non-root distroless Node.js 24 image, preserves the built application copy, and invokes ChangesDocker runtime image
Estimated code review effort: 1 (Trivial) | ~2 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
libs/tools/src/docker/Dockerfile (2)
16-20: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winKeep builder and runtime Node versions aligned.
The builder still tracks
node:lts-bookworm-slim, while the runtime is fixed to Node 24. When LTS advances, build-time and runtime Node versions may diverge, undermining backward compatibility. Pin the builder to Node 24 or share oneNODE_VERSIONargument across both stages.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@libs/tools/src/docker/Dockerfile` around lines 16 - 20, Align the builder stage’s Node image with the Node 24 distroless runtime by updating its base image or introducing a shared NODE_VERSION build argument used by both stages. Preserve the existing build and runtime commands while ensuring they always use the same major Node version.
16-16: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick winPin and verify the distroless base image.
The mutable
:nonroottag can silently change runtime contents, making vulnerability results and rollbacks non-reproducible. Prefer a digest-pinned image with automated digest updates and signature verification. Distroless documents Cosign verification for its images. (github.com)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@libs/tools/src/docker/Dockerfile` at line 16, Update the Dockerfile’s distroless base image reference to use a verified immutable digest instead of the mutable :nonroot tag. Configure the repository’s existing image-update automation to track and refresh that digest, and add the applicable Cosign signature verification step for the pinned distroless image.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@libs/tools/src/docker/Dockerfile`:
- Around line 16-20: Align the builder stage’s Node image with the Node 24
distroless runtime by updating its base image or introducing a shared
NODE_VERSION build argument used by both stages. Preserve the existing build and
runtime commands while ensuring they always use the same major Node version.
- Line 16: Update the Dockerfile’s distroless base image reference to use a
verified immutable digest instead of the mutable :nonroot tag. Configure the
repository’s existing image-update automation to track and refresh that digest,
and add the applicable Cosign signature verification step for the pinned
distroless image.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 69cb7db3-7648-4fda-bccc-91d95dbfe8a7
📒 Files selected for processing (1)
libs/tools/src/docker/Dockerfile
Description
Switch the base image to
gcr.io/distroless/nodejs24-debian13:nonroot. This will reduce the number of vulnerabilities in the base image to 0, and since ADC itself does not introduce any vulnerabilities, all vulnerabilities have been eliminated.The trade-off is that the image now does not include any shell, package manager, or unnecessary packages. Therefore, it is no longer possible to use commands like
docker execto access the container shell for debugging. However, launching the inspector using Node.js options is still possible.Checklist
Summary by CodeRabbit