Skip to content

Commit

Permalink
peerpod-ctl: use CC for multi-arch images for peerpod-ctl
Browse files Browse the repository at this point in the history
Fixes: #1432

Signed-off-by: Qi Feng Huo <[email protected]>
  • Loading branch information
Qi Feng Huo committed Sep 15, 2023
1 parent 58f31c2 commit 3d4861e
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions peerpod-ctrl/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@ COPY main.go main.go
COPY api/ api/
COPY controllers/ controllers/

RUN if [ "$TARGETARCH" = s390x ] ; then ln /usr/bin/gcc /usr/bin/s390x-linux-gnu-gcc; fi
RUN if [ "$TARGETARCH" = ppc64le ] ; then ln /usr/bin/gcc /usr/bin/powerpc64-linux-gnu-gcc; fi

# Build
# the GOARCH has not a default value to allow the binary be built according to the host where the command
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
RUN CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build ${GOFLAGS} -a -o manager main.go
# CC=gcc because the cgo compiler will be always be gcc in image golang-fedora, even for s390x and ppc64le
RUN CC=gcc CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build ${GOFLAGS} -a -o manager main.go

FROM --platform=$TARGETPLATFORM fedora:36
RUN if [ "$CGO_ENABLED" = 1 ] ; then dnf install -y libvirt-libs /usr/bin/ssh && dnf clean all; fi
Expand Down

0 comments on commit 3d4861e

Please sign in to comment.