-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
docker: Multiplatform cross-compilation #3323
Conversation
Codecov ReportPatch coverage has no change and project coverage change:
Additional details and impacted files@@ Coverage Diff @@
## master #3323 +/- ##
==========================================
+ Coverage 73.16% 73.18% +0.01%
==========================================
Files 258 258
Lines 19912 19912
==========================================
+ Hits 14569 14572 +3
+ Misses 4418 4416 -2
+ Partials 925 924 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
dde958d
to
a6219a0
Compare
6713a15
to
bc232b5
Compare
Dockerfile
Outdated
RUN CGO_ENABLED=0 go install -a -trimpath -ldflags "-s -w -X go.k6.io/k6/lib/consts.VersionDetails=$(date -u +"%FT%T%z")/$(git describe --tags --always --long --dirty)" | ||
RUN --mount=target=. \ | ||
--mount=type=cache,target=/root/.cache/go-build \ | ||
--mount=type=cache,target=/go/pkg \ |
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.
--mount=type=cache,target=/go/pkg \ |
We don't need it, we already include the vendor folder
bc232b5
to
6d572b3
Compare
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.
LGTM 👍 I'm OK with merging this even as it is, but if we go with this option, please remove the Makefile target.
Dockerfile
Outdated
RUN CGO_ENABLED=0 go install -a -trimpath -ldflags "-s -w -X go.k6.io/k6/lib/consts.VersionDetails=$(date -u +"%FT%T%z")/$(git describe --tags --always --long --dirty)" | ||
RUN --mount=target=.,readonly \ | ||
--mount=type=cache,target=/root/.cache/go-build \ | ||
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -a -trimpath -o /usr/bin/k6 |
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.
Additionalyl I think -a
compeltely negates the fact that we are havging a cache of the builds as -a
basically saays to ignore that and rebuild
6d572b3
to
2871ff5
Compare
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.
LGTM! Just one nit
Dockerfile
Outdated
RUN apk --no-cache add git=~2 | ||
RUN CGO_ENABLED=0 go install -a -trimpath -ldflags "-s -w -X go.k6.io/k6/lib/consts.VersionDetails=$(date -u +"%FT%T%z")/$(git describe --tags --always --long --dirty)" | ||
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -a -trimpath -o /usr/bin/k6 |
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.
nit: Is there a reason we want the -a
? I think it rebuilds the stdlib which seems .. pointless 🤷
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.
I was commenting the same, but you were faster!!
I researched about it and I didn't find any reason, I guess there was some historical reason for it considering how old this command is.
I'm going to remove it as it isn't needed at the moment.
The base branch was changed.
Removed the -a flag as we don't think it is required. Probably, it had been set for some historical reason related to the old CI or the old go toolchain. At the moment, there isn't a requirement for maintaing it.
1231ce1
to
3eb4e39
Compare
What?
Move to use the cross compilation for docker multi-arch builds.
Why?
https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide/
Related PR(s)/Issue(s)
#3301