Skip to content

Commit 3c0a5df

Browse files
authored
Update image to multiplatform with arm64 support. (#891)
1 parent cfa7291 commit 3c0a5df

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

Dockerfile

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

44
WORKDIR /workspace
55
# Copy the Go Modules manifests
@@ -16,7 +16,9 @@ COPY apis/ apis/
1616
COPY controllers/ controllers/
1717

1818
# Build
19-
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o flink-operator main.go
19+
ARG TARGETOS
20+
ARG TARGETARCH
21+
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -a -o flink-operator main.go
2022

2123
# Use distroless as minimal base image to package the manager binary
2224
# Refer to https://github.com/GoogleContainerTools/distroless for more details

Makefile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ SHELL := /bin/bash
22
VERSION ?= latest
33
# Image URL to use all building/pushing image targets
44
IMG ?= ghcr.io/spotify/flink-operator:$(VERSION)
5+
# Image platforms to support.
6+
PLATFORMS ?= linux/amd64,linux/arm64
57
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
68
CRD_OPTIONS ?= "crd:maxDescLen=0,generateEmbeddedObjectMeta=true"
79
# The Kubernetes namespace in which the operator will be deployed.
@@ -98,11 +100,15 @@ endif
98100
run: manifests generate fmt vet tidy ## Run a controller from your host against the configured Kubernetes cluster in ~/.kube/config
99101
go run ./main.go
100102

101-
docker-build: test ## Build docker image with the manager.
102-
docker build -t ${IMG} --label git-commit=$(shell git rev-parse HEAD) .
103+
.PHONY: docker-create-builder ## Create makes a new builder instance.
104+
docker-create-builder:
105+
docker buildx create --use
103106

104-
docker-push: docker-build ## Push docker image with the manager.
105-
docker push ${IMG}
107+
docker-build: test docker-create-builder ## Build docker image with the manager.
108+
docker buildx build --platform ${PLATFORMS} -t ${IMG} --label git-commit=$(shell git rev-parse HEAD) .
109+
110+
docker-push: test docker-create-builder ## Push docker image with the manager.
111+
docker buildx build --push --platform ${PLATFORMS} -t ${IMG} --label git-commit=$(shell git rev-parse HEAD) .
106112

107113
release-manifests: build-overlay build-overlay-sharded ## Build manifests for release.
108114
$(KUSTOMIZE) build config/deploy > config/deploy/flink-operator.yaml \

0 commit comments

Comments
 (0)