github.com/qsunny/k8s@v0.0.0-20220101153623-e6dca256d5bf/examples-master/guestbook/redis-slave/Makefile (about) 1 # Copyright 2017 The Kubernetes Authors. All rights reserved. 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 TAG = v3 16 REGISTRY = gcr.io/google-samples 17 ARCH ?= $(shell go env GOARCH) 18 ALL_ARCH = amd64 arm arm64 ppc64le s390x 19 20 IMAGE = $(REGISTRY)/gb-redisslave 21 MULTI_ARCH_IMG = $(IMAGE)-$(ARCH) 22 23 # Set default base image dynamically for each arch 24 ifeq ($(ARCH),arm) 25 QEMUARCH=arm 26 BASEIMAGE=arm32v6/redis:3.2.9-alpine 27 endif 28 ifeq ($(ARCH),arm64) 29 QEMUARCH=aarch64 30 BASEIMAGE=arm64v8/redis:3.2.9 31 endif 32 ifeq ($(ARCH),ppc64le) 33 QEMUARCH=ppc64le 34 BASEIMAGE=ppc64le/redis:3.2.9 35 endif 36 ifeq ($(ARCH),s390x) 37 QEMUARCH=s390x 38 BASEIMAGE=s390x/redis:3.2.9 39 endif 40 41 TEMP_DIR := $(shell mktemp -d) 42 43 all: all-container 44 45 sub-container-%: 46 $(MAKE) ARCH=$* container 47 48 sub-push-%: 49 $(MAKE) ARCH=$* push 50 51 all-container: $(addprefix sub-container-,$(ALL_ARCH)) 52 53 all-push: $(addprefix sub-push-,$(ALL_ARCH)) 54 docker manifest create --amend $(IMAGE):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(IMAGE)\-&:$(TAG)~g") 55 @for arch in $(ALL_ARCH); do docker manifest annotate --arch $${arch} ${IMAGE}:${TAG} ${IMAGE}-$${arch}:${TAG}; done 56 docker manifest push --purge ${IMAGE}:${TAG} 57 58 container: .container-$(ARCH) 59 .container-$(ARCH): 60 cp ./* $(TEMP_DIR) 61 62 ifneq ($(ARCH), amd64) 63 cd $(TEMP_DIR) && sed -i "s|FROM redis.*|FROM $(BASEIMAGE)|g" Dockerfile 64 endif 65 66 docker build -t $(MULTI_ARCH_IMG):$(TAG) $(TEMP_DIR) 67 68 ifeq ($(ARCH), amd64) 69 # This is for to maintain the backward compatibility 70 docker tag $(MULTI_ARCH_IMG):$(TAG) $(IMAGE):$(TAG) 71 endif 72 73 push: .push-$(ARCH) 74 .push-$(ARCH): .container-$(ARCH) 75 docker push $(MULTI_ARCH_IMG):$(TAG) 76 77 clean: $(addprefix sub-clean-,$(ALL_ARCH)) 78 docker rmi -f $(IMAGE):$(TAG) || true 79 sub-clean-%: 80 docker rmi -f $(IMAGE)-$*:$(TAG) || true