-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Build binaries with minimal deps and remove autogen code #40180
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
Conversation
f7af678 to
8f477f2
Compare
Dockerfile
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps instead of copying these to /usr/local/bin we could just add the bundles directory to PATH, similar to what I did in docker/cli#419 (not sure if there's code that expects the binaries to be in /usr/local/bin though)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the logic:
Lines 4 to 31 in c36460c
| copy_binaries() { | |
| local dir="$1" | |
| local hash="$2" | |
| # Add nested executables to bundle dir so we have complete set of | |
| # them available, but only if the native OS/ARCH is the same as the | |
| # OS/ARCH of the build target | |
| if [ "$(go env GOOS)/$(go env GOARCH)" != "$(go env GOHOSTOS)/$(go env GOHOSTARCH)" ]; then | |
| return | |
| fi | |
| if [ ! -x /usr/local/bin/runc ]; then | |
| return | |
| fi | |
| echo "Copying nested executables into $dir" | |
| for file in containerd containerd-shim ctr runc docker-init docker-proxy rootlesskit rootlesskit-docker-proxy dockerd-rootless.sh; do | |
| cp -f "$(command -v "$file")" "$dir/" | |
| if [ "$hash" = "hash" ]; then | |
| hash_files "$dir/$file" | |
| fi | |
| done | |
| # vpnkit is amd64 only | |
| if command -v "vpnkit.$(uname -m)" 2>&1 >/dev/null; then | |
| cp -f "$(command -v "vpnkit.$(uname -m)")" "$dir/vpnkit" | |
| if [ "$hash" = "hash" ]; then | |
| hash_files "$dir/vpnkit" | |
| fi | |
| fi | |
| } |
So we can add them anywhere into PATH, or add anywhere to PATH, or just copy them manually.
I wanted to reduce redundant code as much as possible here.
The other thing that makes it kinda tricky is each build target builds in a subdir, like bundles/binary-daemon and bundles/dynbinary-daemon, so I'd have to do this copy twice.
I could bind-mount the files in and update PATH to include each one, but this would only reduce the amount of copying we are doing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically my worry here is we have this list of commands that need to be copied as part of a build and different lists get out of sync.
8f477f2 to
1499b27
Compare
|
Ping |
thaJeztah
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops, forgot about this one; left some comments 🤗
This makes the binary build targets use a minimal build env instead of having to build all the stuff needed for the full dev enviornment. Signed-off-by: Brian Goff <[email protected]>
1499b27 to
f2d171a
Compare
This eliminates the need to lay down an auto-generated file. IIRC this was originally hadded for gccgo which we no longer support. Signed-off-by: Brian Goff <[email protected]>
Signed-off-by: Brian Goff <[email protected]>
Signed-off-by: Brian Goff <[email protected]>
The Dockerfile is not needed in any of the build targets. The one exception may be the dev image, however in most cases the docker source will be bind mounted into the container anyway. Signed-off-by: Brian Goff <[email protected]>
f2d171a to
e6d514d
Compare
|
Fixed. |
thaJeztah
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Dockerfile
Outdated
|
|
||
| FROM dev AS src | ||
| FROM runtime-dev AS src | ||
| # Make arg inheritable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: outdated comment?
|
|
||
| FROM src AS final | ||
| FROM dev AS final | ||
| COPY . /go/src/github.com/docker/docker |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit (no need to change); /go/src/github.com/docker/docker is the WORKDIR, is this could be
COPY . .| // Code generated by hack/make/.go-autogen. DO NOT EDIT. | ||
| DVEOF | ||
| LDFLAGS="${LDFALGS} \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops; typo: (LDFALGS); fixing in #40389
Upstream moby/moby#40180 removed the auto-generated code, replacing it with build-time variables (-X). This patch updates the Dockerfiles to account for this change. Signed-off-by: Sebastiaan van Stijn <[email protected]>
This was removed after refactoring the Dockerfile in moby#40180 Signed-off-by: Brian Goff <[email protected]>
More optimizations for the Dockerfile
i. Prevents rebuilding things just because there is some change in either of these files.
ii. Is not needed since we don't do nested build.