Skip to content

fix(docker): chown gateway install tree on UID remap (salvage #37928) - #38655

Merged
benbarclay merged 1 commit into
mainfrom
fix/docker-chown-gateway-tree-salvage-37928
Jun 4, 2026
Merged

fix(docker): chown gateway install tree on UID remap (salvage #37928)#38655
benbarclay merged 1 commit into
mainfrom
fix/docker-chown-gateway-tree-salvage-37928

Conversation

@benbarclay

Copy link
Copy Markdown
Collaborator

Summary

Salvage of #37928 (@sarvesh1327), reduced to the still-needed delta.

/opt/hermes/gateway is a runtime-writable Python package: on first import the supervised gateway writes __pycache__ beneath it, and the image does not set PYTHONDONTWRITEBYTECODE. When HERMES_UID/PUID is remapped at boot (e.g. Unraid 99), usermod -u only re-chowns the hermes home dir; the build trees under /opt/hermes keep the build-time UID (10000). main already chowns .venv, ui-tui, and node_modules on remap (#38556) but missed gateway, so the remapped gateway hits EACCES writing __pycache__ (#27221).

This adds /opt/hermes/gateway to both chown sites:

  • the Dockerfile build-time chown -R hermes:hermes line
  • the stage2-hook build-tree ownership repair

so it tracks the remapped UID like its sibling trees.

Differences from #37928 as submitted

Dropped the uid_gid_remapped flag and the || [ "$uid_gid_remapped" = true ] chown gate. main's #38556 already solved that half, and more correctly — it probes the actual tree ownership (venv_owner != actual_hermes_uid) rather than tracking same-boot remaps, which also catches pre-existing ownership drift and stays idempotent. Keeping #37928's flag would regress that. The salvage is the gateway-tree addition only.

Credit preserved via Co-authored-by:.

Verification

Unit: test_dockerfile_node_modules_perms.py + new test_stage2_hook_install_dir_chown.py — 3 tests, green. shellcheck docker/stage2-hook.sh clean.

End-to-end against a real image build:

Fixes #27221.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docker Docker image, Compose, packaging backend/docker Docker container execution comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: entrypoint.sh misses chown for ui-tui/ and gateway/ when HERMES_UID is remapped

3 participants