github.com/jonaz/heapster@v1.3.0-beta.0.0.20170208112634-cd3c15ca3d29/Makefile (about) 1 all: build 2 3 PREFIX?=gcr.io/google_containers 4 FLAGS= 5 ARCH?=amd64 6 ALL_ARCHITECTURES=amd64 arm arm64 ppc64le s390x 7 ML_PLATFORMS=linux/amd64,linux/arm,linux/arm64,linux/ppc64le,linux/s390x 8 GOLANG_VERSION?=1.7 9 TEMP_DIR:=$(shell mktemp -d /tmp/heapster.XXXXXX) 10 11 VERSION?=v1.3.0-beta.1 12 GIT_COMMIT:=$(shell git rev-parse --short HEAD) 13 REPO_DIR?=$(shell pwd) 14 15 # You can set this variable for testing and the built image will also be tagged with this name 16 OVERRIDE_IMAGE_NAME?= 17 18 # If this session isn't interactive, then we don't want to allocate a 19 # TTY, which would fail, but if it is interactive, we do want to attach 20 # so that the user can send e.g. ^C through. 21 INTERACTIVE := $(shell [ -t 0 ] && echo 1 || echo 0) 22 TTY= 23 ifeq ($(INTERACTIVE), 1) 24 TTY=-t 25 endif 26 27 SUPPORTED_KUBE_VERSIONS=1.4.6 28 TEST_NAMESPACE=heapster-e2e-tests 29 30 HEAPSTER_LDFLAGS=-w -X k8s.io/heapster/version.HeapsterVersion=$(VERSION) -X k8s.io/heapster/version.GitCommit=$(GIT_COMMIT) 31 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 fmt: 49 find . -type f -name "*.go" | grep -v "./vendor*" | xargs gofmt -s -w 50 51 build: clean fmt 52 GOARCH=$(ARCH) CGO_ENABLED=0 go build -ldflags "$(HEAPSTER_LDFLAGS)" -o heapster k8s.io/heapster/metrics 53 GOARCH=$(ARCH) CGO_ENABLED=0 go build -ldflags "$(HEAPSTER_LDFLAGS)" -o eventer k8s.io/heapster/events 54 55 sanitize: 56 hooks/check_boilerplate.sh 57 hooks/check_gofmt.sh 58 hooks/run_vet.sh 59 60 test-unit: clean sanitize build 61 GOARCH=$(ARCH) go test --test.short -race ./... $(FLAGS) 62 63 test-unit-cov: clean sanitize build 64 hooks/coverage.sh 65 66 test-integration: clean build 67 go test -v --timeout=60m ./integration/... --vmodule=*=2 $(FLAGS) --namespace=$(TEST_NAMESPACE) --kube_versions=$(SUPPORTED_KUBE_VERSIONS) 68 69 container: 70 # Run the build in a container in order to have reproducible builds 71 # Also, fetch the latest ca certificates 72 docker run --rm -i $(TTY) -v $(TEMP_DIR):/build -v $(REPO_DIR):/go/src/k8s.io/heapster -w /go/src/k8s.io/heapster golang:$(GOLANG_VERSION) /bin/bash -c "\ 73 cp /etc/ssl/certs/ca-certificates.crt /build \ 74 && GOARCH=$(ARCH) CGO_ENABLED=0 go build -ldflags \"$(HEAPSTER_LDFLAGS)\" -o /build/heapster k8s.io/heapster/metrics \ 75 && GOARCH=$(ARCH) CGO_ENABLED=0 go build -ldflags \"$(HEAPSTER_LDFLAGS)\" -o /build/eventer k8s.io/heapster/events" 76 77 cp deploy/docker/Dockerfile $(TEMP_DIR) 78 cd $(TEMP_DIR) && sed -i -e "s|BASEIMAGE|$(BASEIMAGE)|g" Dockerfile 79 80 docker build --pull -t $(PREFIX)/heapster-$(ARCH):$(VERSION) $(TEMP_DIR) 81 ifneq ($(OVERRIDE_IMAGE_NAME),) 82 docker tag -f $(PREFIX)/heapster-$(ARCH):$(VERSION) $(OVERRIDE_IMAGE_NAME) 83 endif 84 rm -rf $(TEMP_DIR) 85 86 push: ./manifest-tool gcr-login $(addprefix sub-push-,$(ALL_ARCHITECTURES)) 87 ./manifest-tool push from-args --platforms $(ML_PLATFORMS) --template $(PREFIX)/heapster-ARCH:$(VERSION) --target $(PREFIX)/heapster:$(VERSION) 88 89 sub-push-%: 90 $(MAKE) ARCH=$* PREFIX=$(PREFIX) VERSION=$(VERSION) container 91 docker push $(PREFIX)/heapster-$*:$(VERSION) 92 93 influxdb: 94 ARCH=$(ARCH) PREFIX=$(PREFIX) make -C influxdb build 95 96 grafana: 97 ARCH=$(ARCH) PREFIX=$(PREFIX) make -C grafana build 98 99 push-influxdb: 100 PREFIX=$(PREFIX) make -C influxdb push 101 102 push-grafana: 103 PREFIX=$(PREFIX) make -C grafana push 104 105 ./manifest-tool: 106 curl -sSL https://github.com/luxas/manifest-tool/releases/download/v0.3.0/manifest-tool > manifest-tool 107 chmod +x manifest-tool 108 109 gcr-login: 110 ifeq ($(findstring gcr.io,$(PREFIX)),gcr.io) 111 @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." 112 @echo "This script is automatically logging you in now." 113 docker login -u oauth2accesstoken -p "$(shell gcloud auth print-access-token)" https://gcr.io 114 endif 115 116 clean: 117 rm -f heapster 118 rm -f eventer 119 120 .PHONY: all build sanitize test-unit test-unit-cov test-integration container grafana influxdb clean