chore(docker): add .dockerignore to keep .git out of the build context#1517
Open
piciolo wants to merge 1 commit into
Open
chore(docker): add .dockerignore to keep .git out of the build context#1517piciolo wants to merge 1 commit into
piciolo wants to merge 1 commit into
Conversation
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.
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.
Problem
Dockerfilebuilds the image withCOPY . /var/www/, and the repo has no.dockerignore, so the entire working tree — including the ~400 MB.gitdirectory — is copied into every image. On large PRs this fills the CI runner disk during layer extraction and the preview environment build fails:Fix
Add a
.dockerignorethat 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 bydocker/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 underpublic/build/..idea/,.vscode/— editor files.storage/,bootstrap/cache/,rust/andpublic/build/are intentionally left untouched — they are needed at runtime and the first three are already copied explicitly in theDockerfile.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.