build(taskfile): stop leaving the volume-init container behind - #147
Merged
Merged
Conversation
… run `docker compose run --rm` removes the container it was asked to run and nothing else. Every service that writes to the cache volume pulls in volume-init through depends_on to get the directories created and chowned, so each task left a completed specs-cli-volume-init-1 behind — harmless, but it accumulates one stale container per project that only ever surfaces in `docker ps -a`. The internal dc task is the single point every compose invocation passes through, so one defer there covers dc:run:*, dc:build, dc:shell and the lint, docs, markdown and demo taskfiles that call into it. Task runs deferred commands when the task ends regardless of its result, so a failing test tears the container down too. The teardown is the same defer the demo:record task already uses for the socket proxy.
The cleanup task promised "gitignored files, untracked files and development containers" and delivered a `git clean` — a hugo or docs-preview service started from this project survived a cleanup untouched. `docker compose --profile "*" down --remove-orphans` runs first, across every profile, so the promise holds. Deliberately without `--volumes`: the cache volume holds the Go build, module and golangci-lint caches, and throwing those away would turn a workspace cleanup into a multi-minute rebuild.
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.
Summary
docker compose run --rmnever removes whatdepends_onpulled in, so every task left a completedspecs-cli-volume-init-1behind — one stale container per project, forever.deferin the internaldctask removes it again, covering every compose invocation in the repo (dc:run:*,dc:build,dc:shell, lint, docs, markdown, demo). It runs on failure too.task cleanupnow actually removes development containers, as its summary already claimed:docker compose --profile "*" down --remove-orphans, deliberately without--volumesso the Go build cache survives..github/instructions/executing-commands.mdnotes the teardown, so the extra compose output at the end of a run is not mistaken for an error.