Skip to content

Commit 435f88f

Browse files
wcrumTylerGillson
andcommitted
chore: add arch configuration for docker-build make target (#117)
* Update Makefile * fix: specify targetarch for all stages in Dockerfile; use GOARCH Signed-off-by: Tyler Gillson <tyler.gillson@gmail.com> --------- Signed-off-by: Tyler Gillson <tyler.gillson@gmail.com> Co-authored-by: Tyler Gillson <tyler.gillson@gmail.com>
1 parent 3347381 commit 435f88f

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
FROM golang:1.21 AS builder
2+
FROM --platform=$TARGETPLATFORM golang:1.21 AS builder
33
ARG TARGETOS
44
ARG TARGETARCH
55

@@ -25,7 +25,7 @@ RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o ma
2525

2626
# Use distroless as minimal base image to package the manager binary
2727
# Refer to https://github.com/GoogleContainerTools/distroless for more details
28-
FROM gcr.io/distroless/static:nonroot AS production
28+
FROM --platform=$TARGETPLATFORM gcr.io/distroless/static:nonroot AS production
2929
WORKDIR /
3030
COPY --from=builder /workspace/manager .
3131
USER 65532:65532

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# Image URL to use all building/pushing image targets
33
IMG ?= quay.io/spectrocloud-labs/validator-plugin-aws:latest
44

5+
GOARCH ?= $(shell go env GOARCH)
6+
57
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
68
ifeq (,$(shell go env GOBIN))
79
GOBIN=$(shell go env GOPATH)/bin
@@ -77,7 +79,7 @@ run: manifests generate fmt vet ## Run a controller from your host.
7779
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
7880
.PHONY: docker-build
7981
docker-build: test ## Build docker image with the manager.
80-
$(CONTAINER_TOOL) build -t ${IMG} .
82+
$(CONTAINER_TOOL) build -t ${IMG} . --platform linux/$(GOARCH)
8183

8284
.PHONY: docker-push
8385
docker-push: ## Push docker image with the manager.

0 commit comments

Comments
 (0)