diff --git a/peerpod-ctrl/Dockerfile b/peerpod-ctrl/Dockerfile index cd35e8afb..a9ff55704 100644 --- a/peerpod-ctrl/Dockerfile +++ b/peerpod-ctrl/Dockerfile @@ -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