diff --git a/peerpod-ctrl/Dockerfile b/peerpod-ctrl/Dockerfile index 665b54a85f..d3dc9bd350 100644 --- a/peerpod-ctrl/Dockerfile +++ b/peerpod-ctrl/Dockerfile @@ -1,5 +1,13 @@ # Build the manager binary -FROM --platform=$TARGETPLATFORM quay.io/confidential-containers/golang-fedora:1.20.8-38 as builder +ARG BUILDER_BASE=quay.io/confidential-containers/golang-fedora:1.20.8-38 +ARG BASE=registry.fedoraproject.org/fedora:38 + +# This dockerfile uses Go cross-compilation to build the binary, +# we build on the host platform ($BUILDPLATFORM) and then copy the +# binary into the container image of the target platform ($TARGETPLATFORM) +# that was specified with --platform. For more details see: +# https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide/ +FROM --platform=$BUILDPLATFORM $BUILDER_BASE as builder ARG TARGETOS ARG TARGETARCH ARG CGO_ENABLED=1 @@ -28,7 +36,7 @@ COPY controllers/ controllers/ RUN CC=gcc CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build ${GOFLAGS} -a -o manager main.go # Target Image -FROM --platform=$TARGETPLATFORM registry.fedoraproject.org/fedora:38 +FROM --platform=$TARGETPLATFORM $BASE ARG CGO_ENABLED=1 RUN if [ "$CGO_ENABLED" = 1 ] ; then dnf install -y libvirt-libs openssh-clients && dnf clean all; fi