Skip to content

chore(build): keep terraform and regenerable output out of the docker context - #641

Merged
ericfitz merged 1 commit into
mainfrom
chore/dockerignore-build-context
Jul 31, 2026
Merged

chore(build): keep terraform and regenerable output out of the docker context#641
ericfitz merged 1 commit into
mainfrom
chore/dockerignore-build-context

Conversation

@ericfitz

Copy link
Copy Markdown
Owner

Found while deploying #639 to k3s: docker build failed outright with
no space left on device while copying terraform-provider-aws_v6.56.0_x5 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 — nearly all of it files no image has ever needed.

Measurements

Taken with a FROM scratch + COPY . /ctx probe on a fresh buildx builder, so these are
full context transfers rather than BuildKit deltas (the first re-measure on the default
builder reported 72 kB because it only sent the diff):

context result
before 4.71 GB no space left on device
after 673 MB ✅ succeeds

The "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 init caches provider binaries under .terraform/,
    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 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 and
    regenerable. Same class as test/results/, whose existing comment records the context
    having 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, same
    rationale as the existing test/outputs/ exclusion.

I confirmed no Dockerfile references any of these paths before excluding them.

Verification

make build-server-container succeeds on the reduced context, so nothing an image actually
needs was excluded. (A bare docker build -f Dockerfile.controller . fails for an unrelated
reason — .docker-deps/tmi-client/ is staged by the build scripts, so these builds have to go
through 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

… 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
@ericfitz
ericfitz merged commit 422c56a into main Jul 31, 2026
12 checks passed
@ericfitz
ericfitz deleted the chore/dockerignore-build-context branch July 31, 2026 12:59
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