diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 2bfe81c0b..7e941b4bf 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -30,10 +30,12 @@ jobs: path: ~/.cache/go-build key: ${{ runner.os }}-go-build-v1-${{ github.run_id }} - - name: Build operator and Tag Latest - run: make docker-build - env: - IMG: ${{ env.REGISTRY_URL }}/${{ env.ORG }}/${{ env.REPO }}:latest + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Buildx + id: buildx + uses: docker/setup-buildx-action@v3 - name: Login to Registry uses: docker/login-action@v3 @@ -42,7 +44,12 @@ jobs: username: ${{ secrets.REGISTRY_USERNAME }} password: ${{ secrets.REGISTRY_PASSWORD }} - - name: Push latest operator - run: make docker-push - env: - IMG: ${{ env.REGISTRY_URL }}/${{ env.ORG }}/${{ env.REPO }}:latest + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + push: true + platforms: linux/amd64,linux/arm64 + tags: ${{ env.REGISTRY_URL }}/${{ env.ORG }}/${{ env.REPO }}:latest + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/Dockerfile b/Dockerfile index ed4194dad..204f822a1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ # Build the manager binary -FROM golang:1.21 as builder +FROM --platform=$BUILDPLATFORM golang:1.21 as builder + +ARG TARGETOS TARGETARCH WORKDIR /workspace # Copy the Go Modules manifests @@ -18,7 +20,7 @@ COPY version/ version/ # Build ARG LD_FLAGS -RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="$LD_FLAGS" -a -o manager main.go +RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="$LD_FLAGS" -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