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

chore: update go, improve cross-compilation in docker #343

Merged
merged 2 commits into from
Feb 4, 2022

Conversation

backjo
Copy link
Collaborator

@backjo backjo commented Feb 4, 2022

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

Signed-off-by: Jonah Back <jonah@jonahback.com>
@backjo backjo requested review from a team as code owners February 4, 2022 05:41
Signed-off-by: Jonah Back <jonah@jonahback.com>
@codecov
Copy link

codecov bot commented Feb 4, 2022

Codecov Report

Merging #343 (70dc3e2) into master (8cda93d) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8cda93d...70dc3e2. Read the comment docs.

@@ -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
Copy link
Collaborator

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?

Copy link
Collaborator Author

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 (
Copy link
Collaborator

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 😆

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yep!

Copy link
Collaborator

@eytan-avisror eytan-avisror left a comment

Choose a reason for hiding this comment

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

👍

@backjo backjo merged commit 14ffe9c into master Feb 4, 2022
@backjo
Copy link
Collaborator Author

backjo commented Feb 4, 2022

Nice - this improved the docker build time from ~39 minutes to ~6 minutes!

@backjo backjo deleted the chore/UpdateDockerfile branch February 4, 2022 19:42
@eytan-avisror
Copy link
Collaborator

Nice - this improved the docker build time from ~39 minutes to ~6 minutes!

Wow! Amazing improvement

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