Repository navigation
A second checkout cannot take over the containers silently - #15
Merged
Merged
Conversation
Every clone uses the same compose project name, so starting from a second directory adopts and reconfigures the first one's containers. That is how a test install stopped serving its own domain here, with nothing said. The two stay one environment reachable from two folders: the shared name is also what keeps database volumes working, and deriving it from the directory would orphan every existing one. What changes is that taking over is announced. forge asks, --force skips the question, and with no terminal it refuses and names the flag. forge status says which folder owns the running containers. Detection needs nothing stored: compose already labels containers with project.working_dir. active_dir() reads it through compose_with_env so the installer can call it before .env exists. The check sits in compose_up, the single route every start goes through since the profile work, plus cmd_stop. CI reproduces it with a real second directory and takes ownership back through a trap. Verified it fails when check_owner is removed.
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.
Every clone uses the same compose project name, so starting from a second directory adopts and reconfigures the first one's containers. Seen for real on this machine while testing an upgrade:
~/Projects/pepitoThe running containers mounted the first.
pepito.devstopped serving, the files were untouched, and nothing said a word. Adocker compose up -dfrom the second directory did it — the installer was never involved, which is why the fix could not live there alone.What is actually shared
Worth separating, because it decided the design:
com.docker.compose.project: php-devforge— it belongs to the project name, not to a directory.Deriving the project name from the checkout would isolate the two, but it orphans every existing volume: the user's databases would look deleted. So the two stay one environment reachable from two folders, and what changes is that taking over is announced instead of silent.
forge --force <command>skips the question; with no terminal it refuses and names the flag.forge statusnow says which folder owns the running containers. With no conflict, nothing is printed at all.Detection stores nothing new
Compose already labels every container with
project.working_dir.active_dir()inlib/compose.shreads it throughcompose_with_env, so the installer can call it before.envexists — otherwise the project name falls back to the directory name and finds nothing.The check sits in
compose_up(), which #10 made the single route every start goes through, pluscmd_stop— stopping someone else's containers destroys nothing but is just as surprising.A claim in the plan was wrong
The plan said
install.shsilently repointed theforgesymlink withln -sfn. It does not — that line only runs when the link is absent or already points here, and there is an explicit "points somewhere else. Left alone." branch. The symlink on this machine had been repointed by hand during local verification. One less change.CI reproduces it
A real second directory, started from, then taken back, with a
traprestoring ownership however the step ends. Verified that removingcheck_ownermakes it fail withforge took over without being asked.Two things the local run caught that CI would not have: a second clone has no gitignored
docker-compose.local.yml, so the copied.envhas to drop it fromCOMPOSE_FILE; andforge status | grep -qdies of SIGPIPE underpipefail— the same trap asforge profile on tools | grepin #10.