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

Use tonistiigi/xx for cross-platform builds #458

Merged
merged 2 commits into from
Oct 13, 2021

Conversation

darkowlzz
Copy link
Contributor

@darkowlzz darkowlzz commented Oct 12, 2021

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.

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>
@darkowlzz darkowlzz force-pushed the xx-builds branch 3 times, most recently from 33dbe01 to 954a3a9 Compare October 12, 2021 20:18
@@ -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
Copy link
Contributor Author

@darkowlzz darkowlzz Oct 12, 2021

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

@darkowlzz darkowlzz marked this pull request as ready for review October 12, 2021 20:30
e2e:
- Enable buildx.
- Build only for linux/amd64 and export the built image.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
Copy link
Member

@stefanprodan stefanprodan left a comment

Choose a reason for hiding this comment

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

LGTM

Thanks @darkowlzz

@stefanprodan stefanprodan added the area/ci CI related issues and pull requests label Oct 13, 2021
@stefanprodan stefanprodan merged commit 4ed25e0 into fluxcd:main Oct 13, 2021
@hiddeco
Copy link
Member

hiddeco commented Oct 13, 2021

This PR didn't take into account the changes to the GitHub workflows as I explicitly documented in the referred issue:

[..] While doing this, it should be taken into account that the GitHub Action workflows should likely be rewritten to make more efficiently use of the Dockerfile during (end-to-end) tests, and could be making use of (commit SHA based) caching and/or a local registry.

@darkowlzz darkowlzz deleted the xx-builds branch October 13, 2021 12:26
@darkowlzz
Copy link
Contributor Author

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 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ci CI related issues and pull requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants