Skip to content

Commit

Permalink
build: fix arm build
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Kotzbauer <christian.kotzbauer@gmail.com>
  • Loading branch information
ckotzbauer committed Dec 11, 2021
1 parent 701f60e commit cc13944
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
FROM golang:1.17.5-buster as builder

ARG TARGETOS
ARG TARGETARCH

ARG version
ENV VERSION=$version

WORKDIR /go/src/app
COPY . .
RUN make manager
RUN TARGETOS=${TARGETOS} TARGETARCH=${TARGETARCH} make manager && \
mv bin/manager_${TARGETOS}_${TARGETARCH} bin/manager


FROM alpine:3.15
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ CRD_OPTIONS ?= "crd"
# default k8s version for e2e tests
K8S_VERSION ?= 1.23.0

TARGETOS=linux
ifeq (,${TARGETARCH})
TARGETARCH=$(shell go env GOARCH)
endif

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
Expand All @@ -33,7 +38,7 @@ e2e-test: kind

# Build manager binary
manager: generate fmt vet
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -ldflags '-w -X=main.Version=$(BIN_VERSION)' -o bin/manager main.go
CGO_ENABLED=0 GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) go build -a -ldflags '-w -X=main.Version=$(BIN_VERSION)' -o bin/manager_$(TARGETOS)_$(TARGETARCH) main.go

# Run against the configured Kubernetes cluster in ~/.kube/config
run: generate fmt vet manifests
Expand Down

0 comments on commit cc13944

Please sign in to comment.