[WIP] hack/dockerfile: add dockerignore for vendor.dockerfile#3649
[WIP] hack/dockerfile: add dockerignore for vendor.dockerfile#3649thaJeztah wants to merge 1 commit into
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 <github@gone.nl>
|
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: |
|
Going to close this since the PR is in draft and it's been a few years since the last comment. |
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
.dockerignoreat the root of the repository, but adds the.git,.github, andvendordirectories. 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
.gitandvendor: