Skip to content

Commit 7dffd70

Browse files
scotwellsclaude
andcommitted
build: publish multi-arch (amd64 + arm64) container images
Adds linux/arm64 to the published image so Apple Silicon developers can run the operator locally without QEMU. - Dockerfile: pin builder to BUILDPLATFORM and cross-compile to TARGETARCH so arm64 builds run natively on amd64 runners (and vice versa) instead of under emulation. - Dockerfile: stamp version metadata into the binary via -ldflags using the VERSION/GIT_COMMIT/GIT_TREE_STATE/BUILD_DATE build args the shared publish workflow already provides. - cmd/main.go: log the stamped build metadata on startup. - publish.yaml: bump the shared publish-docker workflow to v1.13.1 and request linux/amd64,linux/arm64. Verified locally with docker buildx: cold multi-arch build is ~47s, warm rebuild is ~7s, both architectures cross-compile natively. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0a6eb1b commit 7dffd70

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

.github/workflows/publish.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ jobs:
1111
id-token: write
1212
contents: read
1313
packages: write
14-
uses: datum-cloud/actions/.github/workflows/publish-docker.yaml@v1.5.1
14+
uses: datum-cloud/actions/.github/workflows/publish-docker.yaml@v1.13.1
1515
with:
1616
image-name: workload-operator
17+
platforms: linux/amd64,linux/arm64
1718
secrets: inherit
1819

1920
publish-kustomize-bundles:

Dockerfile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# Build the manager binary
2-
FROM golang:1.24 AS builder
2+
FROM --platform=$BUILDPLATFORM golang:1.24 AS builder
33
ARG TARGETOS
44
ARG TARGETARCH
5+
ARG VERSION=dev
6+
ARG GIT_COMMIT=unknown
7+
ARG GIT_TREE_STATE=unknown
8+
ARG BUILD_DATE=unknown
59

610
WORKDIR /workspace
711
# Copy the Go Modules manifests
@@ -26,7 +30,13 @@ ENV GOCACHE=/root/.cache/go-build
2630
ENV GOTMPDIR=/root/.cache/go-build
2731
RUN --mount=type=cache,target=/go/pkg/mod/ \
2832
--mount=type=cache,target="/root/.cache/go-build" \
29-
CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go
33+
CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build \
34+
-ldflags "-s -w \
35+
-X main.version=${VERSION} \
36+
-X main.gitCommit=${GIT_COMMIT} \
37+
-X main.gitTreeState=${GIT_TREE_STATE} \
38+
-X main.buildDate=${BUILD_DATE}" \
39+
-o manager cmd/main.go
3040

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

cmd/main.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ var (
4444
scheme = runtime.NewScheme()
4545
setupLog = ctrl.Log.WithName("setup")
4646
codecs = serializer.NewCodecFactory(scheme, serializer.EnableStrict)
47+
48+
// Build metadata, set via -ldflags at build time. See Dockerfile.
49+
version = "dev"
50+
gitCommit = "unknown"
51+
gitTreeState = "unknown"
52+
buildDate = "unknown"
4753
)
4854

4955
func init() {
@@ -81,6 +87,13 @@ func main() {
8187

8288
ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))
8389

90+
setupLog.Info("starting workload-operator",
91+
"version", version,
92+
"gitCommit", gitCommit,
93+
"gitTreeState", gitTreeState,
94+
"buildDate", buildDate,
95+
)
96+
8497
var serverConfig config.WorkloadOperator
8598
var configData []byte
8699
if len(serverConfigFile) > 0 {

0 commit comments

Comments
 (0)