fix(docker): chown ui-tui and node_modules on UID remap so TUI esbuild works (#28851)#33045
Merged
Conversation
…d works (#28851) When HERMES_UID remaps the hermes user from 10000 to another UID (e.g. matching the host user's UID for bind-mount ergonomics), the TUI launcher's esbuild step fails: ✘ [ERROR] Failed to write to output file: open /opt/hermes/ui-tui/dist/entry.js: permission denied TUI build failed. This is because the Dockerfile's build-time `chown -R hermes:hermes` on `/opt/hermes/{.venv,ui-tui,node_modules}` (line 154) wrote UID 10000, and stage2-hook.sh only re-chowned `.venv` on UID remap — leaving the TUI build trees still owned by the old UID. Extend the stage2 re-chown to include the same set as the build-time chown: `.venv`, `ui-tui`, `node_modules`. These are the runtime-writable trees under $INSTALL_DIR; everything else under /opt/hermes is read-only at runtime so keeping it root-owned is fine. Original fix targeted docker/entrypoint.sh which is now a deprecated shim; retargeted to docker/stage2-hook.sh where the .venv chown moved during the s6-overlay rework. Co-authored-by: Andreas Steffan <623481+deas@users.noreply.github.com>
Contributor
🔎 Lint report:
|
Collaborator
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.
Salvages #28851 (@deas).
Problem
When
HERMES_UIDremaps the hermes user from the build-time UID 10000 toanother UID (typical use case: matching the host user's UID so bind-mounted
files are owned correctly), the TUI launcher's esbuild step fails:
This is because the Dockerfile's build-time
chown -R hermes:hermeson/opt/hermes/{.venv,ui-tui,node_modules}(line 154) wrote UID 10000, andstage2-hook.shonly re-chowned.venvon UID remap — leaving the TUIbuild trees still owned by the old UID. esbuild needs to rewrite
ui-tui/dist/entry.json every launch where the source mtime is newerthan
dist/(or whenHERMES_TUI_FORCE_BUILD=1is set), and it runsas the new hermes UID, which can no longer write to
dist/.Fix
Extend the stage2 re-chown to include the same set as the build-time
Dockerfile chown:
chown -R hermes:hermes \ "$INSTALL_DIR/.venv" \ "$INSTALL_DIR/ui-tui" \ "$INSTALL_DIR/node_modules"These are the runtime-writable trees under
$INSTALL_DIR. Everything elseunder
/opt/hermesis read-only at runtime so keeping it root-owned is fine.Sync rule documented in the comment so future Dockerfile chown changes
keep stage2 in step.
Validation
Wrote an isolated TUI UID-remap E2E harness that forces the build path
(
HERMES_TUI_FORCE_BUILD=1) and runsdocker run --tuiwithHERMES_UID=1000.Baseline (
origin/main, current behavior)Salvage (this PR)
Regression checks
--version, hermes_cli import,_tui_need_npm_install: False,--tuino-TTY exit,tools.lazy_depsimport,gccpresent): 6 pass, 0 failAuthorship
Original change by @deas in #28851. Their branch targeted
docker/entrypoint.sh(a deprecated shim since the s6-overlay reworkmoved the real cont-init logic into
docker/stage2-hook.sh);retargeted the fix accordingly. Preserved attribution via
Co-authored-by:.Closes #28851.