mirror of
https://github.com/kubernetes-sigs/prometheus-adapter.git
synced 2026-04-05 17:27:51 +00:00
This commit causes the `all` Makefile rule to trigger `build` instead of `docker-build`. This allows people with convoluted setups that involve `go build`-ing and `docker build`-ing on different machines (like @directxman12) to not complain as much.
53 lines
1.6 KiB
Makefile
53 lines
1.6 KiB
Makefile
REGISTRY?=directxman12
|
|
IMAGE?=k8s-prometheus-adapter
|
|
TEMP_DIR:=$(shell mktemp -d)
|
|
ARCH?=amd64
|
|
ALL_ARCH=amd64 arm arm64 ppc64le s390x
|
|
ML_PLATFORMS=linux/amd64,linux/arm,linux/arm64,linux/ppc64le,linux/s390x
|
|
OUT_DIR?=./_output
|
|
|
|
VERSION?=latest
|
|
|
|
ifeq ($(ARCH),amd64)
|
|
BASEIMAGE?=busybox
|
|
endif
|
|
ifeq ($(ARCH),arm)
|
|
BASEIMAGE?=armhf/busybox
|
|
endif
|
|
ifeq ($(ARCH),arm64)
|
|
BASEIMAGE?=aarch64/busybox
|
|
endif
|
|
ifeq ($(ARCH),ppc64le)
|
|
BASEIMAGE?=ppc64le/busybox
|
|
endif
|
|
ifeq ($(ARCH),s390x)
|
|
BASEIMAGE?=s390x/busybox
|
|
endif
|
|
|
|
all: build
|
|
build: vendor
|
|
CGO_ENABLED=0 GOARCH=$(ARCH) go build -a -tags netgo -o $(OUT_DIR)/$(ARCH)/adapter github.com/directxman12/k8s-prometheus-adapter/cmd/adapter
|
|
|
|
docker-build: vendor
|
|
cp deploy/Dockerfile $(TEMP_DIR)
|
|
cd $(TEMP_DIR) && sed -i "s|BASEIMAGE|$(BASEIMAGE)|g" Dockerfile
|
|
|
|
docker run -it -v $(TEMP_DIR):/build -v $(shell pwd):/go/src/github.com/directxman12/k8s-prometheus-adapter -e GOARCH=$(ARCH) golang:1.8 /bin/bash -c "\
|
|
CGO_ENABLED=0 go build -a -tags netgo -o /build/adapter github.com/directxman12/k8s-prometheus-adapter/cmd/adapter"
|
|
|
|
docker build -t $(REGISTRY)/$(IMAGE)-$(ARCH):$(VERSION) $(TEMP_DIR)
|
|
sudo rm -r $(TEMP_DIR)
|
|
|
|
push-%:
|
|
$(MAKE) ARCH=$* docker-build
|
|
docker push $(REGISTRY)/$(IMAGE)-$*:$(VERSION)
|
|
|
|
push: ./manifest-tool $(addprefix push-,$(ALL_ARCH))
|
|
./manifest-tool push from-args --platforms $(ML_PLATFORMS) --template $(REGISTRY)/$(IMAGE)-ARCH:$(VERSION) --target $(REGISTRY)/$(IMAGE):$(VERSION)
|
|
|
|
./manifest-tool:
|
|
curl -sSL https://github.com/estesp/manifest-tool/releases/download/v0.5.0/manifest-tool-linux-amd64 > manifest-tool
|
|
chmod +x manifest-tool
|
|
|
|
vendor: glide.lock
|
|
glide install -v
|