Skip to content

Optimize .dockerignore when there are exclusions#20872

Merged
vdemeester merged 1 commit intomoby:masterfrom
duglin:Issue20470
Mar 4, 2016
Merged

Optimize .dockerignore when there are exclusions#20872
vdemeester merged 1 commit intomoby:masterfrom
duglin:Issue20470

Conversation

@duglin
Copy link
Copy Markdown
Contributor

@duglin duglin commented Mar 2, 2016

Closes #20470

Before this PR we used to scan the entire build context when there were
exclusions in the .dockerignore file (paths that started with !). Now we
only traverse into subdirs when one of the exclusions starts with that dir
path.

Signed-off-by: Doug Davis dug@us.ibm.com

@calavera
Copy link
Copy Markdown
Contributor

calavera commented Mar 2, 2016

@duglin is this a replacement of #20128 or just a general improvement?

@duglin
Copy link
Copy Markdown
Contributor Author

duglin commented Mar 2, 2016

@calavera I think #20128 is a different (but related) issue. I still haven't had a chance to review his code. His PR, if adopted, might replace this code I dunno, but until his PR is reviewed I think this improvement is needed.

@icecrime
Copy link
Copy Markdown
Contributor

icecrime commented Mar 3, 2016

@duglin A failure on win2lin could be related:

10:09:22 FAIL: docker_cli_build_test.go:3420: DockerSuite.TestBuildDockerignoreExceptions
10:09:22 
10:09:22 docker_cli_build_test.go:3472:
10:09:22     c.Fatal(err)
10:09:22 ... Error: failed to build the image: Sending build context to Docker daemon 5.632 kB

10:09:22 Step 1 : FROM busybox
10:09:22  ---> d9551b4026f0
10:09:22 Step 2 : ADD . /bla
10:09:22  ---> 525151bf3a0d
10:09:22 Removing intermediate container bb73d439035b
10:09:22 Step 3 : RUN sh -c "[[ -f /bla/src/x.go ]]"
10:09:22  ---> Running in cd47636aea86
10:09:22  ---> c4744cd1dd6e
10:09:22 Removing intermediate container cd47636aea86
10:09:22 Step 4 : RUN sh -c "[[ -f /bla/Makefile ]]"
10:09:22  ---> Running in 1c650905761e
10:09:22  ---> cc828d2eb450
10:09:22 Removing intermediate container 1c650905761e
10:09:22 Step 5 : RUN sh -c "[[ ! -e /bla/src/_vendor ]]"
10:09:22  ---> Running in 34058da14892
10:09:22  ---> 6cee219e56d5
10:09:22 Removing intermediate container 34058da14892
10:09:22 Step 6 : RUN sh -c "[[ ! -e /bla/.gitignore ]]"
10:09:22  ---> Running in 5a0284b90ae2
10:09:22  ---> b8b5fdd2cd67
10:09:22 Removing intermediate container 5a0284b90ae2
10:09:22 Step 7 : RUN sh -c "[[ ! -e /bla/README.md ]]"
10:09:22  ---> Running in 14819c13dc08
10:09:22  ---> a1d0fe340d67
10:09:22 Removing intermediate container 14819c13dc08
10:09:22 Step 8 : RUN sh -c "[[  -e /bla/dir/dir/foo ]]"
10:09:22  ---> Running in 3ee3f23439de
10:09:22 The command '/bin/sh -c sh -c "[[  -e /bla/dir/dir/foo ]]"' returned a non-zero code: 1

@icecrime icecrime added the status/failing-ci Indicates that the PR in its current state fails the test suite label Mar 3, 2016
Closes moby#20470

Before this PR we used to scan the entire build context when there were
exclusions in the .dockerignore file (paths that started with !). Now we
only traverse into subdirs when one of the exclusions starts with that dir
path.

Signed-off-by: Doug Davis <dug@us.ibm.com>
@duglin duglin removed the status/failing-ci Indicates that the PR in its current state fails the test suite label Mar 3, 2016
@duglin
Copy link
Copy Markdown
Contributor Author

duglin commented Mar 3, 2016

@icecrime ok, windows issue is fixed!

@calavera
Copy link
Copy Markdown
Contributor

calavera commented Mar 3, 2016

LGTM

@vdemeester
Copy link
Copy Markdown
Member

LGTM 🐹

vdemeester added a commit that referenced this pull request Mar 4, 2016
Optimize .dockerignore when there are exclusions
@vdemeester vdemeester merged commit 9bc62e6 into moby:master Mar 4, 2016
@duglin duglin deleted the Issue20470 branch April 25, 2016 14:29
@xaka
Copy link
Copy Markdown

xaka commented Jan 23, 2017

It is possible that this PR broke nested exclusions (#30018) and better be reverted to bring important feature back to life? @vdemeester

@thaJeztah thaJeztah added the area/builder Build label Sep 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.dockerignore ! pattern results in slow builds on large contexts

7 participants