mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-04 18:52:38 +00:00
Build Kubernetes in Docker.
Scripts and Dockerfile to build a container image, build binaries, run tests, etc. Also copy output back out to the host machine.
This commit is contained in:
65
build/build-image/Dockerfile
Normal file
65
build/build-image/Dockerfile
Normal file
@@ -0,0 +1,65 @@
|
||||
# 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 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
|
||||
MAINTAINER Joe Beda <jbeda@google.com>
|
||||
|
||||
RUN apt-get update -y && apt-get install --no-install-recommends -y -q \
|
||||
curl \
|
||||
build-essential \
|
||||
ca-certificates \
|
||||
git \
|
||||
mercurial \
|
||||
rsync
|
||||
|
||||
# Install Go
|
||||
# TODO(jbeda) -- we need to verify this against the hash
|
||||
RUN curl -s https://storage.googleapis.com/golang/go1.2.2.src.tar.gz | tar -C /usr/local -xz
|
||||
ENV PATH /usr/local/go/bin:$PATH
|
||||
RUN cd /usr/local/go/src && ./make.bash --no-clean 2>&1
|
||||
|
||||
# Compile Go for cross compilation
|
||||
ENV KUBE_CROSSPLATFORMS \
|
||||
linux/386 linux/arm \
|
||||
darwin/amd64 darwin/386
|
||||
# (set an explicit GOARM of 5 for maximum compatibility)
|
||||
ENV GOARM 5
|
||||
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'
|
||||
|
||||
# Set up Go Environment
|
||||
ENV PATH /usr/local/go/bin:/go/bin:$PATH
|
||||
ENV GOPATH /go:/go/src/github.com/GoogleCloudPlatform/kubernetes/third_party
|
||||
|
||||
# Mark this as a kube-build container
|
||||
RUN touch /kube-build-image
|
||||
|
||||
# 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
|
||||
|
||||
WORKDIR /go/src/github.com/GoogleCloudPlatform/kubernetes
|
||||
|
||||
# Upload Kubernetes
|
||||
ADD kube-source.tar.gz /go/src/github.com/GoogleCloudPlatform/kubernetes
|
27
build/build-image/common.sh
Normal file
27
build/build-image/common.sh
Normal file
@@ -0,0 +1,27 @@
|
||||
# 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 script sets up a go workspace locally and builds all go components.
|
||||
# You can 'source' this file if you want to set up GOPATH in your local shell.
|
||||
|
||||
cd $(dirname "${BASH_SOURCE}")/../.. >/dev/null
|
||||
readonly KUBE_REPO_ROOT="${PWD}"
|
||||
readonly KUBE_TARGET="${KUBE_REPO_ROOT}/output/build"
|
||||
readonly KUBE_GO_PACKAGE=github.com/GoogleCloudPlatform/kubernetes
|
||||
|
||||
mkdir -p "${KUBE_TARGET}"
|
||||
|
||||
if [[ ! -f "/kube-build-image" ]]; then
|
||||
echo "WARNING: This script should be run in the kube-build conrtainer image!" >&2
|
||||
fi
|
45
build/build-image/make-binaries.sh
Executable file
45
build/build-image/make-binaries.sh
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/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 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
|
31
build/build-image/run-integration.sh
Executable file
31
build/build-image/run-integration.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/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.
|
||||
|
||||
set -e
|
||||
|
||||
source $(dirname $0)/common.sh
|
||||
|
||||
ETCD_DIR="${KUBE_REPO_ROOT}/output/etcd"
|
||||
mkdir -p "${ETCD_DIR}"
|
||||
|
||||
etcd -name test -data-dir ${ETCD_DIR} > "${KUBE_REPO_ROOT}/output/etcd.log" &
|
||||
ETCD_PID=$!
|
||||
|
||||
sleep 5
|
||||
|
||||
${KUBE_TARGET}/integration
|
||||
|
||||
kill $ETCD_PID
|
43
build/build-image/run-tests.sh
Executable file
43
build/build-image/run-tests.sh
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/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.
|
||||
|
||||
|
||||
set -e
|
||||
|
||||
source $(dirname $0)/common.sh
|
||||
|
||||
find_test_dirs() {
|
||||
(
|
||||
cd ${KUBE_REPO_ROOT}
|
||||
find . -not \( \
|
||||
\( \
|
||||
-wholename './third_party' \
|
||||
-o -wholename './output' \
|
||||
\) -prune \
|
||||
\) -name '*_test.go' -print0 | xargs -0n1 dirname | sort -u
|
||||
)
|
||||
}
|
||||
|
||||
cd "${KUBE_TARGET}"
|
||||
|
||||
if [[ -n "$1" ]]; then
|
||||
go test -cover -coverprofile="tmp.out" "$KUBE_GO_PACKAGE/$1"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for package in $(find_test_dirs); do
|
||||
go test -cover -coverprofile="tmp.out" "${KUBE_GO_PACKAGE}/${package}"
|
||||
done
|
Reference in New Issue
Block a user