Skip to content

chore(docker): add .dockerignore to keep .git out of the build context#1517

Open
piciolo wants to merge 1 commit into
lanedirt:mainfrom
piciolo:chore/add-dockerignore
Open

chore(docker): add .dockerignore to keep .git out of the build context#1517
piciolo wants to merge 1 commit into
lanedirt:mainfrom
piciolo:chore/add-dockerignore

Conversation

@piciolo

@piciolo piciolo commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Problem

Dockerfile builds the image with COPY . /var/www/, and the repo has no .dockerignore, so the entire working tree — including the ~400 MB .git directory — is copied into every image. On large PRs this fills the CI runner disk during layer extraction and the preview environment build fails:

ERROR: failed to extract layer …: write /var/www/.git/objects/pack/pack-….pack: no space left on device

Fix

Add a .dockerignore that keeps build-only / never-needed content out of the build context and image:

  • .git, .gitattributes, .github — version-control / CI metadata, never needed at runtime (this is the big one, ~400 MB).
  • vendor/ — reinstalled at container startup by docker/entrypoint.sh (composer install), so it does not need to be copied in.
  • node_modules/ — not needed at runtime; frontend assets are pre-built and committed under public/build/.
  • .idea/, .vscode/ — editor files.

storage/, bootstrap/cache/, rust/ and public/build/ are intentionally left untouched — they are needed at runtime and the first three are already copied explicitly in the Dockerfile.

Effect

Shrinks the build context and resolves the "no space left on device" preview-build failures on large PRs (e.g. #1297). No behavioural change to the app.

The Dockerfile copies the whole repo with COPY . /var/www/ and there is no
.dockerignore, so the ~400MB .git history is copied into the image. On large
PRs this fills the CI runner disk during layer extraction (preview builds fail
with 'no space left on device').

Exclude version-control/CI metadata (.git, .github), plus vendor/ (reinstalled
at startup by docker/entrypoint.sh) and node_modules/ (not needed at runtime;
assets are pre-built in public/build). storage/, bootstrap/cache/, rust/ and
public/build/ are left untouched.
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