feat: worktree-isolated network identity (own ip/port/domain) + hosts crash fix - #15
Merged
Merged
Conversation
…run side by side
Worktree support previously namespaced only the compose project name; the
loopback IP, host port and hosts domain were still taken from .env, so a
worktree reused the main checkout's APP_IP and its container failed to bind
(":443 already allocated"). It also relied on rewriting .env, which dirties a
committed .env and fails when .env is read-only.
Introduce AppIdentity: the effective compose project / domain / ip is now
resolved at runtime as an OVERLAY and injected into docker compose (shell env
overrides .env), the loopback alias and the hosts entry - never written to .env.
Inside a worktree it derives a suffixed compose project + domain and allocates
its own stable loopback ip (cached in the per-worktree registry), so the app
runs alongside the main checkout on its own ip/port/domain. .env and
.env.template stay untouched (works even when committed or read-only), and the
main checkout is unaffected. Adds `lab up --domain <domain>` / `--ip <ip>` to set
the identity explicitly (CI/agents). Doppler stays on the base project.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
removeDomain and removeCurrent passed a Map to the vendored forEach helper, which cannot iterate Maps and threw "Could not iterate given object!" - breaking the hosts-conflict path and `lab down`'s hosts cleanup. Use the native Map.forEach (as set() already does). 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.0 — worktree apps run side by side with
mainFixes the bug report: a worktree app couldn't start because only the compose project name was namespaced — the loopback IP / host port / hosts domain still came from
.env, so the worktree reusedmain'sAPP_IPand the container failed to bind (:443 already allocated). It also depended on rewriting.env, which dirties a committed.envand fails when.envis read-only.What changed
AppIdentityoverlay. The effective compose project / domain / IP is now resolved at runtime and injected into docker compose (shell env overrides.env), the loopback alias, and the hosts entry — never written to.env.mainon its own ip/port/domain..envand.env.templatestay untouched → works even when.envis committed or read-only, andgit statusstays clean.maincheckout unaffected; Doppler project stays shared.lab up --domain <domain>/--ip <ip>to set the identity explicitly (CI/agents).DockerHosts.removeDomain/removeCurrentcrashed with "Could not iterate given object!" (passed aMapto the vendoredforEach). Now use nativeMap.forEach— also fixeslab down's hosts cleanup.Not needed anymore
The reporter's manual workaround (hand-editing
APP_DOMAINin the worktree.env) is obsolete. (lab test -yfor headless runs already shipped in 4.1.0.)Verification
npm run build✅ ·npm test✅ (29 suites / 59 tests). NewAppIdentitytests (main passthrough, worktree isolation, fresh-IP allocation + idempotent reuse, suffix idempotency, overrides) and aDockerHostsregression test (no Map-iteration crash). The docker-level side-by-side run is validated by the reporter's environment.🤖 Generated with Claude Code