Skip to content
This repository was archived by the owner on Mar 1, 2024. It is now read-only.

Commit 2964544

Browse files
Simplify multi-arch building. (prometheus-operator#3035)
Default build is linux/amd64 For any other target: OS=<os> ARCH=<arch> make
1 parent b9edcc9 commit 2964544

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
FROM quay.io/prometheus/busybox:latest
1+
ARG ARCH="amd64"
2+
ARG OS="linux"
3+
FROM quay.io/prometheus/busybox-${OS}-${ARCH}:latest
24

35
ADD operator /bin/operator
46

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
SHELL=/bin/bash -o pipefail
22

3+
OS?=linux
4+
ARCH?=amd64
5+
36
GO_PKG=github.com/coreos/prometheus-operator
47
REPO?=quay.io/coreos/prometheus-operator
58
REPO_PROMETHEUS_CONFIG_RELOADER?=quay.io/coreos/prometheus-config-reloader
@@ -39,7 +42,7 @@ K8S_GEN_DEPS:=.header
3942
K8S_GEN_DEPS+=$(TYPES_V1_TARGET)
4043
K8S_GEN_DEPS+=$(foreach bin,$(K8S_GEN_BINARIES),$(FIRST_GOPATH)/bin/$(bin))
4144

42-
GO_BUILD_RECIPE=GOOS=linux CGO_ENABLED=0 go build -mod=vendor -ldflags="-s -X $(GO_PKG)/pkg/version.Version=$(VERSION)"
45+
GO_BUILD_RECIPE=GOOS=$(OS) GOARCH=$(ARCH) CGO_ENABLED=0 go build -mod=vendor -ldflags="-s -X $(GO_PKG)/pkg/version.Version=$(VERSION)"
4346
pkgs = $(shell go list ./... | grep -v /vendor/ | grep -v /test/ | grep -v /contrib/)
4447

4548
CONTAINER_CMD:=docker run --rm \
@@ -130,7 +133,7 @@ image: .hack-operator-image .hack-prometheus-config-reloader-image
130133
# Create empty target file, for the sole purpose of recording when this target
131134
# was last executed via the last-modification timestamp on the file. See
132135
# https://www.gnu.org/software/make/manual/make.html#Empty-Targets
133-
docker build -t $(REPO):$(TAG) .
136+
docker build --build-arg ARCH=$(ARCH) --build-arg OS=$(OS) -t $(REPO):$(TAG) .
134137
touch $@
135138

136139
.hack-prometheus-config-reloader-image: cmd/prometheus-config-reloader/Dockerfile prometheus-config-reloader

cmd/prometheus-config-reloader/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
FROM quay.io/prometheus/busybox:latest
1+
ARG ARCH="amd64"
2+
ARG OS="linux"
3+
FROM quay.io/prometheus/busybox-${OS}-${ARCH}:latest
24

35
ADD prometheus-config-reloader /bin/prometheus-config-reloader
46

0 commit comments

Comments
 (0)