fix: make .dockerignore ignore node_modules at any depth - #2431
Open
RudrenduPaul wants to merge 1 commit into
Open
fix: make .dockerignore ignore node_modules at any depth#2431RudrenduPaul wants to merge 1 commit into
RudrenduPaul wants to merge 1 commit into
Conversation
.dockerignore uses gitignore-like syntax but the two differ: a bare node_modules/ pattern in .dockerignore only matches the top-level node_modules directory, unlike .gitignore where the same pattern matches at any depth. Prefix the pattern with **/ so it is excluded from the build context regardless of nesting.
Author
|
Just flagging for visibility: this is a single-line, narrowly-scoped fix ( |
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.
Closes #1920
What this PR does
Fixes a
.dockerignorepattern that was written assuming.gitignoresemantics, which Docker does not follow.
Root cause
.dockerignoreline 7 reads:In
.gitignore, a bare directory pattern likenode_modules/(no leadingor embedded slash) matches that directory name at any depth in the
tree. Docker's
.dockerignoreparser does not carry over this behavior:per the Docker build context docs,
a pattern without
**/is anchored and only matches at the root of thebuild context. So the current pattern only excludes the top-level
./node_modules, not anynode_modulesdirectory that might exist deeperin the tree (e.g. under
scripts/,chart/, or any subpackage added inthe future) — the opposite of what the pattern is clearly meant to do.
Change
Single-line fix in
.dockerignore:The
**/prefix is the documented Docker idiom for "match this pattern atany depth," which restores the intended gitignore-like behavior the file
was already written to assume.
Verification
.dockerignoresyntax docs to confirm**/isrequired for depth-independent matching (unlike
.gitignore).grep/directory listing that the rest of.dockerignoreand the
Dockerfilebuild context are unaffected by this change — noother rule relies on
node_modules/staying root-only.node_modulescurrently exists in this repo (singlepackage.json, not a workspace/monorepo), so this change is a no-op forthe current tree and only guards against future/incidental nested
node_modulesdirectories inflating the build context or gettingcopied into an image layer.