mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
push kube-cross to gcr.io
And do as much of the build setup work in it as possible.
This commit is contained in:
parent
2778bc0c13
commit
f3b9fa62d6
@ -13,41 +13,11 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
# This file creates a standard build environment for building Kubernetes
|
# This file creates a standard build environment for building Kubernetes
|
||||||
|
FROM gcr.io/google_containers/kube-cross:KUBE_BUILD_IMAGE_CROSS_TAG
|
||||||
|
|
||||||
# We replace KUBE_BUILD_IMAGE_CROSS in build/common.sh with the actual
|
ENV http_proxy=KUBE_BUILD_HTTP_PROXY \
|
||||||
# cross-build image tag.
|
https_proxy=KUBE_BUILD_HTTPS_PROXY \
|
||||||
FROM KUBE_BUILD_IMAGE_CROSS
|
no_proxy=KUBE_BUILD_NO_PROXY
|
||||||
|
|
||||||
MAINTAINER Joe Beda <jbeda@google.com>
|
|
||||||
|
|
||||||
ENV GOOS linux
|
|
||||||
ENV GOARCH amd64
|
|
||||||
ENV http_proxy KUBE_BUILD_HTTP_PROXY
|
|
||||||
ENV https_proxy KUBE_BUILD_HTTPS_PROXY
|
|
||||||
ENV no_proxy KUBE_BUILD_NO_PROXY
|
|
||||||
|
|
||||||
|
|
||||||
# work around 64MB tmpfs size in Docker 1.6
|
|
||||||
ENV TMPDIR /tmp.k8s
|
|
||||||
|
|
||||||
# Get the code coverage tool and godep
|
|
||||||
RUN mkdir $TMPDIR && \
|
|
||||||
go get golang.org/x/tools/cmd/cover github.com/tools/godep
|
|
||||||
|
|
||||||
# We use rsync to copy some binaries around. It is faster (0.3s vs. 1.1s) on my
|
|
||||||
# machine vs. `install`
|
|
||||||
RUN rm -rf /var/lib/apt/lists/ \
|
|
||||||
&& apt-get -o Acquire::Check-Valid-Until=false update \
|
|
||||||
&& apt-get install -y rsync \
|
|
||||||
&& rm -rf /var/lib/apt/lists/
|
|
||||||
|
|
||||||
# Download and symlink etcd. We need this for our integration tests.
|
|
||||||
RUN export ETCD_VERSION=v2.2.1; \
|
|
||||||
mkdir -p /usr/local/src/etcd &&\
|
|
||||||
cd /usr/local/src/etcd &&\
|
|
||||||
curl -fsSLO https://github.com/coreos/etcd/releases/download/$ETCD_VERSION/etcd-$ETCD_VERSION-linux-amd64.tar.gz &&\
|
|
||||||
tar xzf etcd-$ETCD_VERSION-linux-amd64.tar.gz &&\
|
|
||||||
ln -s ../src/etcd/etcd-$ETCD_VERSION-linux-amd64/etcd /usr/local/bin/
|
|
||||||
|
|
||||||
# Mark this as a kube-build container
|
# Mark this as a kube-build container
|
||||||
RUN touch /kube-build-image
|
RUN touch /kube-build-image
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
# platform go binary for the architecture kubernetes cares about.
|
# platform go binary for the architecture kubernetes cares about.
|
||||||
|
|
||||||
FROM golang:1.4.2
|
FROM golang:1.4.2
|
||||||
MAINTAINER Joe Beda <jbeda@google.com>
|
|
||||||
|
|
||||||
ENV GOARM 6
|
ENV GOARM 6
|
||||||
ENV KUBE_DYNAMIC_CROSSPLATFORMS \
|
ENV KUBE_DYNAMIC_CROSSPLATFORMS \
|
||||||
@ -28,11 +27,15 @@ ENV KUBE_CROSSPLATFORMS \
|
|||||||
darwin/amd64 darwin/386 \
|
darwin/amd64 darwin/386 \
|
||||||
windows/amd64 windows/386
|
windows/amd64 windows/386
|
||||||
|
|
||||||
RUN cd /usr/src/go/src && for platform in ${KUBE_CROSSPLATFORMS}; do GOOS=${platform%/*} GOARCH=${platform##*/} ./make.bash --no-clean; done
|
RUN cd /usr/src/go/src \
|
||||||
|
&& for platform in ${KUBE_CROSSPLATFORMS}; do GOOS=${platform%/*} GOARCH=${platform##*/} ./make.bash --no-clean; done
|
||||||
|
|
||||||
# Install g++, then download and install protoc for generating protobuf output
|
# Install g++, then download and install protoc for generating protobuf output
|
||||||
RUN apt-get install -y g++ && apt-get clean && rm -rf /var/lib/apt/lists/* &&\
|
RUN apt-get update \
|
||||||
mkdir -p /usr/local/src/protobuf && cd /usr/local/src/protobuf &&\
|
&& apt-get install -y g++ rsync \
|
||||||
|
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
RUN mkdir -p /usr/local/src/protobuf && cd /usr/local/src/protobuf &&\
|
||||||
wget -q https://github.com/google/protobuf/releases/download/v3.0.0-beta-2/protobuf-cpp-3.0.0-beta-2.tar.gz &&\
|
wget -q https://github.com/google/protobuf/releases/download/v3.0.0-beta-2/protobuf-cpp-3.0.0-beta-2.tar.gz &&\
|
||||||
tar xzvf protobuf-cpp-3.0.0-beta-2.tar.gz &&\
|
tar xzvf protobuf-cpp-3.0.0-beta-2.tar.gz &&\
|
||||||
cd protobuf-3.0.0-beta-2 &&\
|
cd protobuf-3.0.0-beta-2 &&\
|
||||||
@ -52,3 +55,18 @@ RUN echo "deb http://emdebian.org/tools/debian/ jessie main" > /etc/apt/sources.
|
|||||||
&& apt-get install -y build-essential \
|
&& apt-get install -y build-essential \
|
||||||
&& for platform in ${KUBE_DYNAMIC_CROSSPLATFORMS}; do apt-get install -y crossbuild-essential-${platform}; done \
|
&& for platform in ${KUBE_DYNAMIC_CROSSPLATFORMS}; do apt-get install -y crossbuild-essential-${platform}; done \
|
||||||
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# work around 64MB tmpfs size in Docker 1.6
|
||||||
|
ENV TMPDIR /tmp.k8s
|
||||||
|
|
||||||
|
# Get the code coverage tool and godep
|
||||||
|
RUN mkdir $TMPDIR && \
|
||||||
|
go get golang.org/x/tools/cmd/cover github.com/tools/godep
|
||||||
|
|
||||||
|
# Download and symlink etcd. We need this for our integration tests.
|
||||||
|
RUN export ETCD_VERSION=v2.2.1; \
|
||||||
|
mkdir -p /usr/local/src/etcd &&\
|
||||||
|
cd /usr/local/src/etcd &&\
|
||||||
|
curl -fsSLO https://github.com/coreos/etcd/releases/download/$ETCD_VERSION/etcd-$ETCD_VERSION-linux-amd64.tar.gz &&\
|
||||||
|
tar xzf etcd-$ETCD_VERSION-linux-amd64.tar.gz &&\
|
||||||
|
ln -s ../src/etcd/etcd-$ETCD_VERSION-linux-amd64/etcd /usr/local/bin/
|
||||||
|
26
build/build-image/cross/Makefile
Normal file
26
build/build-image/cross/Makefile
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# Copyright 2016 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.
|
||||||
|
|
||||||
|
.PHONY: build push
|
||||||
|
|
||||||
|
IMAGE = kube-cross
|
||||||
|
TAG = $(shell cat VERSION)
|
||||||
|
|
||||||
|
build:
|
||||||
|
docker build -t gcr.io/google_containers/$(IMAGE):$(TAG) .
|
||||||
|
|
||||||
|
push: build
|
||||||
|
gcloud docker --server=gcr.io push gcr.io/google_containers/$(IMAGE):$(TAG)
|
||||||
|
|
||||||
|
all: push
|
1
build/build-image/cross/VERSION
Normal file
1
build/build-image/cross/VERSION
Normal file
@ -0,0 +1 @@
|
|||||||
|
v1.4.2-1
|
@ -48,10 +48,8 @@ readonly KUBE_GCS_DELETE_EXISTING="${KUBE_GCS_DELETE_EXISTING:-n}"
|
|||||||
|
|
||||||
# Constants
|
# Constants
|
||||||
readonly KUBE_BUILD_IMAGE_REPO=kube-build
|
readonly KUBE_BUILD_IMAGE_REPO=kube-build
|
||||||
readonly KUBE_BUILD_GOLANG_VERSION=1.4.2
|
readonly KUBE_BUILD_IMAGE_CROSS_TAG="v1.4.2-1"
|
||||||
readonly KUBE_BUILD_IMAGE_CROSS_TAG="cross-${KUBE_BUILD_GOLANG_VERSION}-2"
|
# KUBE_BUILD_DATA_CONTAINER_NAME=kube-build-data-<hash>"
|
||||||
readonly KUBE_BUILD_IMAGE_CROSS="${KUBE_BUILD_IMAGE_REPO}:${KUBE_BUILD_IMAGE_CROSS_TAG}"
|
|
||||||
# KUBE_BUILD_DATA_CONTAINER_NAME=kube-build-data-<hash>
|
|
||||||
|
|
||||||
# Here we map the output directories across both the local and remote _output
|
# Here we map the output directories across both the local and remote _output
|
||||||
# directories:
|
# directories:
|
||||||
@ -248,7 +246,7 @@ function kube::build::update_dockerfile() {
|
|||||||
else
|
else
|
||||||
sed_opts=(-i)
|
sed_opts=(-i)
|
||||||
fi
|
fi
|
||||||
sed ${sed_opts[@]} "s/KUBE_BUILD_IMAGE_CROSS/${KUBE_BUILD_IMAGE_CROSS}/" "${LOCAL_OUTPUT_BUILD_CONTEXT}/Dockerfile"
|
sed ${sed_opts[@]} "s/KUBE_BUILD_IMAGE_CROSS_TAG/${KUBE_BUILD_IMAGE_CROSS_TAG}/" "${LOCAL_OUTPUT_BUILD_CONTEXT}/Dockerfile"
|
||||||
sed ${sed_opts[@]} "s#KUBE_BUILD_HTTP_PROXY#${KUBE_BUILD_HTTP_PROXY:-\"\"}#" "${LOCAL_OUTPUT_BUILD_CONTEXT}/Dockerfile"
|
sed ${sed_opts[@]} "s#KUBE_BUILD_HTTP_PROXY#${KUBE_BUILD_HTTP_PROXY:-\"\"}#" "${LOCAL_OUTPUT_BUILD_CONTEXT}/Dockerfile"
|
||||||
sed ${sed_opts[@]} "s#KUBE_BUILD_HTTPS_PROXY#${KUBE_BUILD_HTTPS_PROXY:-\"\"}#" "${LOCAL_OUTPUT_BUILD_CONTEXT}/Dockerfile"
|
sed ${sed_opts[@]} "s#KUBE_BUILD_HTTPS_PROXY#${KUBE_BUILD_HTTPS_PROXY:-\"\"}#" "${LOCAL_OUTPUT_BUILD_CONTEXT}/Dockerfile"
|
||||||
sed ${sed_opts[@]} "s#KUBE_BUILD_NO_PROXY#${KUBE_BUILD_NO_PROXY:-127.0.0.1}#" "${LOCAL_OUTPUT_BUILD_CONTEXT}/Dockerfile"
|
sed ${sed_opts[@]} "s#KUBE_BUILD_NO_PROXY#${KUBE_BUILD_NO_PROXY:-127.0.0.1}#" "${LOCAL_OUTPUT_BUILD_CONTEXT}/Dockerfile"
|
||||||
@ -460,23 +458,6 @@ function kube::build::build_image_built() {
|
|||||||
kube::build::docker_image_exists "${KUBE_BUILD_IMAGE_REPO}" "${KUBE_BUILD_IMAGE_TAG}"
|
kube::build::docker_image_exists "${KUBE_BUILD_IMAGE_REPO}" "${KUBE_BUILD_IMAGE_TAG}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function kube::build::ensure_golang() {
|
|
||||||
kube::build::docker_image_exists golang "${KUBE_BUILD_GOLANG_VERSION}" || {
|
|
||||||
[[ ${KUBE_SKIP_CONFIRMATIONS} =~ ^[yY]$ ]] || {
|
|
||||||
echo "You don't have a local copy of the golang:${KUBE_BUILD_GOLANG_VERSION} docker image. This image is 450MB."
|
|
||||||
read -p "Download it now? [y/n] " -r
|
|
||||||
echo
|
|
||||||
[[ $REPLY =~ ^[yY]$ ]] || {
|
|
||||||
echo "Aborting." >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
kube::log::status "Pulling docker image: golang:${KUBE_BUILD_GOLANG_VERSION}"
|
|
||||||
"${DOCKER[@]}" pull golang:${KUBE_BUILD_GOLANG_VERSION}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# The set of source targets to include in the kube-build image
|
# The set of source targets to include in the kube-build image
|
||||||
function kube::build::source_targets() {
|
function kube::build::source_targets() {
|
||||||
local targets=(
|
local targets=(
|
||||||
@ -512,8 +493,6 @@ function kube::build::source_targets() {
|
|||||||
function kube::build::build_image() {
|
function kube::build::build_image() {
|
||||||
kube::build::ensure_tar
|
kube::build::ensure_tar
|
||||||
|
|
||||||
kube::build::build_image_cross
|
|
||||||
|
|
||||||
mkdir -p "${LOCAL_OUTPUT_BUILD_CONTEXT}"
|
mkdir -p "${LOCAL_OUTPUT_BUILD_CONTEXT}"
|
||||||
"${TAR}" czf "${LOCAL_OUTPUT_BUILD_CONTEXT}/kube-source.tar.gz" $(kube::build::source_targets)
|
"${TAR}" czf "${LOCAL_OUTPUT_BUILD_CONTEXT}/kube-source.tar.gz" $(kube::build::source_targets)
|
||||||
|
|
||||||
@ -523,21 +502,9 @@ function kube::build::build_image() {
|
|||||||
cp build/build-image/Dockerfile "${LOCAL_OUTPUT_BUILD_CONTEXT}/Dockerfile"
|
cp build/build-image/Dockerfile "${LOCAL_OUTPUT_BUILD_CONTEXT}/Dockerfile"
|
||||||
kube::build::update_dockerfile
|
kube::build::update_dockerfile
|
||||||
|
|
||||||
# We don't want to force-pull this image because it's based on a local image
|
|
||||||
# (see kube::build::build_image_cross), not upstream.
|
|
||||||
kube::build::docker_build "${KUBE_BUILD_IMAGE}" "${LOCAL_OUTPUT_BUILD_CONTEXT}" 'false'
|
kube::build::docker_build "${KUBE_BUILD_IMAGE}" "${LOCAL_OUTPUT_BUILD_CONTEXT}" 'false'
|
||||||
}
|
}
|
||||||
|
|
||||||
# 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}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Build a docker image from a Dockerfile.
|
# Build a docker image from a Dockerfile.
|
||||||
# $1 is the name of the image to build
|
# $1 is the name of the image to build
|
||||||
# $2 is the location of the "context" directory, with the Dockerfile at the root.
|
# $2 is the location of the "context" directory, with the Dockerfile at the root.
|
||||||
|
Loading…
Reference in New Issue
Block a user