mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 02:09:56 +00:00
Support cross compilation.
Also add more utilities to copy and clean stuff.
This commit is contained in:
parent
570ebf54a9
commit
4f63a690ee
@ -13,15 +13,6 @@
|
|||||||
# 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
|
||||||
#
|
|
||||||
# Usage:
|
|
||||||
#
|
|
||||||
# # Assemble the full dev environment. This is slow the first time.
|
|
||||||
# docker build -t kube-build .
|
|
||||||
#
|
|
||||||
# # Mount your source in an interactive container for quick testing:
|
|
||||||
# docker run -v `pwd`:/go/src/github.com/GoogleCloudPlatform/kubernetes -i -t docker bash
|
|
||||||
#
|
|
||||||
|
|
||||||
FROM google/debian:wheezy
|
FROM google/debian:wheezy
|
||||||
MAINTAINER Joe Beda <jbeda@google.com>
|
MAINTAINER Joe Beda <jbeda@google.com>
|
||||||
@ -50,15 +41,17 @@ RUN cd /usr/local/go/src && \
|
|||||||
bash -xc 'for platform in $KUBE_CROSSPLATFORMS; do GOOS=${platform%/*} GOARCH=${platform##*/} ./make.bash --no-clean 2>&1; done'
|
bash -xc 'for platform in $KUBE_CROSSPLATFORMS; do GOOS=${platform%/*} GOARCH=${platform##*/} ./make.bash --no-clean 2>&1; done'
|
||||||
|
|
||||||
# Set up Go Environment
|
# Set up Go Environment
|
||||||
ENV PATH /usr/local/go/bin:/go/bin:$PATH
|
ENV PATH /go/bin:$PATH
|
||||||
ENV GOPATH /go:/go/src/github.com/GoogleCloudPlatform/kubernetes/third_party
|
ENV GOPATH /go:/go/src/github.com/GoogleCloudPlatform/kubernetes/third_party
|
||||||
|
ENV GOOS linux
|
||||||
# Mark this as a kube-build container
|
ENV GOARCH amd64
|
||||||
RUN touch /kube-build-image
|
|
||||||
|
|
||||||
# Get the code coverage tool and etcd for integration tests
|
# Get the code coverage tool and etcd for integration tests
|
||||||
RUN go get code.google.com/p/go.tools/cmd/cover github.com/coreos/etcd
|
RUN go get code.google.com/p/go.tools/cmd/cover github.com/coreos/etcd
|
||||||
|
|
||||||
|
# Mark this as a kube-build container
|
||||||
|
RUN touch /kube-build-image
|
||||||
|
|
||||||
WORKDIR /go/src/github.com/GoogleCloudPlatform/kubernetes
|
WORKDIR /go/src/github.com/GoogleCloudPlatform/kubernetes
|
||||||
|
|
||||||
# Upload Kubernetes
|
# Upload Kubernetes
|
||||||
|
@ -25,3 +25,33 @@ mkdir -p "${KUBE_TARGET}"
|
|||||||
if [[ ! -f "/kube-build-image" ]]; then
|
if [[ ! -f "/kube-build-image" ]]; then
|
||||||
echo "WARNING: This script should be run in the kube-build conrtainer image!" >&2
|
echo "WARNING: This script should be run in the kube-build conrtainer image!" >&2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
function make-binaries() {
|
||||||
|
readonly BINARIES="
|
||||||
|
proxy
|
||||||
|
integration
|
||||||
|
apiserver
|
||||||
|
controller-manager
|
||||||
|
kubelet
|
||||||
|
cloudcfg
|
||||||
|
localkube"
|
||||||
|
|
||||||
|
ARCH_TARGET="${KUBE_TARGET}/${GOOS}/${GOARCH}"
|
||||||
|
mkdir -p "${ARCH_TARGET}"
|
||||||
|
|
||||||
|
function make-binary() {
|
||||||
|
echo "+++ Building $1 for ${GOOS}/${GOARCH}"
|
||||||
|
go build \
|
||||||
|
-o "${ARCH_TARGET}/$1" \
|
||||||
|
github.com/GoogleCloudPlatform/kubernetes/cmd/$1
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ -n $1 ]]; then
|
||||||
|
make-binary $1
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
for b in ${BINARIES}; do
|
||||||
|
make-binary $b
|
||||||
|
done
|
||||||
|
}
|
||||||
|
@ -20,26 +20,4 @@ set -e
|
|||||||
|
|
||||||
source $(dirname $0)/common.sh
|
source $(dirname $0)/common.sh
|
||||||
|
|
||||||
readonly BINARIES="
|
make-binaries
|
||||||
proxy
|
|
||||||
integration
|
|
||||||
apiserver
|
|
||||||
controller-manager
|
|
||||||
kubelet
|
|
||||||
cloudcfg
|
|
||||||
localkube"
|
|
||||||
|
|
||||||
if [[ -n $1 ]]; then
|
|
||||||
echo "+++ Building $1"
|
|
||||||
go build \
|
|
||||||
-o "${KUBE_TARGET}/$1" \
|
|
||||||
github.com/GoogleCloudPlatform/kubernetes/cmd/$1
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
for b in ${BINARIES}; do
|
|
||||||
echo "+++ Building $b"
|
|
||||||
go build \
|
|
||||||
-o "${KUBE_TARGET}/$b" \
|
|
||||||
github.com/GoogleCloudPlatform/kubernetes/cmd/$b
|
|
||||||
done
|
|
||||||
|
35
build/build-image/make-cross.sh
Executable file
35
build/build-image/make-cross.sh
Executable file
@ -0,0 +1,35 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# 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 and builds all go components.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
source $(dirname $0)/common.sh
|
||||||
|
|
||||||
|
readonly CROSS_BINARIES="
|
||||||
|
cloudcfg
|
||||||
|
"
|
||||||
|
|
||||||
|
for platform in ${KUBE_CROSSPLATFORMS}; do
|
||||||
|
(
|
||||||
|
export GOOS=${platform%/*}
|
||||||
|
export GOARCH=${platform##*/}
|
||||||
|
for binary in ${CROSS_BINARIES}; do
|
||||||
|
make-binaries "${binary}"
|
||||||
|
done
|
||||||
|
)
|
||||||
|
done
|
@ -90,6 +90,7 @@ function build-image() {
|
|||||||
set +e # We are handling the error here manually
|
set +e # We are handling the error here manually
|
||||||
local -r DOCKER_OUTPUT="$(${DOCKER_BUILD_CMD} 2>&1)"
|
local -r DOCKER_OUTPUT="$(${DOCKER_BUILD_CMD} 2>&1)"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
|
set -e
|
||||||
echo "+++ Docker build command failed." >&2
|
echo "+++ Docker build command failed." >&2
|
||||||
echo >&2
|
echo >&2
|
||||||
echo "${DOCKER_OUTPUT}" >&2
|
echo "${DOCKER_OUTPUT}" >&2
|
||||||
@ -100,6 +101,8 @@ function build-image() {
|
|||||||
echo >&2
|
echo >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
set -e
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run a command in the kube-build image. This assumes that the image has
|
# Run a command in the kube-build image. This assumes that the image has
|
||||||
@ -109,7 +112,7 @@ function run-build-command() {
|
|||||||
|
|
||||||
local -r DOCKER="docker run --rm --name=${DOCKER_CONTAINER_NAME} -it ${DOCKER_MOUNT} ${KUBE_BUILD_IMAGE}"
|
local -r DOCKER="docker run --rm --name=${DOCKER_CONTAINER_NAME} -it ${DOCKER_MOUNT} ${KUBE_BUILD_IMAGE}"
|
||||||
|
|
||||||
docker rm ${DOCKER_CONTAINER_NAME} >/dev/null 2>&1
|
docker rm ${DOCKER_CONTAINER_NAME} >/dev/null 2>&1 || true
|
||||||
|
|
||||||
${DOCKER} "$@"
|
${DOCKER} "$@"
|
||||||
|
|
||||||
@ -130,10 +133,11 @@ function copy-output() {
|
|||||||
local DOCKER="docker run -a stdout --rm --name=${DOCKER_CONTAINER_NAME} ${DOCKER_MOUNT} ${KUBE_BUILD_IMAGE}"
|
local DOCKER="docker run -a stdout --rm --name=${DOCKER_CONTAINER_NAME} ${DOCKER_MOUNT} ${KUBE_BUILD_IMAGE}"
|
||||||
|
|
||||||
# Kill any leftover container
|
# Kill any leftover container
|
||||||
docker rm ${DOCKER_CONTAINER_NAME} >/dev/null 2>&1
|
docker rm ${DOCKER_CONTAINER_NAME} >/dev/null 2>&1 || true
|
||||||
|
|
||||||
echo "+++ Syncing back output directory from boot2docker VM"
|
echo "+++ Syncing back output directory from boot2docker VM"
|
||||||
mkdir -p "${LOCAL_OUTPUT_DIR}"
|
mkdir -p "${LOCAL_OUTPUT_DIR}"
|
||||||
|
rm -rf "${LOCAL_OUTPUT_DIR}/*"
|
||||||
${DOCKER} sh -c "tar c -C ${REMOTE_OUTPUT_DIR} ." \
|
${DOCKER} sh -c "tar c -C ${REMOTE_OUTPUT_DIR} ." \
|
||||||
| tar xv -C "${LOCAL_OUTPUT_DIR}"
|
| tar xv -C "${LOCAL_OUTPUT_DIR}"
|
||||||
|
|
||||||
@ -146,3 +150,5 @@ function copy-output() {
|
|||||||
# rsync --blocking-io -av -e "${DOCKER}" foo:${REMOTE_OUTPUT_DIR}/ ${LOCAL_OUTPUT_DIR}
|
# rsync --blocking-io -av -e "${DOCKER}" foo:${REMOTE_OUTPUT_DIR}/ ${LOCAL_OUTPUT_DIR}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
26
build/copy-output.sh
Executable file
26
build/copy-output.sh
Executable file
@ -0,0 +1,26 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
# Make all of the Kubernetes binaries.
|
||||||
|
#
|
||||||
|
# This makes the docker build image, builds the binaries and copies them out
|
||||||
|
# of the docker container.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
source $(dirname $0)/common.sh
|
||||||
|
|
||||||
|
copy-output
|
@ -25,4 +25,3 @@ source $(dirname $0)/common.sh
|
|||||||
|
|
||||||
build-image
|
build-image
|
||||||
run-build-command build/build-image/make-binaries.sh "$@"
|
run-build-command build/build-image/make-binaries.sh "$@"
|
||||||
copy-output
|
|
||||||
|
27
build/make-clean.sh
Executable file
27
build/make-clean.sh
Executable file
@ -0,0 +1,27 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
# Make all of the Kubernetes binaries.
|
||||||
|
#
|
||||||
|
# This makes the docker build image, builds the binaries and copies them out
|
||||||
|
# of the docker container.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
source $(dirname $0)/common.sh
|
||||||
|
|
||||||
|
build-image
|
||||||
|
run-build-command rm -rf output/build/*
|
27
build/make-cross.sh
Executable file
27
build/make-cross.sh
Executable file
@ -0,0 +1,27 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
# Make all of the Kubernetes binaries.
|
||||||
|
#
|
||||||
|
# This makes the docker build image, builds the binaries and copies them out
|
||||||
|
# of the docker container.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
source $(dirname $0)/common.sh
|
||||||
|
|
||||||
|
build-image
|
||||||
|
run-build-command build/build-image/make-cross.sh
|
@ -27,4 +27,3 @@ source $(dirname $0)/common.sh
|
|||||||
|
|
||||||
build-image
|
build-image
|
||||||
run-build-command bash
|
run-build-command bash
|
||||||
copy-output
|
|
||||||
|
Loading…
Reference in New Issue
Block a user