You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(openemr-cmd): pass HOST_UID/HOST_GID through compose to openemr container (#840)
## Summary
Completes the cross-repo HOST_UID story started in openemr/openemr#12642
(entrypoint side, already merged + new flex image SHA pinned via
dependabot #12644). This PR wires the openemr-devops side:
`wt_write_override` emits `HOST_UID`/`HOST_GID` env vars in the openemr
service block, sourced from `id -u` / `id -g` at worktree-add / regen
time.
## Result
For **non-uid=1000 hosts** (CI runners at uid=1001, multi-user dev
boxes, distros that start uids at 1001+, macOS via Docker Desktop):
apache inside the container now writes bind-mount files with the host's
uid. Host-side writes (`git commit`, IDE edits, `worktree regen`,
`worktree set-env`) work without any chown dance. The uid-mismatch class
of bugs that dominated #833 / #836 / #838 review cycles is eliminated
end-to-end.
For **uid=1000 hosts** (most Linux desktop developers): zero functional
change. The env vars are emitted unconditionally because the entrypoint
adoption block is a sub-millisecond no-op on uid=1000 and the consistent
behavior across hosts is worth more than the savings.
**Backwards compatible:** pre-HOST_UID-aware images silently ignore the
env vars.
## CI workarounds removed (now obsolete)
Both `sudo chown -R "$(id -u):$(id -g)"` steps in
`test-bats-openemr-cmd-real-docker.yml`:
1. **`worktree-lifecycle-e2e`** "One-shot chown back to runner (enables
host-side regen + set-env)" — added in #834
2. **`prek-workflow-e2e`** "One-shot chown back to runner (enables
host-side writes + git commits)" — added in #836
Both replaced with `NOTE:` comments documenting what used to live there
and why the chown is no longer needed — for archaeology by future
contributors.
## Kept as back-compat shim
The `#833` auto-chown block in `cmd_worktree_remove` stays in place.
Inline comment updated to reflect its new status (no-op when the image
honors HOST_UID; still useful for users on pre-HOST_UID images and for
any drift the entrypoint adoption might miss).
## Tests
New bats file `tests/bats/openemr-cmd/host_uid_compose.bats` pins three
behaviors:
1. `wt_write_override` emits `HOST_UID` and `HOST_GID` env vars in the
override file
2. Values match `id -u` / `id -g` at write time
3. Env vars are correctly nested under `services.openemr.environment`
(structural check via yaml.safe_load)
4. Emitted for all three env variants (easy / easy-light / easy-redis)
## Test plan
- [ ] BATS openemr-cmd (ubuntu-22.04 + macos-14) pass — new tests +
existing suite
- [ ] e2e — full worktree lifecycle: passes WITHOUT the sudo chown step
(proves apache now adopts runner uid; regen + set-env writes work as
runner)
- [ ] e2e — prek install + real git commit: passes WITHOUT the sudo
chown step (proves `git commit` from the worktree works as runner)
- [ ] Other e2e jobs unchanged
- [ ] FUNCS_END drift sentinel still passes (no new function added —
wt_write_override grew inline, last function still at line 1882)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Generated OpenEMR docker-compose override files now include the
current host user and group IDs (`HOST_UID`/`HOST_GID`) in the container
environment.
* **Bug Fixes**
* Worktree lifecycle and pre-install commit workflows no longer require
host-side ownership adjustment before regeneration and environment
setup.
* Permission recovery/chown behavior is more consistent, with
backward-compatible fallback for older images or ownership drift.
* **Tests**
* Added BATS coverage validating `HOST_UID`/`HOST_GID` emission and
stability of golden comparisons by masking host-specific values.
* Improved BATS harness sourcing for hermetic function-only execution.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
0 commit comments