Skip to content

Commit 9f98295

Browse files
Let Dockerfile to support multiarch build (#586)
1 parent 7541a16 commit 9f98295

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

Dockerfile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
FROM golang:1.19 as builder
2+
FROM --platform=$BUILDPLATFORM golang:1.19 as builder
33

44
WORKDIR /workspace
55
# Copy the Go Modules manifests
@@ -17,7 +17,13 @@ COPY internal/ internal/
1717
COPY rabbitmqclient/ rabbitmqclient/
1818

1919
# Build
20-
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -tags timetzdata -o manager main.go
20+
ARG TARGETOS
21+
ARG TARGETARCH
22+
ENV GOOS $TARGETOS
23+
ENV GOARCH $TARGETARCH
24+
25+
# Build
26+
RUN CGO_ENABLED=0 GO111MODULE=on go build -a -tags timetzdata -o manager main.go
2127

2228
# ---------------------------------------
2329
FROM alpine:latest as etc-builder

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ deploy-dev: check-env-docker-credentials cmctl docker-build-dev manifests deploy
106106

107107
# Load operator image and deploy operator into current KinD cluster
108108
deploy-kind: manifests cmctl deploy-rbac
109-
$(BUILD_KIT) build --build-arg=GIT_COMMIT=$(GIT_COMMIT) -t $(DOCKER_REGISTRY_SERVER)/$(OPERATOR_IMAGE):$(GIT_COMMIT) .
109+
$(BUILD_KIT) buildx build --build-arg=GIT_COMMIT=$(GIT_COMMIT) -t $(DOCKER_REGISTRY_SERVER)/$(OPERATOR_IMAGE):$(GIT_COMMIT) .
110110
kind load docker-image $(DOCKER_REGISTRY_SERVER)/$(OPERATOR_IMAGE):$(GIT_COMMIT)
111111
$(CMCTL) check api --wait=2m
112112
kustomize build config/default/overlays/kind | sed 's@((operator_docker_image))@"$(DOCKER_REGISTRY_SERVER)/$(OPERATOR_IMAGE):$(GIT_COMMIT)"@' | kubectl apply -f -
@@ -160,7 +160,7 @@ ifndef DOCKER_REGISTRY_SECRET
160160
endif
161161

162162
docker-build-dev: check-env-docker-repo git-commit-sha
163-
$(BUILD_KIT) build --build-arg=GIT_COMMIT=$(GIT_COMMIT) -t $(DOCKER_REGISTRY_SERVER)/$(OPERATOR_IMAGE):$(GIT_COMMIT) .
163+
$(BUILD_KIT) buildx build --build-arg=GIT_COMMIT=$(GIT_COMMIT) -t $(DOCKER_REGISTRY_SERVER)/$(OPERATOR_IMAGE):$(GIT_COMMIT) .
164164
$(BUILD_KIT) push $(DOCKER_REGISTRY_SERVER)/$(OPERATOR_IMAGE):$(GIT_COMMIT)
165165

166166
docker-registry-secret: check-env-docker-credentials operator-namespace

0 commit comments

Comments
 (0)