github.com/GoogleContainerTools/skaffold/v2@v2.13.2/codelab/02_kpt-deploy/resources/sample-app/php-redis/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 = v6
    16  REGISTRY = gcr.io/yuwenma-gke-playground
    17  ARCH ?= $(shell go env GOARCH)
    18  ALL_ARCH = amd64 arm arm64 ppc64le
    19  
    20  QEMUVERSION=v2.7.0
    21  
    22  IMAGE = $(REGISTRY)/gb-frontend
    23  MULTI_ARCH_IMG = $(IMAGE)-$(ARCH)
    24  
    25  # Set default base image dynamically for each arch
    26  ifeq ($(ARCH),arm)
    27  	QEMUARCH=arm
    28  	BASEIMAGE=armhf/php:5.6-apache
    29  endif
    30  ifeq ($(ARCH),arm64)
    31  	QEMUARCH=aarch64
    32  	BASEIMAGE=arm64v8/php:5-apache
    33  endif
    34  ifeq ($(ARCH),ppc64le)
    35  	QEMUARCH=ppc64le
    36  	BASEIMAGE=ppc64le/php:5-apache
    37  endif
    38  
    39  TEMP_DIR := $(shell mktemp -d)
    40  
    41  all: all-container
    42  
    43  sub-container-%:
    44  	$(MAKE) ARCH=$* container
    45  
    46  sub-push-%:
    47  	$(MAKE) ARCH=$* push
    48  
    49  all-container: $(addprefix sub-container-,$(ALL_ARCH))
    50  
    51  all-push: $(addprefix sub-push-,$(ALL_ARCH))
    52  	docker manifest create --amend $(IMAGE):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(IMAGE)\-&:$(TAG)~g")
    53  	@for arch in $(ALL_ARCH); do docker manifest annotate --arch $${arch} ${IMAGE}:${TAG} ${IMAGE}-$${arch}:${TAG}; done
    54  	docker manifest push --purge ${IMAGE}:${TAG}
    55  
    56  container: .container-$(ARCH)
    57  .container-$(ARCH):
    58  	cp ./* $(TEMP_DIR)
    59  
    60  ifneq ($(ARCH),amd64)
    61  	cd $(TEMP_DIR) && sed -i "s|FROM php.*|FROM $(BASEIMAGE)\nCOPY qemu-$(QEMUARCH)-static /usr/bin\n|g" Dockerfile
    62  	# Register /usr/bin/qemu-ARCH-static as the handler for ARM binaries in the kernel
    63  	docker run --rm --privileged multiarch/qemu-user-static:register --reset
    64  	curl -sSL https://github.com/multiarch/qemu-user-static/releases/download/$(QEMUVERSION)/x86_64_qemu-$(QEMUARCH)-static.tar.gz | tar -xz -C $(TEMP_DIR)
    65  endif
    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