diff --git a/build/pause/Makefile b/build/pause/Makefile index c788dcd8c9f..77798fe2005 100644 --- a/build/pause/Makefile +++ b/build/pause/Makefile @@ -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 diff --git a/build/pause/prepare.sh b/build/pause/prepare.sh deleted file mode 100755 index 5b36e6fb926..00000000000 --- a/build/pause/prepare.sh +++ /dev/null @@ -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