fix: worktree mounts its own code + hosts entry stays in sync - #16
Merged
Conversation
… in sync Two follow-ups to the 4.3.0 worktree isolation: - BUG A: the worktree container still bind-mounted the MAIN checkout's code, because APP_ROOT_DIR / APP_WORKING_DIR / APP_OPT_DIR (and the other APP_*_DIR) came from the shared .env and pointed at the main app. AppIdentity now repoints the declared directory variables at the WORKTREE's own paths and injects them into docker compose (and creates them if missing), so the worktree app serves its own branch's code / config instead of the main checkout's. - BUG B: the worktree domain could resolve to the main app's ip because the hosts entry was only written during init (which is skipped when the docker-file hash is unchanged). The hosts entry is now re-synced with the effective identity on every "lab up", so the worktree domain always points at the worktree ip. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
4.3.1 — worktree apps now serve their OWN branch
Follow-up to the 4.3.0 retest. 4.3.0 fixed startup/IP/port; these two fixes make a worktree app actually usable for testing its own branch.
BUG A (critical) — worktree bind-mounted the MAIN checkout's code
APP_ROOT_DIR/APP_WORKING_DIR/APP_OPT_DIR(and the otherAPP_*_DIR) came from the shared.envand pointed at the main app, so the "worktree app" was just a second copy ofmainon a different IP (worktree-only routes 404'd).AppIdentitynow repoints the declared directory variables at the worktree's own paths and injects them into docker compose (creating them if missing). The container serves the worktree's code/config..envis still never rewritten.BUG B — worktree domain resolved to the main app's IP
The hosts entry was only written during
init, which is skipped when the docker-file hash is unchanged — so after upgrading, the worktree domain could still point atmain's IP. The hosts entry is now re-synced with the effective identity on everylab up(writes only when it changed), so the worktree domain always points at the worktree IP.BUG C — already fixed (usage note)
downandtestgained-y/--yesin 4.1.0: uselab down -y/lab test -yfor headless runs (they were run without-yin the report).Verification
npm run build✅ ·npm test✅ (29 suites / 61 tests; newAppIdentitytests assert the worktree dir overrides + that only declared vars are injected + none in a main checkout).🤖 Generated with Claude Code