ceph-csi/vendor/k8s.io/kubernetes/build/debian-hyperkube-base/Makefile

86 lines
2.6 KiB
Makefile
Raw Normal View History

2018-01-09 18:57:14 +00:00
# Copyright 2017 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Build the hyperkube base image. This image is used to build the hyperkube image.
#
# Usage:
2018-03-06 22:33:18 +00:00
# [ARCH=amd64] [REGISTRY="staging-k8s.gcr.io"] make (build|push)
2018-01-09 18:57:14 +00:00
2018-03-06 22:33:18 +00:00
REGISTRY?=staging-k8s.gcr.io
2018-11-26 18:23:56 +00:00
IMAGE?=$(REGISTRY)/debian-hyperkube-base
TAG=0.12.0
2018-01-09 18:57:14 +00:00
ARCH?=amd64
2018-11-26 18:23:56 +00:00
ALL_ARCH = amd64 arm arm64 ppc64le s390x
2018-01-09 18:57:14 +00:00
CACHEBUST?=1
2018-11-26 18:23:56 +00:00
BASEIMAGE=k8s.gcr.io/debian-base-$(ARCH):0.4.0
2018-01-09 18:57:14 +00:00
CNI_VERSION=v0.6.0
TEMP_DIR:=$(shell mktemp -d)
CNI_TARBALL=cni-plugins-$(ARCH)-$(CNI_VERSION).tgz
2018-11-26 18:23:56 +00:00
# This option is for running docker manifest command
export DOCKER_CLI_EXPERIMENTAL := enabled
2018-01-09 18:57:14 +00:00
2018-11-26 18:23:56 +00:00
SUDO=$(if $(filter 0,$(shell id -u)),,sudo)
.PHONY: all build push clean all-build all-push-images all-push push-manifest
all: all-push
sub-build-%:
$(MAKE) ARCH=$* build
all-build: $(addprefix sub-build-,$(ALL_ARCH))
sub-push-image-%:
$(MAKE) ARCH=$* push
all-push-images: $(addprefix sub-push-image-,$(ALL_ARCH))
all-push: all-push-images push-manifest
push-manifest:
docker manifest create --amend $(IMAGE):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(IMAGE)\-&:$(TAG)~g")
@for arch in $(ALL_ARCH); do docker manifest annotate --arch $${arch} ${IMAGE}:${TAG} ${IMAGE}-$${arch}:${TAG}; done
docker manifest push --purge ${IMAGE}:${TAG}
2018-01-09 18:57:14 +00:00
cni-tars/$(CNI_TARBALL):
mkdir -p cni-tars/
cd cni-tars/ && curl -sSLO --retry 5 https://storage.googleapis.com/kubernetes-release/network-plugins/${CNI_TARBALL}
clean:
rm -rf cni-tars/
build: cni-tars/$(CNI_TARBALL)
cp Dockerfile $(TEMP_DIR)
cd $(TEMP_DIR) && sed -i "s|BASEIMAGE|$(BASEIMAGE)|g" Dockerfile
ifeq ($(CACHEBUST),1)
cd ${TEMP_DIR} && sed -i.back "s|CACHEBUST|$(shell uuidgen)|g" Dockerfile
endif
mkdir -p ${TEMP_DIR}/cni-bin/bin
tar -xz -C ${TEMP_DIR}/cni-bin/bin -f "cni-tars/${CNI_TARBALL}"
2018-11-26 18:23:56 +00:00
ifneq ($(ARCH),amd64)
2018-01-09 18:57:14 +00:00
# Register /usr/bin/qemu-ARCH-static as the handler for non-x86 binaries in the kernel
2018-11-26 18:23:56 +00:00
$(SUDO) ../../third_party/multiarch/qemu-user-static/register/register.sh --reset
endif
docker build --pull -t $(IMAGE)-$(ARCH):$(TAG) $(TEMP_DIR)
2018-01-09 18:57:14 +00:00
rm -rf $(TEMP_DIR)
push: build
2018-11-26 18:23:56 +00:00
docker push $(IMAGE)-$(ARCH):$(TAG)