Merge pull request #1007 from mkumatag/echoserver_multiarch
Multi arch echoserver image
This commit is contained in:
commit
3495bfb4ac
2 changed files with 62 additions and 9 deletions
|
@ -12,7 +12,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FROM gcr.io/google_containers/nginx-slim:0.21
|
||||
FROM BASEIMAGE
|
||||
|
||||
ADD nginx.conf /etc/nginx/nginx.conf
|
||||
ADD template.lua /usr/local/share/lua/5.1/
|
||||
|
|
|
@ -1,11 +1,64 @@
|
|||
all: push
|
||||
# Copyright 2017 The Kubernetes Authors. All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
# TAG 0.0 shouldn't clobber any release builds
|
||||
TAG = 1.7
|
||||
PREFIX = gcr.io/google_containers/echoserver
|
||||
TAG = 1.8
|
||||
REGISTRY = gcr.io/google_containers
|
||||
ARCH ?= $(shell go env GOARCH)
|
||||
ALL_ARCH = amd64 arm ppc64le
|
||||
|
||||
container:
|
||||
docker build -t $(PREFIX):$(TAG) .
|
||||
QEMUVERSION=v2.7.0
|
||||
|
||||
push: container
|
||||
gcloud docker -- push $(PREFIX):$(TAG)
|
||||
IMGNAME = echoserver
|
||||
IMAGE = $(REGISTRY)/$(IMGNAME)
|
||||
MULTI_ARCH_IMG = $(IMAGE)-$(ARCH)
|
||||
|
||||
# Set default base image dynamically for each arch
|
||||
BASEIMAGE?=gcr.io/google_containers/nginx-slim-$(ARCH):0.21
|
||||
|
||||
TEMP_DIR := $(shell mktemp -d)
|
||||
|
||||
all: all-container
|
||||
|
||||
sub-container-%:
|
||||
$(MAKE) ARCH=$* container
|
||||
|
||||
sub-push-%:
|
||||
$(MAKE) ARCH=$* push
|
||||
|
||||
all-container: $(addprefix sub-container-,$(ALL_ARCH))
|
||||
|
||||
all-push: $(addprefix sub-push-,$(ALL_ARCH))
|
||||
|
||||
container: .container-$(ARCH)
|
||||
.container-$(ARCH):
|
||||
cp ./* $(TEMP_DIR)
|
||||
cd $(TEMP_DIR) && sed -i 's|BASEIMAGE|$(BASEIMAGE)|g' Dockerfile
|
||||
|
||||
docker build -t $(MULTI_ARCH_IMG):$(TAG) $(TEMP_DIR)
|
||||
|
||||
ifeq ($(ARCH), amd64)
|
||||
# This is for to maintain the backward compatibility
|
||||
docker tag $(MULTI_ARCH_IMG):$(TAG) $(IMAGE):$(TAG)
|
||||
endif
|
||||
|
||||
push: .push-$(ARCH)
|
||||
.push-$(ARCH): .container-$(ARCH)
|
||||
gcloud docker -- push $(MULTI_ARCH_IMG):$(TAG)
|
||||
ifeq ($(ARCH), amd64)
|
||||
gcloud docker -- push $(IMAGE):$(TAG)
|
||||
endif
|
||||
|
||||
clean: $(addprefix sub-clean-,$(ALL_ARCH))
|
||||
sub-clean-%:
|
||||
docker rmi -f $(IMAGE)-$*:$(TAG) || true
|
||||
|
|
Loading…
Reference in a new issue