Skip to content

chore(docker): add a .dockerignore to keep the build context small - #164

Merged
arjunrajlab merged 1 commit into
masterfrom
chore/dockerignore
Aug 1, 2026
Merged

chore(docker): add a .dockerignore to keep the build context small#164
arjunrajlab merged 1 commit into
masterfrom
chore/dockerignore

Conversation

@arjunrajlab

Copy link
Copy Markdown
Collaborator

Every worker in this repo builds from the repo root (docker build . -f workers/annotations/<name>/Dockerfile), and Docker sends the entire build context to the daemon before running a single instruction. There was no .dockerignore, so that context is the whole working tree.

On a real development checkout that is ~11 GB, essentially all of it from files no image ever uses:

Path Size What it is
workers/annotations/sam_automatic_mask_generator/local_tests 6.5 G .venv with torch/CUDA + a 2.6 GB sam_vit_h_4b8939.pth checkpoint
workers/annotations/sam2_fewshot_segmentation/local_tests 4.1 G same shape
.git 96 M

That cost is paid on every build, by all 107 Dockerfiles in the repo.

What this excludes

.git, .github, per-worker local_tests/ and .venv/ scratch, and compiled bytecode (__pycache__, *.py[cod]).

Why it is safe

Nothing listed is referenced by any COPY/ADD — checked by grepping every Dockerfile in the repo:

  • No COPY/ADD anywhere mentions local_tests, .venv, __pycache__ or .git.
  • Worker COPY lines name specific files (entrypoint.py, environment.yml, utils.py, …), not whole worker directories, so excluding a subdirectory of a worker cannot remove anything a build needs.
  • The two directories that are copied wholesale — annotation_utilities and worker_client — only lose stale __pycache__, which is regenerated inside the image anyway.
  • tests/ is deliberately not excluded: the *_test images copy it.

Verified in practice as well as by inspection: the eight ML worker images in #163 were all built with this file in place, and each one loaded its baked-in model cache and ran a real job against a live NimbusImage stack.

Note

This is orthogonal to #163 (image size) — this is build context transfer, which affects every build in the repo including CPU workers. Split out deliberately so #163 stays focused.


Generated by Claude Code

Every worker builds from the repo root, so each `docker build` sent the entire
working tree to the daemon before running any instruction. On a checkout with
local test venvs and downloaded model checkpoints that is ~11 GB per build,
across 107 Dockerfiles.

Excludes .git, .github, per-worker local_tests/ and .venv/ scratch, and
compiled bytecode. Nothing listed is referenced by any COPY/ADD -- checked by
grepping every Dockerfile: worker COPY lines name specific files rather than
directories, and the two directories copied wholesale (annotation_utilities,
worker_client) only lose stale __pycache__.

Verified in practice: the eight ML worker images in #163 were built with this
file in place, and each one loaded its baked-in models and ran a real job
against a live NimbusImage stack.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DGVianXJET5VVja76jahvj
@arjunrajlab
arjunrajlab merged commit 4beb1e7 into master Aug 1, 2026
1 check passed
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