github.com/galamsiva2020/kubernetes-heapster-monitoring@v0.0.0-20210823134957-3c1baa7c1e70/influxdb/Makefile (about) 1 # Copyright 2016 The Kubernetes Authors. 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 15 # Build the influxdb image for amd64, arm, arm64, ppc64le and s390x 16 # 17 # Usage: 18 # [PREFIX=staging-k8s.gcr.io] [ARCH=amd64] make (build|push) 19 20 all: build 21 22 VERSION?=v1.5.2 23 PREFIX?=staging-k8s.gcr.io 24 ARCH?=amd64 25 GOLANG_VERSION=1.10 26 TEMP_DIR:=$(shell mktemp -d) 27 28 ALL_ARCHITECTURES=amd64 arm arm64 ppc64le s390x 29 ML_PLATFORMS=linux/amd64,linux/arm,linux/arm64,linux/ppc64le,linux/s390x 30 31 # Set default base image dynamically for each arch 32 ifeq ($(ARCH),amd64) 33 BASEIMAGE?=busybox 34 endif 35 ifeq ($(ARCH),arm) 36 BASEIMAGE?=armhf/busybox 37 endif 38 ifeq ($(ARCH),arm64) 39 BASEIMAGE?=aarch64/busybox 40 endif 41 ifeq ($(ARCH),ppc64le) 42 BASEIMAGE?=ppc64le/busybox 43 endif 44 ifeq ($(ARCH),s390x) 45 BASEIMAGE?=s390x/busybox 46 endif 47 48 build: 49 # Copy the whole directory to a temporary dir and set the base image 50 cp -r ./* $(TEMP_DIR) 51 52 cd $(TEMP_DIR) && sed -i "s|BASEIMAGE|$(BASEIMAGE)|g" Dockerfile 53 54 # Compile the binary inside a container for reliable builds 55 docker run --rm -it -v $(TEMP_DIR):/build -w /go/src/github.com/influxdb/influxdb golang:$(GOLANG_VERSION) /bin/bash -c "\ 56 curl -sSL https://github.com/influxdata/influxdb/archive/$(VERSION).tar.gz | tar -xz --strip-components=1 \ 57 && go get github.com/sparrc/gdm \ 58 && gdm restore \ 59 && ln -s /go/src/github.com/influxdb/influxdb /go/src/github.com/influxdata/ \ 60 && GOARCH=$(ARCH) CGO_ENABLED=0 go build -a --installsuffix cgo --ldflags=\"-s\" -o /build/influxd ./cmd/influxd" 61 62 docker build --pull -t $(PREFIX)/heapster-influxdb-$(ARCH):$(VERSION) $(TEMP_DIR) 63 64 rm -rf $(TEMP_DIR) 65 66 # Should depend on target: ./manifest-tool 67 push: gcr-login $(addprefix sub-push-,$(ALL_ARCHITECTURES)) 68 # ./manifest-tool push from-args --platforms $(ML_PLATFORMS) --template $(PREFIX)/heapster-influxdb-ARCH:$(VERSION) --target $(PREFIX)/heapster-influxdb:$(VERSION) 69 70 sub-push-%: 71 $(MAKE) ARCH=$* PREFIX=$(PREFIX) VERSION=$(VERSION) build 72 docker push $(PREFIX)/heapster-influxdb-$*:$(VERSION) 73 74 gcr-login: 75 ifeq ($(findstring gcr.io,$(PREFIX)),gcr.io) 76 @echo "If you are pushing to a gcr.io registry, you have to be logged in via 'docker login'; 'gcloud docker push' can't push manifest lists yet." 77 @echo "This script is automatically logging you in now." 78 gcloud docker -a 79 endif 80 81 # TODO(luxas): As soon as it's working to push fat manifests to gcr.io, reenable this code 82 #./manifest-tool: 83 # curl -sSL https://github.com/luxas/manifest-tool/releases/download/v0.3.0/manifest-tool > manifest-tool 84 # chmod +x manifest-tool