Makefile 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # Copyright 2017 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. # Build the etcd-version-monitor image
  15. #
  16. # Usage:
  17. # [GOLANG_VERSION=1.8.3] [REGISTRY=staging-k8s.gcr.io] [TAG=test] make (build|push)
  18. # TODO(shyamjvs): Support architectures other than amd64 if needed.
  19. ARCH:=amd64
  20. GOLANG_VERSION?=1.8.3
  21. REGISTRY?=staging-k8s.gcr.io
  22. TAG?=0.1.3
  23. IMAGE:=$(REGISTRY)/etcd-version-monitor:$(TAG)
  24. CURRENT_DIR:=$(pwd)
  25. TEMP_DIR:=$(shell mktemp -d)
  26. build:
  27. # Copy the necessary files for building the image to TEMP_DIR.
  28. cp etcd-version-monitor.go Dockerfile $(TEMP_DIR)
  29. # Compile etcd-version-monitor.
  30. docker run -it \
  31. -v $(shell pwd)/../../../:/go/src/k8s.io/kubernetes \
  32. -v $(TEMP_DIR):/build \
  33. -e GOARCH=$(ARCH) \
  34. golang:$(GOLANG_VERSION) \
  35. /bin/bash -c "CGO_ENABLED=0 go build -o /build/etcd-version-monitor k8s.io/kubernetes/cluster/images/etcd-version-monitor"
  36. docker build -t $(IMAGE) $(TEMP_DIR)
  37. push: build
  38. docker push $(IMAGE)
  39. all: build
  40. .PHONY: build push