Skip to content

Commit

Permalink
feat: linux/arm64 compatibility
Browse files Browse the repository at this point in the history
Fixes: cert-manager#283

Signed-off-by: Robin Breathe <[email protected]>
  • Loading branch information
isometry committed Jun 12, 2024
1 parent d2efcbe commit b5323b5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/on-push-to-main-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/on-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
FROM golang:1.21 as builder
WORKDIR /workspace

ARG TARGETARCH=amd64
ARG TARGETOS=linux
ARG TARGETARCH
ARG TARGETOS

ENV GOPROXY=direct
# Copy the Go Modules manifests
Expand All @@ -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
Expand Down
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,17 @@ docker-build: test
docker-push:
docker push ${IMG}

PLATFORMS ?= linux/arm64,linux/amd64
.PHONY: docker-buildx
docker-buildx: ## Build docker image for the manager with cross-platform support
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
- docker buildx create --name project-v3-builder
docker buildx use project-v3-builder
- docker buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross .
- docker buildx rm project-v3-builder
rm Dockerfile.cross

CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
controller-gen:
$(call go-install-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/[email protected])
Expand Down

0 comments on commit b5323b5

Please sign in to comment.