-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] hack/dockerfile: add dockerignore for vendor.dockerfile #3649
base: master
Are you sure you want to change the base?
Conversation
Some of the Dockerfiles in this repository may needed the git source to do their work, but vendoring likely doesn't, and I noticed that sending over the build-context was considerably slowing down the process. This patch adds a dockerignoe specific for this Dockerfile. It's based on the `.dockerignore` at the root of the repository, but adds the `.git`, `.github`, and `vendor` directories. Possibly other non-code paths could be excluded as well, but would probably likely only bring minor improvements. before: make vendor ... [+] Building 100.6s (14/14) FINISHED ... => [internal] load build context 23.5s => => transferring context: 99.02MB 23.3s After removing `.git`: => [internal] load build context 15.2s => => transferring context: 43.10MB 15.1s After removing both `.git` and `vendor`: make vendor ... [+] Building 13.6s (13/13) FINISHED ... => [internal] load build context 1.2s => => transferring context: 5.24MB 1.0s Signed-off-by: Sebastiaan van Stijn <[email protected]>
This might still need work / discussion. Currently the first stage of the Dockerfile will use the And maybe the "copy back to host" step would not even be needed if the starting point after buildkit/hack/dockerfiles/vendor.Dockerfile Lines 3 to 9 in a9d6e1f
|
Ah, interesting, so I guess we have a step somewhere to check if
|
Yes we need the working tree so we can validate vendoring. Same with https://github.com/moby/buildkit/blob/master/hack/dockerfiles/generated-files.Dockerfile. Maybe we could just use |
It's a bit confusing though, because CI runs Lines 4 to 13 in 5e08ad3
The |
|
(...ignoring the current validation issue) I tend to think this is a premature optimization. User shouldn't need to think about maintaining a list of files purely for performance. Hopefully, BuildKit in the future can optimize it further automatically. Ignoring some files can easily become a subtle bug, especially because 1) even in the CI the files will now be different as dockerignore only applies to local files 2) missing git internal files are usually silently ignored. If some files are better ignored, it is better if that definition is at least in Dockerfile side. For buildkit maintainer, all the contexts are shared today and if you built any other target before, only small changes and metadata is sent. This is what I get with the first invocation.
Disclaimer: this is coming from the guy who put @crazy-max lmk if you disagree on the perf side. I might be spoiled by having a relatively fast machine. |
Tested on WSL with 9p protocol:
ext4:
|
Some of the Dockerfiles in this repository may needed the git source to do their work, but vendoring likely doesn't, and I noticed that sending over the build-context was considerably slowing down the process.
This patch adds a dockerignoe specific for this Dockerfile. It's based on the
.dockerignore
at the root of the repository, but adds the.git
,.github
, andvendor
directories. Possibly other non-code paths could be excluded as well, but would probably likely only bring minor improvements.before:
After removing
.git
:After removing both
.git
andvendor
: