diff --git a/build/build-image/Dockerfile b/build/build-image/Dockerfile index 4ff8066b98c..3d9e58cfa24 100644 --- a/build/build-image/Dockerfile +++ b/build/build-image/Dockerfile @@ -14,15 +14,9 @@ # This file creates a standard build environment for building Kubernetes -FROM golang:1.3 +FROM kube-build:cross MAINTAINER Joe Beda -ENV KUBE_CROSSPLATFORMS \ - linux/386 linux/arm \ - darwin/amd64 darwin/386 - -RUN cd /usr/src/go/src && for platform in ${KUBE_CROSSPLATFORMS}; do GOOS=${platform%/*} GOARCH=${platform##*/} ./make.bash --no-clean; done - # (set an explicit GOARM of 5 for maximum compatibility) ENV GOARM 5 ENV GOOS linux diff --git a/build/build-image/cross/Dockerfile b/build/build-image/cross/Dockerfile new file mode 100644 index 00000000000..926da0148a4 --- /dev/null +++ b/build/build-image/cross/Dockerfile @@ -0,0 +1,25 @@ +# Copyright 2014 Google Inc. 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. + +# This file creates a standard build environment for building cross +# platform go binary for the architecture kubernetes cares about. + +FROM golang:1.3 +MAINTAINER Joe Beda + +ENV KUBE_CROSSPLATFORMS \ + linux/386 linux/arm \ + darwin/amd64 darwin/386 + +RUN cd /usr/src/go/src && for platform in ${KUBE_CROSSPLATFORMS}; do GOOS=${platform%/*} GOARCH=${platform##*/} ./make.bash --no-clean; done diff --git a/build/common.sh b/build/common.sh index 15a9189f8b6..7a368f09a66 100644 --- a/build/common.sh +++ b/build/common.sh @@ -46,6 +46,8 @@ readonly KUBE_BUILD_IMAGE_REPO=kube-build # KUBE_BUILD_IMAGE_TAG= # KUBE_BUILD_IMAGE="${KUBE_BUILD_IMAGE_REPO}:${KUBE_BUILD_IMAGE_TAG}" # KUBE_BUILD_CONTAINER_NAME=kube-build- +readonly KUBE_BUILD_IMAGE_CROSS_TAG=cross +readonly KUBE_BUILD_IMAGE_CROSS="${KUBE_BUILD_IMAGE_REPO}:${KUBE_BUILD_IMAGE_CROSS_TAG}" readonly KUBE_GO_PACKAGE="github.com/GoogleCloudPlatform/kubernetes" @@ -220,8 +222,8 @@ function kube::build::build_image_built() { kube::build::docker_image_exists "${KUBE_BUILD_IMAGE_REPO}" "${KUBE_BUILD_IMAGE_TAG}" } -function kube::build::ensure_golang_cross() { - kube::build::docker_image_exists golang cross || { +function kube::build::ensure_golang() { + kube::build::docker_image_exists golang 1.3 || { [[ ${KUBE_SKIP_CONFIRMATIONS} =~ ^[yY]$ ]] || { echo "You don't have a local copy of the golang:cross docker image. This image is 1.8GB." read -p "Download it now? [y/n] " -n 1 -r @@ -232,8 +234,8 @@ function kube::build::ensure_golang_cross() { } } - echo "+++ Pulling docker image: golang:cross" - docker pull golang:cross + echo "+++ Pulling docker image: golang:1.3" + docker pull golang:1.3 } } @@ -255,7 +257,7 @@ function kube::build::build_image() { third_party ) - kube::build::ensure_golang_cross + kube::build::build_image_cross mkdir -p "${build_context_dir}" tar czf "${build_context_dir}/kube-source.tar.gz" "${source[@]}" @@ -266,6 +268,16 @@ EOF kube::build::docker_build "${KUBE_BUILD_IMAGE}" "${build_context_dir}" } +# Build the kubernetes golang cross base image. +function kube::build::build_image_cross() { + kube::build::ensure_golang + + local -r build_context_dir="${LOCAL_OUTPUT_ROOT}/images/${KUBE_BUILD_IMAGE}/cross" + mkdir -p "${build_context_dir}" + cp build/build-image/cross/Dockerfile ${build_context_dir}/Dockerfile + kube::build::docker_build "${KUBE_BUILD_IMAGE_CROSS}" "${build_context_dir}" +} + # Builds the runtime image. Assumes that the appropriate binaries are already # built and in _output/build/. function kube::build::run_image() {