-
Notifications
You must be signed in to change notification settings - Fork 40
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
chore: update go, improve cross-compilation in docker #343
Conversation
Signed-off-by: Jonah Back <jonah@jonahback.com>
Signed-off-by: Jonah Back <jonah@jonahback.com>
Codecov Report
@@ Coverage Diff @@
## master #343 +/- ##
=======================================
Coverage 51.09% 51.09%
=======================================
Files 33 33
Lines 4505 4505
=======================================
Hits 2302 2302
Misses 2062 2062
Partials 141 141 Continue to review full report at Codecov.
|
@@ -15,7 +15,7 @@ COPY api/ api/ | |||
COPY controllers/ controllers/ | |||
|
|||
# Build | |||
RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -a -o manager main.go | |||
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH GO111MODULE=on go build -a -o manager main.go |
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.
So these env vars should be available by default? also within the github action workflows?
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.
Yep, docker sets these up.
@@ -22,3 +22,56 @@ require ( | |||
k8s.io/client-go v0.19.6 | |||
sigs.k8s.io/controller-runtime v0.7.0 | |||
) | |||
|
|||
require ( |
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.
These are all from go mod update
? wow 😆
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.
yep!
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.
👍
Nice - this improved the docker build time from ~39 minutes to ~6 minutes! |
Wow! Amazing improvement |
See https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide/ for more info. TL;DR - this change uses Go's native cross-compilation inside the Docker build to minimize the amount of time spent using emulation.
Signed-off-by: Jonah Back jonah@jonahback.com