fix(docker): chown gateway install tree on UID remap (salvage #37928) - #38655
Merged
Conversation
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.
Summary
Salvage of #37928 (@sarvesh1327), reduced to the still-needed delta.
/opt/hermes/gatewayis a runtime-writable Python package: on first import the supervised gateway writes__pycache__beneath it, and the image does not setPYTHONDONTWRITEBYTECODE. WhenHERMES_UID/PUIDis remapped at boot (e.g. Unraid99),usermod -uonly re-chowns the hermes home dir; the build trees under/opt/hermeskeep the build-time UID (10000).mainalready chowns.venv,ui-tui, andnode_moduleson remap (#38556) but missedgateway, so the remapped gateway hits EACCES writing__pycache__(#27221).This adds
/opt/hermes/gatewayto both chown sites:chown -R hermes:hermeslineso it tracks the remapped UID like its sibling trees.
Differences from #37928 as submitted
Dropped the
uid_gid_remappedflag 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 thegateway-tree addition only.Credit preserved via
Co-authored-by:.Verification
Unit:
test_dockerfile_node_modules_perms.py+ newtest_stage2_hook_install_dir_chown.py— 3 tests, green.shellcheck docker/stage2-hook.shclean.End-to-end against a real image build:
main, bootHERMES_UID=99 HERMES_GID=100→gatewaystays10000:10000; a write as uid 99 intogateway/fails with EACCES (the [Bug]: entrypoint.sh misses chown for ui-tui/ and gateway/ when HERMES_UID is remapped #27221 bug).gatewayis chowned to99:100alongside.venv/ui-tui/node_modules; the write succeeds.gatewayat10000:10000— no behavior change for the common path.Fixes #27221.