Repository navigation
fix: chown npm cache after global installs in Dockerfile - #1626
Merged
Merged
Conversation
The global npm installs (yarn, pnpm, @fission-ai/openspec) run as root and populate the npm cache (/home/madz/.npm, derived from ENV HOME) as root, with nothing re-chowning it afterward, so the madz user hits EACCES. Re-chown the cache after the global installs, pin NPM_CONFIG_CACHE, and add a build-time assertion that fails the build if the cache is not owned by madz. Closes #1624
Sync the new dockerfile-npm-cache-ownership capability spec into openspec/specs/ and move the change into the archive.
Owner
Author
Audit Results — dockerfile-npm-cache-chown-ordering (issue #1624)Goal fulfillment: The npm cache under Spec compliance:
Task completion: All OpenSpec tasks implemented; change archived to Quality check:
Verification: Build the image and assert |
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.
Description
Fix a Dockerfile bug (issue #1624) where the npm cache under
/home/madz/.npmwas left owned byrootafter the global npm installs, causingEACCESfor themadzuser at runtime. Root cause is ordering:RUN chown -R madz:node /app /home/madzran before the global installs (npm install -g yarn pnpmandnpm install -g @fission-ai/openspec@latest), andENV HOME=/home/madzmade npm resolve its cache to/home/madz/.npm, which those root-run installs populated as root with nothing re-chowning it afterward.This change:
ENV NPM_CONFIG_CACHE=/home/madz/.npmso the chown target is explicit and stable rather than implicitly derived fromHOME.RUN chown -R madz:node /home/madz/.npmafter every global install, so a futurenpm install -gcannot silently re-break ownership as long as it stays the last ownership operation on the cache.RUN test "$(stat -c '%U' /home/madz/.npm)" = madzthat fails the build if the cache is not owned bymadz.Type of Change
Testing
Dockerfile-only change; the project has no unit-test infrastructure for Dockerfile ownership. The regression guard is a build-time assertion (
RUN test "$(stat -c '%U' /home/madz/.npm)" = madz) that fails the build if the cache is not owned bymadz. Verification: build the image and assertstat -c '%U:%G' /home/madz/.npmreturnsmadz:node. CIlintandtestjobs pass.Coverage
Checklist
npm run lintpassesCloses #1624