chore(build): keep terraform and regenerable output out of the docker context - #641
Merged
Merged
Conversation
… context `docker build` failed outright with "no space left on device" while copying terraform-provider-aws into the build context. .dockerignore excluded test/results/ and test/outputs/ but nothing else that had grown large, so the context was 4.71 GB, most of it files no image has ever needed. `terraform init` caches provider binaries under .terraform/ -- 4.3 GB across eight directories on a machine that has init'd every environment (aws-public alone is 1.6 GB). No Dockerfile references terraform/, so the whole tree is excluded rather than just **/.terraform/; that also keeps it from regrowing the next time a new environment is init'd. test/postman/test-results/ is another ~400 MB of newman output. It is already gitignored and regenerable -- the same class as test/results/, which carries the same comment about the context having reached 14 GB. The collections themselves are tracked source and stay in the context. node_modules/, coverage/, coverage_html/ and .dedupe/ round it out: all regenerable, none referenced by any Dockerfile. Measured with a `FROM scratch` + `COPY . /ctx` probe on a fresh buildx builder, so the numbers are full context transfers rather than BuildKit deltas: before 4.71 GB build FAILS, no space left on device after 673 MB build succeeds The "before" run reproduced the original failure exactly, dying on terraform-provider-oci_v8.5.0. Verified `make build-server-container` still succeeds on the reduced context, so nothing an image actually needs was excluded. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WnrVyySuyJFqcMxB8q3pNc
4 tasks
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.
Found while deploying #639 to k3s:
docker buildfailed outright withno space left on devicewhile copyingterraform-provider-aws_v6.56.0_x5into thebuild context.
.dockerignoreexcludedtest/results/andtest/outputs/but nothing else that had grownlarge, so the context was 4.71 GB — nearly all of it files no image has ever needed.
Measurements
Taken with a
FROM scratch+COPY . /ctxprobe on a fresh buildx builder, so these arefull context transfers rather than BuildKit deltas (the first re-measure on the default
builder reported 72 kB because it only sent the diff):
no space left on deviceThe "before" run reproduced the original failure exactly, dying on
terraform-provider-oci_v8.5.0.What's excluded and why
terraform/(4.3 GB) —terraform initcaches provider binaries under.terraform/,across eight directories on a machine that has init'd every environment (
aws-publicaloneis 1.6 GB). No Dockerfile references
terraform/, so the whole tree goes rather than just**/.terraform/— that also stops it regrowing the next time a new environment is init'd.test/postman/test-results/(~400 MB) — newman output, already gitignored andregenerable. Same class as
test/results/, whose existing comment records the contexthaving reached 14 GB. The collections themselves are tracked source and stay.
node_modules/(76 MB) — regenerable from the lockfile; no image runs a JS build.coverage/,coverage_html/,.dedupe/(~53 MB) — regenerable test/tool output, samerationale as the existing
test/outputs/exclusion.I confirmed no Dockerfile references any of these paths before excluding them.
Verification
make build-server-containersucceeds on the reduced context, so nothing an image actuallyneeds was excluded. (A bare
docker build -f Dockerfile.controller .fails for an unrelatedreason —
.docker-deps/tmi-client/is staged by the build scripts, so these builds have to gothrough
make.)Note
This is a build-context fix only; it does not reclaim disk on its own. The immediate outage
also needed
docker builder prune, which freed 22.56 GB of accumulated build cache.🤖 Generated with Claude Code
https://claude.ai/code/session_01WnrVyySuyJFqcMxB8q3pNc