feature:Dev Dockerfiles run as root with an unpinned base image - #1140
Merged
Conversation
6 tasks
|
🎉 This PR is included in version 1.8.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #1116
Docker Dev Hardening — Audit Issue 28/30
Area: Infra (
frontend/Dockerfile.dev,contracts/Dockerfile.dev,docker-compose.yml)Severity: Low
Scope: Development-only (not production images; prod deploys via Vercel/Netlify/static hosting per README)
Date: 2026-08-22
Problem
frontend/Dockerfile.devandcontracts/Dockerfile.devran their build/dev tooling as root by default (noUSERdirective).docker-compose.ymlbind-mounts live source into the frontend container (./frontend:/app); a compromised transitive build dependency (npm ci,cargo build) would run as root with write access to the bind-mounted host source tree.contracts/Dockerfile.devpinned its base image to a mutable, dated tag (rust:1.75-slim) with no digest pin.Changes
frontend/Dockerfile.devUSER node, using the pre-existing non-rootnodeuser shipped bynode:18-alpine.RUN chown -R node:node /appso the anonymousnode_modulesvolume — where Vite writes its dev cache (node_modules/.vite) — is owned by the runtime user.CHOKIDAR_USEPOLLING=true(set indocker-compose.yml) lets Vite watch the bind-mounted, host-owned source via polling (read-only on source; writes go to thenode-ownednode_modulesvolume).contracts/Dockerfile.devrust:1.75-slim@sha256:70c2a016184099262fd7cee46f3d35fec3568c45c62f87e37f7f665f766b1f74This is the immutable multi-arch index digest, so the tag can no longer be silently re-pushed to change the build base while still resolving on both amd64 and arm64 dev machines.
RUN useradd -m -s /bin/bash builderto create a non-root build user.RUN chown -R builder:builder /contracts /usr/local/cargosocargo buildcan write its output to the persistedcontracts_targetvolume and toCARGO_HOMEwithout root.USER builderso the dev/build process runs unprivileged.docker-compose.ymlrequired no changes —CHOKIDAR_USEPOLLING=trueand the volume mounts already support non-root operation once ownership is correct in the images.Verification
Run in a Docker-enabled environment:
Acceptance criteria:
docker compose up -dstill functions identically for local dev (hot reload + contract building).whoamireturnsnode/builder).