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

Dockerfile: cross compile images using native builder #45

Merged
merged 1 commit into from
Jan 10, 2023

Conversation

willnorris
Copy link
Member

@willnorris willnorris commented Jan 10, 2023

Use a build image built for the native architecture so that it doesn't run in emulation mode.

This also allows us to switch to Chainguard's wolfi/glibc build image. This limits our build architectures to just amd64 and arm64, but that is sufficient for our needs.

Recently our build times have been up to 20 minutes; this brings them back down to about 3 minutes.

(cc @amouat as FYI)

Updates #42
Updates #43

@willnorris willnorris force-pushed the will/crosscompile branch 3 times, most recently from ee834fc to a342bb0 Compare January 10, 2023 02:22
@willnorris willnorris marked this pull request as ready for review January 10, 2023 03:18
Dockerfile Outdated
RUN CGO_ENABLED=0 GOOS=linux go build -v ./cmd/golink
ARG TARGETOS TARGETARCH TARGETVARIANT
RUN \
if [ "${TARGETARCH}" = "arm" ] && [ "${TARGETVARIANT}" ]; then \

Choose a reason for hiding this comment

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

I'd usually expect to see a shell -z test in cases like this:

if ... && [ -z "${TARGETVARIANT}" ]; then

Copy link
Member Author

Choose a reason for hiding this comment

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

ah, yes. -n in this case, but done.

Use a build image built for the native architecture so that it doesn't
run in emulation mode.

Switch to Chainguard's wolfi/glibc build image. This limits our build
architectures to just amd64 and arm64, but that is sufficient for our
needs.

Updates #42
Updates #43

Signed-off-by: Will Norris <[email protected]>
@willnorris willnorris merged commit 3af59c5 into main Jan 10, 2023
@willnorris willnorris deleted the will/crosscompile branch January 10, 2023 04:32
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