Repository navigation
fix(docker): run the dev container as non-root - #45
Merged
Merged
Conversation
Dockerfile.dev had no USER, so next dev ran as root (Trivy DS-0002, HIGH). It now runs as the image's node user, uid 1000, which owns the bind-mounted source on most hosts; APP_UID and APP_GID override it in compose.
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 #39 (closed manually on merge, closing keywords do not apply to
develop).Finding
Trivy DS-0002 (HIGH):
Dockerfile.devhad noUSER, sonext devran as root inside the development container. The production image already runs unprivileged.Fix
Dockerfile.devswitches to the image'snodeuser (uid 1000) before installing dependencies, and copies files owned by it.compose.ymlruns the app as${APP_UID:-1000}:${APP_GID:-1000}, since that user must own the bind-mounted source; a host user other than 1000 sets both variables.Verified
node,/appandnode_modulesowned bynode.next devstarts and serves/login(200) and/dashboard(307 without session); files it writes stay owned by the host user, no permission error.make checkgreen.Not fixed here
docker compose uprunsnpm run seed:dev, whoseprisma/seed.dev.tsis untracked (private since #165). On a fresh clone the app command fails beforenext dev. Reported separately; the test above startednext devdirectly.