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

Build manager on the host #2289

Merged
merged 3 commits into from
Nov 6, 2023

Conversation

swiatekm
Copy link
Contributor

@swiatekm swiatekm commented Oct 28, 2023

Description:

Cross-compile the manager binary on the host and copy the appropriate binary into the container during the build. This makes image building much faster, as we don't need to rely on emulation via QEMU.

I've also removed our local toolchain's dependency on buildx while I was at it, as it's not strictly necessary.

Looks like we could build the binaries in a matrix job, but given that they take around 15 minutes without cache, I don't think it's worth it to mess around with artifacts.

Issue: #2295

Testing:
Temporarily made the build happen for this PR, and it worked fine.

@swiatekm swiatekm changed the title Build/cross compile Build manager on the host Oct 28, 2023
@swiatekm swiatekm force-pushed the build/cross-compile branch 2 times, most recently from c895491 to ffadd08 Compare October 30, 2023 08:56
@swiatekm swiatekm added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Oct 30, 2023
@swiatekm swiatekm changed the title Build manager on the host Build manager on the host and copy it into the container image Oct 30, 2023
@swiatekm swiatekm marked this pull request as ready for review October 30, 2023 09:34
@swiatekm swiatekm requested a review from a team October 30, 2023 09:34
@@ -86,19 +101,5 @@ jobs:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
build-args: |
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we not need these args anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They're set while building the binary, straight from the environment. They're not needed for anything else.

Copy link
Contributor

@jaronoff97 jaronoff97 left a comment

Choose a reason for hiding this comment

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

I think this LGTM, but we should wait on @pavolloffay 's review here too

@swiatekm swiatekm force-pushed the build/cross-compile branch 2 times, most recently from d1d6705 to 4e61c5a Compare October 31, 2023 10:35
@swiatekm swiatekm changed the title Build manager on the host and copy it into the container image Build manager on the host Oct 31, 2023
Instead of building the manager binary during the docker image build,
instead build it on the host and copy it to the image.

This massively improves the performance of cross compilation, which
is much faster natively vs emulation via QEMU.
This way we can cache based on the state of go.sum.
@jaronoff97 jaronoff97 merged commit f398a9d into open-telemetry:main Nov 6, 2023
27 checks passed
@swiatekm swiatekm deleted the build/cross-compile branch November 30, 2023 10:09
ItielOlenick pushed a commit to ItielOlenick/opentelemetry-operator that referenced this pull request May 1, 2024
* Build manager on the host

Instead of building the manager binary during the docker image build,
instead build it on the host and copy it to the image.

This massively improves the performance of cross compilation, which
is much faster natively vs emulation via QEMU.

* Setup Go after checking our code in E2E tests

This way we can cache based on the state of go.sum.

* Minor improvements
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Skip Changelog PRs that do not require a CHANGELOG.md entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants