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 #178

Merged
merged 3 commits into from
Oct 27, 2021

Conversation

darkowlzz
Copy link
Contributor

@darkowlzz darkowlzz commented Oct 11, 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 6 minutes on my
machine. Cross-compiling reduces the multi-arch build to under 2
minutes.
Manually tested the built image on amd64 and arm/v7 (raspberry pi).
Haven't tested on arm64.

⚠️ target branch of the PR is reconcilers-dev.

Update the Dockerfile to use tonistiigi/xx to cross-compile the
manager binaries natively and speed up the multi-arch image build
time.

Also, update github action for build to enable docker buildx.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
Signed-off-by: Sunny <darkowlzz@protonmail.com>
Prevent running the test twice in build workflow by removing the
dependency on docker-build on test.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
BUILD_PLATFORMS=linux/amd64 \
BUILD_ARGS="--cache-from=type=local,src=/tmp/.buildx-cache \
--cache-to=type=local,dest=/tmp/.buildx-cache-new,mode=max"
- # Temp fix
Copy link
Member

Choose a reason for hiding this comment

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

We can now use -cache-from=type=gha --cache-to=type=gha,mode=max as docker/buildx#681 was resolved.

@@ -12,13 +12,28 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@v2
- name: Setup QEMU
Copy link
Member

Choose a reason for hiding this comment

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

Do we actually need qemu considering we're only building for amd64 in this workflow?

- name: Setup QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: all
Copy link
Member

Choose a reason for hiding this comment

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

If we do need it, I suppose this should be set to the subset of platforms we actually do support:

Suggested change
platforms: all
platforms: linux/amd64,linux/arm/v7,linux/arm64

Copy link
Member

@relu relu left a comment

Choose a reason for hiding this comment

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

Since other controllers have the same configuration at the moment there's no reason for me to block this. I'll just get back with the set of changes proposed in my previous 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.

2 participants