Skip to content

build(taskfile): stop leaving the volume-init container behind - #147

Merged
Ilyes512 merged 2 commits into
mainfrom
build/cleanup-volume-init-containers
Sep 16, 2026
Merged

Ilyes512 merged 2 commits into
mainfrom
build/cleanup-volume-init-containers

Conversation

@Ilyes512

Copy link
Copy Markdown
Member

Summary

  • docker compose run --rm never removes what depends_on pulled in, so every task left a completed specs-cli-volume-init-1 behind — one stale container per project, forever.
  • A defer in the internal dc task 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 cleanup now actually removes development containers, as its summary already claimed: docker compose --profile "*" down --remove-orphans, deliberately without --volumes so the Go build cache survives.
  • .github/instructions/executing-commands.md notes the teardown, so the extra compose output at the end of a run is not mistaken for an error.

… 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.
@Ilyes512
Ilyes512 merged commit bd92199 into main Sep 16, 2026
5 checks passed
@Ilyes512
Ilyes512 deleted the build/cleanup-volume-init-containers branch September 16, 2026 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant