Skip to content

fix(docker): revert NODE_RED_CLI_DEFAULT_USERDIR; add /data auto-probe + --docker-userdir override - #34

Merged
tbrandenburg merged 1 commit into
mainfrom
issue-33-docker-userdir
Sep 6, 2026
Merged

fix(docker): revert NODE_RED_CLI_DEFAULT_USERDIR; add /data auto-probe + --docker-userdir override#34
tbrandenburg merged 1 commit into
mainfrom
issue-33-docker-userdir

Conversation

@tbrandenburg

Copy link
Copy Markdown
Owner

Issues fixed

Closes #33

Summary

Reverts the NODE_RED_CLI_DEFAULT_USERDIR env-var convention (#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, never on the host) that validates node_modules/* and node_modules/@*/* (following symlinks — real npm installs often symlink packages) 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 image 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/the auto-probe without an explicit --user-dir.
  • Updated README (auto-probe + flag docs, agentic-workflow-dev-env example now uses the auto-probe with zero flags).

A real bug was caught during e2e validation and fixed before merge: the initial Dirent.isDirectory()-based scan missed symlinked npm packages, which is exactly how the real agentic-workflow-dev-env image installs @tbrandenburg/node-red-agents — the probe silently failed against the actual motivating image until fixed to stat (following symlinks) instead of trusting Dirent flags.

Files changed

  • src/run-envelope.js — new resolveContainerDefaultUserDir (the /data probe) and resolveEffectiveUserDir (4-level precedence), replacing the reverted env-var logic.
  • bin/node-red-cli-sandbox-entry.js — sets probeContainerDefault: true (auto-probe is sandbox-only).
  • bin/node-red-cli.js — new --docker-userdir <path> flag, updated help text, extended --node-modules guard.
  • test/unit/run-envelope.unit.test.js — unit tests for the probe (true/false positive, symlinks, absent baseDir) and the 4-level precedence.
  • test/integration/docker.integration.test.js — real Docker integration tests: auto-probe true/false positive, --docker-userdir override, --user-dir precedence.
  • test/integration/run-envelope.integration.test.jsdockerUserDir option equivalents.
  • test/e2e/agentic-workflow-dev-env.e2e.test.js (new) — real, non-mocked e2e test against the actual ghcr.io/tbrandenburg/agentic-workflow-dev-env:latest image, proving the auto-probe discovers the real symlinked package with zero flags. Skips gracefully if Docker/network is unavailable.
  • README.md — replaced env-var docs with auto-probe + --docker-userdir docs.

Validation commands run

  • make format — clean (Prettier)
  • make lint — clean (ESLint)
  • make test (node --test) — 141/141 passing, 0 failed, 0 skipped
  • make ci (format + lint + test + audit, via pre-push hook) — all green, npm audit: 0 vulnerabilities

E2E coverage

  • New test/e2e/agentic-workflow-dev-env.e2e.test.js: builds a throwaway image derived from the real ghcr.io/tbrandenburg/agentic-workflow-dev-env:latest + this branch's own bin/src, confirms --docker <image> (no flags) discovers the real, symlinked @tbrandenburg/node-red-agents package via the /data auto-probe. Ran successfully in this environment (Docker + ghcr.io reachable).
  • Existing Docker integration tests extended with 4 new real-container cases covering both probe outcomes and the --docker-userdir override + precedence.

Risks / follow-ups

  • Breaking change for anyone who adopted the very recently released NODE_RED_CLI_DEFAULT_USERDIR — acceptable per the issue (release-notes-worthy, but intentional).
  • --docker-userdir is documented as ignored outside --docker mode and only threaded into the --docker envelope path, matching its stated container-path-override semantics.
  • No unrelated bugs found beyond the symlink issue above, which was fixed as part of this change (required for the auto-probe to work against the real motivating image).

…e + --docker-userdir override

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
@tbrandenburg
tbrandenburg merged commit d8c6b93 into main Sep 6, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Revert NODE_RED_CLI_DEFAULT_USERDIR; replace with a validated /data auto-probe + explicit --docker-userdir override

1 participant