From f1a5fd098e9a24d02785608ead01569509c1213f Mon Sep 17 00:00:00 2001 From: Robin Breathe Date: Mon, 29 Apr 2024 12:39:56 +0200 Subject: [PATCH] feat: linux/arm64 compatibility Fixes: #283 Signed-off-by: Robin Breathe Signed-off-by: Brady Siegel --- .github/workflows/on-push-to-main-branch.yml | 1 + .github/workflows/on-release.yml | 1 + Dockerfile | 12 ++++++------ Makefile | 1 + 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/on-push-to-main-branch.yml b/.github/workflows/on-push-to-main-branch.yml index 84fa9936..39d789e6 100644 --- a/.github/workflows/on-push-to-main-branch.yml +++ b/.github/workflows/on-push-to-main-branch.yml @@ -43,6 +43,7 @@ jobs: build-args: | pkg_version=${{ env.PLUGIN_VERSION }} context: . + platforms: linux/amd64,linux/arm64 tags: | ${{ env.TAG_BASE }}:latest ${{ env.TAG_BASE }}:${{ env.PLUGIN_VERSION }} diff --git a/.github/workflows/on-release.yml b/.github/workflows/on-release.yml index 0e44c0c4..3f357c27 100644 --- a/.github/workflows/on-release.yml +++ b/.github/workflows/on-release.yml @@ -44,6 +44,7 @@ jobs: build-args: | pkg_version=${{ steps.tag.outputs.tag }} context: . + platforms: linux/amd64,linux/arm64 tags: | ${{ env.TAG_BASE }}:latest ${{ env.TAG_BASE }}:${{steps.tag.outputs.tag}} diff --git a/Dockerfile b/Dockerfile index 7162c346..1df40d7f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ # Build the manager binary -FROM golang:1.22 as builder +FROM --platform=${BUILDPLATFORM} golang:1.22 as builder WORKDIR /workspace -ARG TARGETARCH=amd64 -ARG TARGETOS=linux +ARG TARGETARCH +ARG TARGETOS ENV GOPROXY=direct # Copy the Go Modules manifests @@ -18,8 +18,8 @@ COPY main.go main.go COPY pkg/ pkg/ ENV CGO_ENABLED=0 -ENV GOOS=$TARGETOS -ENV GOARCH=$TARGETARCH +ENV GOOS=${TARGETOS:-linux} +ENV GOARCH=${TARGETARCH:-amd64} ENV GO111MODULE=on # Do an initial compilation before setting the version so that there is less to @@ -38,7 +38,7 @@ RUN VERSION=$pkg_version && \ # 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:nonroot +FROM --platform=${TARGETPLATFORM:-linux/amd64} gcr.io/distroless/static:nonroot LABEL org.opencontainers.image.authors="Jochen Ullrich " LABEL org.opencontainers.image.source=https://github.com/cert-manager/aws-privateca-issuer WORKDIR / diff --git a/Makefile b/Makefile index f5b23dc5..5036ad49 100644 --- a/Makefile +++ b/Makefile @@ -145,6 +145,7 @@ docker-build: test --build-arg pkg_version=${VERSION} \ --tag ${IMG} \ --file Dockerfile \ + --platform=linux/amd64,linux/arm64 \ ${CURDIR} # Push the docker image