fix(docker): USER root before global npm install in derived images - #16
Merged
Merged
Conversation
Fixes EACCES when building --docker derived images against base images with a non-root default USER (e.g. node:*-slim images that set USER node). Fixes #15
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.
Issues fixed
Fixes #15
Summary
derivedDockerfile()insrc/docker-image.jsbuilds a derived sandbox image asFROM <image>+RUN npm install -g @tbrandenburg/node-red-cli@<version>, with noUSER rootstep. Base images with a non-root defaultUSER(e.g.node:*-slimimages that setUSER node) fail withEACCESon/usr/local/lib/node_modules.This adds
USER rootimmediately before the npm install step. Derived images now always run as root; restoring the base image's original default user was intentionally left out of scope (would require inspecting the base image at build time) and is documented via a code comment.defaultDockerfile()(thenode:24-slim-based default sandbox) is untouched — it is already root by default and not part of this issue.Validation commands run
make ci(format + lint + test + audit) from the fix branch: 116/116 tests pass, lint clean, 0 npm audit vulnerabilities.E2E coverage
No new E2E test added. This is a Dockerfile-string-generation fix; the existing unit test (
test/unit/docker-image.unit.test.js) now assertsUSER rootappears immediately before thenpm install -gline in the generated derived Dockerfile. A true E2E repro would require pulling a real non-root community base image (e.g.ghcr.io/tbrandenburg/agentic-workflow-dev-env:0.1.5) and runningdocker build, which the existing test suite does not do for any--dockerpath; out of scope for this minimal fix.Risks / follow-ups
USER rootis a no-op for already-root base images; only changes behavior for non-root base images, fixing the reported failure.engines.node(currently only an easy-to-missEBADENGINEnpm warning). No new issue filed since the original issue already documents this as lower-priority/optional.