Repository navigation
Conversation
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.
Fixes #25
Summary
Both runtime stages of
server/Dockerfileandweb/Dockerfileinheritrootfrom thenode:22-slimbase image — neither Dockerfile has aUSERdirective, so the API and the web container both run as uid 0. This adds the missing directive and fixes the ownership it implies.Changes
server/Dockerfile(runtime stage)/app/datais created in the image before the user is dropped, becausedocker-compose.ymlmounts theterminal-datanamed volume there:Docker initialises an empty named volume from the image directory at that path, including its ownership. Creating and chowning
/app/datain the image is therefore what keeps the volume writable fornode; without it the volume would be created root-owned and the API would fail at startup, whenserver/src/db.tsrunsmkdirSync(dataDir, { recursive: true })andserver/src/auth.tswrites the generated key withwriteFileSync(keyFile, generated, { mode: 0o600 }). The web container mounts the same volume read-only (:ro), so no ownership change is needed for it.web/Dockerfile(runtime stage)The standalone Next.js bundle only reads its own output at runtime, so chowning
/appand switching users is sufficient.The
buildstages are unchanged — they only need write access to/appwhile compiling.Why this is safe
nodeuser already exists in the official image (uid/gid 1000); nouseraddis needed.rootprovided — both justnodea JS entrypoint and bind a high port (>1024), so there is no reason to keep uid 0.CAP_requirements are introduced or removed.chownruns after the finalCOPY, in the runtime stage only.Verification
The change is Dockerfile-only;
npm run test -w server,npm run build -w serverandnpm run build -w web(the jobs in.github/workflows/ci.yml) do not build or run the images, so they are unaffected by this diff. I could not rundocker buildon the machine this was prepared on, so the build itself is unverified here — CI does not exercise the Dockerfiles either. Worth a maintainer-sidedocker compose build && docker compose upto confirm the volume-ownership behaviour described above.