fix(docker): fall back to image's default userDir via NODE_RED_CLI_DEFAULT_USERDIR - #32
Merged
Merged
Conversation
tbrandenburg
added a commit
that referenced
this pull request
Sep 6, 2026
…e + --docker-userdir override (#34) Reverts the NODE_RED_CLI_DEFAULT_USERDIR env-var convention from #31/#32, which required community image authors to opt in and was confirmed dead-on-arrival for the motivating agentic-workflow-dev-env image. Replaces it with: - a best-effort /data auto-probe (sandbox entrypoint only) that validates node_modules/* and node_modules/@*/* (following symlinks) for a package.json declaring a "node-red" key before trusting the path - an explicit --docker-userdir <path> CLI flag as a reliable, zero-guessing override for any convention - a 4-level userDir precedence: --user-dir > --docker-userdir > auto-probed /data > ephemeral default - a clearer --node-modules preflight error when combined with --docker-userdir/auto-probe without an explicit --user-dir Closes #33 Co-authored-by: Tom Brandenburg <t_bh@gmx.de>
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
Closes #31
Summary
--dockerpreviously never pointed Node-RED's userDir at a community image's own pre-populated default userDir (e.g./datainagentic-workflow-dev-env), forcing redundant--node-modulesre-installs even when a package was already baked into the image.This adds an opt-in env-var convention, resolved inside the container by the existing shared
runFlowInvocation()insrc/run-envelope.js:NODE_RED_CLI_DEFAULT_USERDIR. Image authors set this to their own conventional userDir path.--user-diralways wins (unchanged).NODE_RED_CLI_DEFAULT_USERDIRis set and points at an existing directory: used asuserDir, never deleted afterward (image-owned).Files changed
src/run-envelope.js:resolveDefaultUserDir()helper + precedence wiring inrunFlowInvocation.bin/node-red-cli-sandbox-entry.js: doc-comment only.bin/node-red-cli.js: one-line HELP_TEXT note for image authors.README.md: documents the new convention under--docker.test/unit/run-envelope.unit.test.js(new): unit coverage forresolveDefaultUserDir(unset / valid dir / nonexistent path / file-not-dir).test/integration/run-envelope.integration.test.js: env-var userDir used + never removed; explicit--user-dirprecedence.test/integration/docker.integration.test.js: real-Docker regression test reproducing the issue's exact scenario (pre-baked module discovered via--dockeralone) + precedence test (--user-diroverrides the env var).Validation
make lint— passmake format— passmake test— 130/130 passed, 0 skipped (Docker was available in the CI/dev environment, so all new Docker integration tests actually ran against real containers, not skipped)make audit— 0 vulnerabilities (ran as part ofmake civia the pre-push hook)E2E coverage
No e2e changes needed — this is a Docker/env-var wiring concern already covered by the new Docker integration tests, per the issue's own agreed testing strategy (integration-level, real Docker + real embedded Node-RED, is the right layer; full
test/e2e/example-flow run adds no additional signal here).Risks / follow-ups
ghcr.io/tbrandenburg/agentic-workflow-dev-envwould need its own change to exportNODE_RED_CLI_DEFAULT_USERDIR=/datato benefit from this.Unrelated issues found