Add support for versions in dockerized build.

pull/6/head
Joe Beda 2014-09-08 16:55:57 -07:00
parent 7fc3a6c050
commit c5cb7202af
3 changed files with 20 additions and 2 deletions

View File

@ -62,5 +62,8 @@ RUN touch /kube-build-image
WORKDIR /go/src/github.com/GoogleCloudPlatform/kubernetes
# Propagate the git tree version into the build image
ADD kube-version-defs /kube-version-defs
# Upload Kubernetes source
ADD kube-source.tar.gz /go/src/github.com/GoogleCloudPlatform/kubernetes

View File

@ -25,7 +25,13 @@ 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
echo "WARNING: This script should be run in the kube-build container image!" >&2
fi
if [[ -f "/kube-version-defs" ]]; then
source "/kube-version-defs"
else
echo "WARNING: No version information provided in build image"
fi
function make-binary() {
@ -34,7 +40,7 @@ function make-binary() {
echo "+++ Building ${bin} for ${GOOS}/${GOARCH}"
pushd "${KUBE_REPO_ROOT}"
godep go build -o "${ARCH_TARGET}/${bin}" "${gopkg}"
godep go build -ldflags "${KUBE_LD_FLAGS-}" -o "${ARCH_TARGET}/${bin}" "${gopkg}"
popd
}

View File

@ -17,6 +17,9 @@
# Common utilties, variables and checks for all build scripts.
cd $(dirname "${BASH_SOURCE}")/..
source hack/config-go.sh
readonly KUBE_REPO_ROOT="${PWD}"
readonly KUBE_GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
@ -105,6 +108,9 @@ function kube::build::build-image() {
)
mkdir -p ${BUILD_CONTEXT_DIR}
tar czf ${BUILD_CONTEXT_DIR}/kube-source.tar.gz "${SOURCE[@]}"
cat >${BUILD_CONTEXT_DIR}/kube-version-defs <<EOF
KUBE_LD_FLAGS="$(kube::version_ldflags)"
EOF
cp build/build-image/Dockerfile ${BUILD_CONTEXT_DIR}/Dockerfile
kube::build::docker-build "${KUBE_BUILD_IMAGE}" "${BUILD_CONTEXT_DIR}"
}
@ -139,6 +145,9 @@ function kube::build::clean-images() {
for b in "${KUBE_RUN_BINARIES[@]}" ; do
kube::build::clean-image "${KUBE_RUN_IMAGE_BASE}-${b}"
done
echo "+++ Cleaning all other untagged docker images"
docker rmi $(docker images | grep "^<none>" | awk '{print $3}') 2> /dev/null
}
# Build a docker image from a Dockerfile.