-
Notifications
You must be signed in to change notification settings - Fork 9
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
ci: Enable building for s390x and arm64 #73
Changes from 4 commits
ac72953
36780e0
71af676
d03ce8e
5a625eb
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,5 @@ | ||
# Build the manager binary | ||
FROM docker.io/library/golang:1.19 as builder | ||
FROM --platform=$BUILDPLATFORM docker.io/library/golang:1.19 AS builder | ||
|
||
WORKDIR /workspace | ||
# Copy the Go Modules manifests | ||
|
@@ -13,8 +13,10 @@ RUN go mod download | |
COPY main.go main.go | ||
COPY pkg/ pkg/ | ||
|
||
ARG 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. dont we need something like this ? 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. Not really, we only need 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. Thanks @ashokpariya0 does it mean maybe that the logic on bridge-marker or whatever projects that done the same as it can be simplified maybe? 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. @oshoval No, it's important to handle default cases. The combination of |
||
|
||
# Build | ||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager main.go | ||
RUN CGO_ENABLED=0 GOOS=linux GOARCH="${TARGETARCH}" go build -a -o manager main.go | ||
jschintag marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
FROM registry.access.redhat.com/ubi8/ubi-minimal | ||
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. Which image is pulled here? Do the resulting image arch and the BUILDPLATFORM match? 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 have tested the whole workflow on my own fork against ghcr.io. 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. If you set 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. https://docs.docker.com/build/building/multi-platform/#cross-compilation Nevermind, I see. 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 believe we need to update the following: 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 am not familiar about it by heart tbh curious, iiuc it works without it on all the required combinations ? 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 have tested native with docker/podman by running 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. Native amd64 -> amd64 works as well with docker/podman. 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.
we can fix this one later specifically according needs, because atm native host/target amd64 works which is what important in this aspect host: amd64, target: s390x - does work ? (podman / docker, higher priority for podman) maybe the PRs of @ashokpariya0 might help in this, if it works there Thanks 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. The combination of host: s390x and target: amd64 is not supported, so there is no need to test this configuration. Host: amd64 Also For the final stage of the build, better to use the following: |
||
WORKDIR / | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,26 @@ | |
|
||
destination=$1 | ||
version=$(grep "^go " go.mod |awk '{print $2}') | ||
tarball=go$version.linux-amd64.tar.gz | ||
|
||
arch="$(uname -m)" | ||
|
||
case $arch in | ||
x86_64 | amd64) | ||
arch="amd64" | ||
;; | ||
aarch64 | arm64) | ||
arch="arm64" | ||
;; | ||
s390x) | ||
arch="s390x" | ||
;; | ||
*) | ||
echo "ERROR: invalid arch=${arch}, only support x86_64, aarch64 and s390x" | ||
exit 1 | ||
;; | ||
esac | ||
Comment on lines
+8
to
+22
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. Can we modify it like below? Instead of restricting the architecture to only support x86_64, aarch64, and s390x, it would be helpful to allow building for other architectures, such as ppc64le, using the make command. 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. lets see please if we do need it imo, because there wasnt an item to support ppc and i prefer to not do just parts unless needed on the other hand, the suggestion is indeed more compact and robust, so it will be fine to adapt this thanks EDIT - for more context 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 actually prefer the more verbose version, since it is more easy to read later on and to see what is intended to work. My proposal would be i keep the switch-case, but change the default to a warning instead of an error. 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 do understand it is more verbose, but it is good to be in the same format on the repos we maintain we do need to error imo if one supplied unsupported version in case we keep it this way Thanks |
||
|
||
tarball=go$version.linux-$arch.tar.gz | ||
url=https://dl.google.com/go/ | ||
|
||
mkdir -p $destination | ||
|
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.
Do we want to add arm please ? (as you added on install go script)
(assuming git actions support arm cross compile)
if you prefer it can wait for follow-ups, unless it is straight forward
(according other PRs i saw, it seems straight forward and supported)
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.
Sure i can add it. I just haven't tested it, so if it works or not i can't say.
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 have added it as a separate commit so it is easier to revert should it not work out.