2016-06-03 00:25:58 +00:00
# Copyright 2016 The Kubernetes Authors.
2016-02-03 06:30:10 +00:00
#
# 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.
2016-01-05 08:52:12 +00:00
# Build the etcd image
#
# Usage:
2016-09-09 17:25:15 +00:00
# [TAG=3.0.4] [REGISTRY=gcr.io/google_containers] [ARCH=amd64] [BASEIMAGE=busybox] make (build|push)
2015-04-02 23:20:09 +00:00
2016-08-09 20:35:03 +00:00
TAG ?= 3.0.4
2016-09-27 13:26:13 +00:00
REGISTRY_TAG ?= $( TAG)
2016-01-05 08:52:12 +00:00
ARCH ?= amd64
REGISTRY ?= gcr.io/google_containers
2016-07-19 22:10:49 +00:00
GOLANG_VERSION ?= 1.6.3
2016-04-14 04:29:10 +00:00
GOARM = 6
2016-01-05 08:52:12 +00:00
TEMP_DIR := $( shell mktemp -d)
2015-04-02 23:20:09 +00:00
2016-01-05 08:52:12 +00:00
i f e q ( $( ARCH ) , a m d 6 4 )
BASEIMAGE?= busybox
e n d i f
i f e q ( $( ARCH ) , a r m )
2016-04-14 04:29:10 +00:00
BASEIMAGE?= armel/busybox
e n d i f
i f e q ( $( ARCH ) , a r m 6 4 )
BASEIMAGE?= aarch64/busybox
e n d i f
i f e q ( $( ARCH ) , p p c 6 4 l e )
BASEIMAGE?= ppc64le/busybox
2016-01-05 08:52:12 +00:00
e n d i f
2015-04-02 23:20:09 +00:00
2016-01-05 08:52:12 +00:00
build :
2016-08-23 10:02:41 +00:00
# Copy the content in this dir to the temp dir,
# without copying the subdirectories.
find ./ -maxdepth 1 -type f | xargs cp -t $( TEMP_DIR)
2016-09-09 17:25:15 +00:00
# Compile attachlease
docker run -it -v $( shell pwd ) /../../../:/go/src/k8s.io/kubernetes -v $( TEMP_DIR) :/build -e GOARCH = $( ARCH) golang:$( GOLANG_VERSION) \
/bin/bash -c "CGO_ENABLED=0 go build -o /build/attachlease k8s.io/kubernetes/cluster/images/etcd/attachlease"
2016-04-14 04:29:10 +00:00
i f e q ( $( ARCH ) , a m d 6 4 )
# Do not compile if we should make an image for amd64, use the official etcd binaries instead
curl -sSL --retry 5 https://github.com/coreos/etcd/releases/download/v$( TAG) /etcd-v$( TAG) -linux-amd64.tar.gz | tar -xz -C $( TEMP_DIR) --strip-components= 1
e l s e
# Download etcd in a golang container and cross-compile it statically
docker run -it -v $( TEMP_DIR) :/etcdbin golang:$( GOLANG_VERSION) /bin/bash -c \
2016-07-19 22:10:49 +00:00
" git clone https://github.com/coreos/etcd /go/src/github.com/coreos/etcd \
&& cd /go/src/github.com/coreos/etcd \
&& git checkout v$( TAG) \
2016-04-14 04:29:10 +00:00
&& GOARM = $( GOARM) GOARCH = $( ARCH) ./build \
2016-09-09 17:25:15 +00:00
&& cp -f bin/$( ARCH) /etcd* bin/etcd* /etcdbin; echo 'done' "
2016-07-19 22:10:49 +00:00
# Add this ENV variable in order to workaround an unsupported arch blocker
# The multiarch feature is in an limited and experimental state right now, and etcd should work fine on arm64
# On arm (which is 32-bit), it can't handle >1GB data in-memory, but it is very unlikely someone tinkering with their limited arm devices would reach such a high usage
# ppc64le is still quite untested, but compiles and is probably in the process of being validated by IBM.
cd $( TEMP_DIR) && echo " ENV ETCD_UNSUPPORTED_ARCH= $( ARCH) " >> Dockerfile
2016-04-14 04:29:10 +00:00
e n d i f
2016-01-05 08:52:12 +00:00
# Replace BASEIMAGE with the real base image
2016-08-04 00:25:11 +00:00
cd $( TEMP_DIR) && sed -i.bak 's|BASEIMAGE|$(BASEIMAGE)|g' Dockerfile
2016-01-05 08:52:12 +00:00
# And build the image
2016-09-27 13:26:13 +00:00
docker build -t $( REGISTRY) /etcd-$( ARCH) :$( REGISTRY_TAG) $( TEMP_DIR)
2015-04-02 23:20:09 +00:00
2015-06-08 23:34:27 +00:00
push : build
2016-09-27 13:26:13 +00:00
gcloud docker push $( REGISTRY) /etcd-$( ARCH) :$( REGISTRY_TAG)
2016-01-05 08:52:12 +00:00
i f e q ( $( ARCH ) , a m d 6 4 )
2016-04-14 04:29:10 +00:00
# Backward compatibility. TODO: deprecate this image tag
2016-09-27 13:26:13 +00:00
docker tag $( REGISTRY) /etcd-$( ARCH) :$( REGISTRY_TAG) $( REGISTRY) /etcd:$( REGISTRY_TAG)
gcloud docker push $( REGISTRY) /etcd:$( REGISTRY_TAG)
2016-01-05 08:52:12 +00:00
e n d i f
2015-04-02 23:20:09 +00:00
2016-01-05 08:52:12 +00:00
all : build
2016-08-09 20:35:03 +00:00
.PHONY : build push