Skip to content
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

Dockerfiles: Use cross compilation for kubectl-gadget Dockerfile. #2216

Merged
merged 1 commit into from
Nov 14, 2023

Conversation

eiffel-fl
Copy link
Member

Hi.

This PR makes kubectl-gadget.Dockerfile using cross compilation, it speeds up build for other architectures:

$ docker buildx build --load --platform=linux/arm64 -f Dockerfiles/kubectl-gadget.Dockerfile -t kubectl-gadget .
[+] Building 235.5s (14/14) FINISHED                                                                     docker-container:magical_sammet
 => [internal] load build definition from kubectl-gadget.Dockerfile                                                                 0.0s
 => => transferring dockerfile: 1.89kB                                                                                              0.0s
 => [internal] load .dockerignore                                                                                                   0.0s
 => => transferring context: 2B                                                                                                     0.0s
 => [internal] load metadata for docker.io/library/alpine:3.18                                                                      2.1s
 => [internal] load metadata for docker.io/library/golang:1.20-bullseye                                                             2.0s
...
 => [builder 5/5] RUN cd /gadget && GOHOSTOS=linux GOHOSTARCH=arm64 make kubectl-gadget                                            41.4s
...
 => importing to docker
$ docker run --rm -ti kubectl-gadget            francis/kubectl-gadget-docker-cross *%
WARNING: The requested image's platform (linux/arm64) does not match the detected host platform (linux/amd64/v3) and no specific platform was requested
/ #
# Other terminal
$ docker cp angry_shockley:/bin/kubectl-gadget /tmp 
Successfully copied 87.2MB to /tmp
$ file /tmp/kubectl-gadget                      francis/kubectl-gadget-docker-cross *%
/tmp/kubectl-gadget: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, Go BuildID=jowbtesoByV0av3PcG9O/KQcXh1JQmFyFXFmi6AAs/yFwYPe_b5K_Poppn2F1f/kevBJNNvk740Te9iA4OM, with debug_info, not stripped

Best regards.

Signed-off-by: Francis Laniel <flaniel@linux.microsoft.com>
Copy link
Member

@burak-ok burak-ok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for configuring it that fast.
LGTM

@eiffel-fl eiffel-fl merged commit 3c51ff5 into main Nov 14, 2023
50 checks passed
@eiffel-fl eiffel-fl deleted the francis/kubectl-gadget-docker-cross branch November 14, 2023 09:36
@eiffel-fl
Copy link
Member Author

Thank you for the review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants