mirror of https://github.com/k3s-io/k3s
Merge pull request #1658 from proppy/slim-kube-build
build: switch to golang:1.3 and build go for KUBE_CROSSPLATFORMSpull/6/head
commit
0ce5e99ee5
|
@ -14,12 +14,9 @@
|
|||
|
||||
# This file creates a standard build environment for building Kubernetes
|
||||
|
||||
FROM golang:cross
|
||||
FROM kube-build:cross
|
||||
MAINTAINER Joe Beda <jbeda@google.com>
|
||||
|
||||
ENV KUBE_CROSSPLATFORMS \
|
||||
linux/386 linux/arm \
|
||||
darwin/amd64 darwin/386
|
||||
# (set an explicit GOARM of 5 for maximum compatibility)
|
||||
ENV GOARM 5
|
||||
ENV GOOS linux
|
||||
|
|
|
@ -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 <jbeda@google.com>
|
||||
|
||||
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
|
|
@ -46,6 +46,9 @@ readonly KUBE_BUILD_IMAGE_REPO=kube-build
|
|||
# KUBE_BUILD_IMAGE_TAG=<hash>
|
||||
# KUBE_BUILD_IMAGE="${KUBE_BUILD_IMAGE_REPO}:${KUBE_BUILD_IMAGE_TAG}"
|
||||
# KUBE_BUILD_CONTAINER_NAME=kube-build-<hash>
|
||||
readonly KUBE_BUILD_IMAGE_CROSS_TAG=cross
|
||||
readonly KUBE_BUILD_IMAGE_CROSS="${KUBE_BUILD_IMAGE_REPO}:${KUBE_BUILD_IMAGE_CROSS_TAG}"
|
||||
readonly KUBE_BUILD_GOLANG_VERSION=1.3
|
||||
|
||||
readonly KUBE_GO_PACKAGE="github.com/GoogleCloudPlatform/kubernetes"
|
||||
|
||||
|
@ -220,10 +223,10 @@ 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."
|
||||
echo "You don't have a local copy of the golang docker image. This image is 450MB."
|
||||
read -p "Download it now? [y/n] " -n 1 -r
|
||||
echo
|
||||
[[ $REPLY =~ ^[yY]$ ]] || {
|
||||
|
@ -232,8 +235,8 @@ function kube::build::ensure_golang_cross() {
|
|||
}
|
||||
}
|
||||
|
||||
echo "+++ Pulling docker image: golang:cross"
|
||||
docker pull golang:cross
|
||||
echo "+++ Pulling docker image: golang:${KUBE_BUILD_GOLANG_VERSION}"
|
||||
docker pull golang:${KUBE_BUILD_GOLANG_VERSION}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -255,7 +258,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 +269,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() {
|
||||
|
|
Loading…
Reference in New Issue