Merge pull request #23697 from luxas/pause_multi_arch

Automatic merge from submit-queue

Update the pause image to build for arm64 and ppc64le

Fixes #22683
This commit is contained in:
k8s-merge-robot 2016-04-14 02:32:28 -07:00
commit e363a26638
2 changed files with 32 additions and 37 deletions

View File

@ -14,18 +14,40 @@
.PHONY: build push
TAG = 2.0
TAG=2.0
REGISTRY?="gcr.io/google_containers"
ARCH = amd64
IMAGE = pause
# ARCH = arm
# IMAGE = pause-arm
# Architectures supported: amd64, arm, arm64 and ppc64le
ARCH?=amd64
GOLANG_VERSION=1.6
TEMP_DIR:=$(shell mktemp -d)
all: push-legacy-too
build:
./prepare.sh ${ARCH}
docker build -t gcr.io/google_containers/$(IMAGE):$(TAG) .
cp pause.go Dockerfile $(TEMP_DIR)
push: build
gcloud docker --server=gcr.io push gcr.io/google_containers/$(IMAGE):$(TAG)
docker run -it -v $(TEMP_DIR):/build golang:$(GOLANG_VERSION) /bin/bash -c \
"cd /build && CGO_ENABLED=0 GOARM=6 GOARCH=$(ARCH) go build -a -installsuffix cgo -ldflags '-w' ./pause.go"
all: push
ifeq ($(ARCH),$(filter $(ARCH),amd64 arm))
# Run goupx for amd64 and arm. The condition above is equal to 'if [[ $ARCH == "amd64" || $ARCH == "arm" ]]' in bash
docker run -it -v $(TEMP_DIR):/build golang:$(GOLANG_VERSION) /bin/bash -c \
"cd /build && apt-get update && apt-get install -y upx \
&& go get github.com/pwaller/goupx && goupx pause"
endif
# And build the image
docker build -t $(REGISTRY)/pause-$(ARCH):$(TAG) $(TEMP_DIR)
ifeq ($(ARCH),amd64)
docker tag -f $(REGISTRY)/pause-$(ARCH):$(TAG) $(REGISTRY)/pause:$(TAG)
endif
push: build
gcloud docker --server=gcr.io push $(REGISTRY)/pause-$(ARCH):$(TAG)
push-legacy-too: push
ifeq ($(ARCH),amd64)
gcloud docker push $(REGISTRY)/pause:$(TAG)
endif

View File

@ -1,27 +0,0 @@
#!/bin/bash
# Copyright 2014 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.
set -e
set -x
ARCH=$1
# Build the binary.
CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} godep go build -a -installsuffix cgo -ldflags '-w' ./pause.go
# Run goupx to shrink binary size.
go get github.com/pwaller/goupx
goupx pause