-
Notifications
You must be signed in to change notification settings - Fork 187
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
Use tonistiigi/xx for cross-platform builds #458
Conversation
Update the Dockerfile to use tonistiigi/xx to cross-compile the manager binaries natively and speed up the multi-arch image build time. Signed-off-by: Sunny <darkowlzz@protonmail.com>
33dbe01
to
954a3a9
Compare
.github/workflows/e2e.yaml
Outdated
@@ -44,9 +61,11 @@ jobs: | |||
exit 1 | |||
fi | |||
- name: Build container image | |||
run: make docker-build IMG=test/kustomize-controller:latest | |||
run: make docker-build IMG=${{ env.REGISTRY }}/test/kustomize-controller:latest BUILD_ARGS=--push BUILD_PLATFORMS=linux/amd64 |
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.
Setting to one platform to keep the build short, about 2 minutes, same as before this change.
Building all the multi-arch images takes about 6 minutes, refer: https://github.com/fluxcd/kustomize-controller/pull/458/checks?check_run_id=3874846235#step:12:1 .
If it's okay to add 4 more minutes to the e2e workflow, I can remove BUILD_PLATFORMS
from here.
Also, continuing to use the make target here, instead of docker/build-push-action
, to exercise the makefile and catch any potential issues.
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.
Can we use https://github.com/fluxcd/source-controller/blob/main/.github/workflows/e2e.yaml#L47 instead of a registry? I would use the same workflow as SC if possible.
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.
oh right, that'd work 😅 didn't see there. Thanks.
e2e: - Enable buildx. - Build only for linux/amd64 and export the built image. Signed-off-by: Sunny <darkowlzz@protonmail.com>
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
Thanks @darkowlzz ☕
This PR didn't take into account the changes to the GitHub workflows as I explicitly documented in the referred issue:
|
Thanks. Working on adding that next 🙂 |
Update the Dockerfile to use tonistiigi/xx to cross-compile the
manager binaries natively and speed up the multi-arch image build
time.
Refer fluxcd/flux2#1910
NOTE: Multi-arch build used to take about 7 minutes on my
machine. Cross-compiling reduces the multi-arch build to under 3
minutes.
Manually tested the built image on amd64 and arm/v7 (raspberry pi).
Haven't tested on arm64.
Observations of the build time in github actions CI: Building all the
images for multi-arch builds takes about 6 minutes, compared to 42
minutes before.