-
Notifications
You must be signed in to change notification settings - Fork 753
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
Add support for multiarch images, include ARM64 #1453
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
# Build the manager binary | ||
FROM golang:1.21 as builder | ||
FROM --platform=$BUILDPLATFORM golang:1.21 as builder | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes this will default to the local platform it is running on. There is no difference to local builds. They work as-is like previously |
||
|
||
ARG TARGETOS TARGETARCH | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These variables are not set anywhere. What are their default values? Are these specific to Docker? Can we remove them? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These arg are auto populated if not specified. They default to the local platform. https://docs.docker.com/reference/dockerfile/#automatic-platform-args-in-the-global-scope They are required for the multi arch build used in the go build line |
||
|
||
WORKDIR /workspace | ||
# Copy the Go Modules manifests | ||
|
@@ -18,7 +20,7 @@ COPY version/ version/ | |
|
||
# Build | ||
ARG LD_FLAGS | ||
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="$LD_FLAGS" -a -o manager cmd/main.go | ||
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="$LD_FLAGS" -a -o manager cmd/main.go | ||
|
||
# Use distroless as minimal base image to package the manager binary | ||
# Refer to https://github.com/GoogleContainerTools/distroless for more details | ||
|
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.
What is the purpose of this?
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.
This exports and retrieves docker build cache to GitHub cache to speed up build time if certain layers have not changed.
https://docs.docker.com/reference/cli/docker/buildx/build/#cache-to
on your local host, this is done transparently. Hence why the 2nd docker build is slightly faster