Skip to content

chore(docker): add and expand .dockerignore files to shrink build contexts - #6409

Open
another-rex wants to merge 1 commit into
google:masterfrom
another-rex:build-stage-dockerignore
Open

another-rex wants to merge 1 commit into
google:masterfrom
another-rex:build-stage-dockerignore

Conversation

@another-rex

Copy link
Copy Markdown
Contributor

Overview

Adds root .dockerignore and go/.dockerignore, and expands vulnfeeds/.dockerignore to exclude large test fixtures and unrelated directories from Docker build contexts during build-and-stage (and local Docker builds).

(AI-assisted PR — part of a series of independent low-effort build-and-stage optimizations.)

Details

  • Root .dockerignore: Only docker/worker-base/Dockerfile, gcp/workers/worker/Dockerfile, and gcp/workers/oss_fuzz_worker/Dockerfile build from repo root .. Excluding unrelated top-level directories (including website/ where build-frontend3 creates node_modules mid-build) and osv/ecosystems/cassettes (29 MB of VCR test fixtures) shrinks root build context transfer from 335.9 MB to 1.55 MB (~99.5% reduction) while keeping osv/osv-schema/validation/schema.json intact.
  • go/.dockerignore: Excludes **/testdata, **/__snapshots__, and **/*_test.go (including 14 MB go/osv/ecosystem/testdata), shrinking go/ build context from 17.0 MB to 1.44 MB (~91.5% reduction) and preventing test-only edits from invalidating Docker cache.
  • vulnfeeds/.dockerignore: Adds **/testdata, test_data, **/__snapshots__, and **/*_test.go (including 70 MB vulnfeeds/git/testdata), shrinking each of the 9 vulnfeeds contexts from 90.7 MB to ~616 KB (~99.3% reduction).

Testing

  • Audited all COPY instructions in Dockerfiles built from ., go/, and vulnfeeds/ and confirmed no production code embeds or references excluded test directories.
  • Verified root context transfer (1.55 MB) and inspected all copied paths inside a test build.
  • Built go/Dockerfile (--target custommetrics) locally: context 1.44 MB, succeeded.
  • Built vulnfeeds/cmd/mirrors/debian-copyright-mirror/Dockerfile locally: context 616 KB, succeeded.
  • Ran poetry run tools/lint_and_format.sh: passed.

agy

@codecov-commenter

codecov-commenter commented Nov 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.57%. Comparing base (51fa7d3) to head (f077cd0).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6409   +/-   ##
=======================================
  Coverage   55.57%   55.57%           
=======================================
  Files         222      222           
  Lines       22928    22928           
=======================================
  Hits        12743    12743           
  Misses      10182    10182           
  Partials        3        3           
Flag Coverage Δ
go 59.20% <ø> (ø)
vulnfeeds 46.57% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@another-rex another-rex added the wheel-of-fortune Intentionally blank label Nov 20, 2026
@another-rex
another-rex marked this pull request as ready for review November 20, 2026 01:36

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wheel-of-fortune Intentionally blank

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants