diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 4c2b9d2d0..395566a1d 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -9,7 +9,7 @@ on: - "v?[0-9]+.[0-9]+.[0-9]+-dev.[0-9]+" # pull_request: env: - PLATFORMS: linux/amd64 + PLATFORMS: linux/amd64,linux/arm64 jobs: docker: name: Docker diff --git a/Dockerfile b/Dockerfile index c74d9e1b0..63523f4f7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,11 @@ # Build the manager binary -FROM golang:1.19 as builder +FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.19 as builder + +ARG BUILDPLATFORM +ARG TARGETPLATFORM +ARG TARGETOS +ARG TARGETARCH +RUN echo "BUILDPLATFORM: ${BUILDPLATFORM}, TARGETPLATFORM: ${TARGETPLATFORM}, TARGETOS: ${TARGETOS}, TARGETARCH: ${TARGETARCH}" WORKDIR /workspace # Copy the Go Modules manifests @@ -18,11 +24,11 @@ COPY internal/ internal/ COPY pkg/ pkg/ # Build -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go +RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} GO111MODULE=on go build -a -o manager main.go # Use distroless as minimal base image to package the manager binary # Refer to https://github.com/GoogleContainerTools/distroless for more details -FROM gcr.io/distroless/static-debian11:nonroot +FROM --platform=${TARGETPLATFORM:-linux/amd64} gcr.io/distroless/static-debian11:nonroot WORKDIR / COPY --from=builder /workspace/manager . ENTRYPOINT ["/manager"]