From c5cb7202afa9cd301db488b4ef0c4f127a07a184 Mon Sep 17 00:00:00 2001 From: Joe Beda Date: Mon, 8 Sep 2014 16:55:57 -0700 Subject: [PATCH] Add support for versions in dockerized build. --- build/build-image/Dockerfile | 3 +++ build/build-image/common.sh | 10 ++++++++-- build/common.sh | 9 +++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/build/build-image/Dockerfile b/build/build-image/Dockerfile index a6c78ab25a..f165676b67 100644 --- a/build/build-image/Dockerfile +++ b/build/build-image/Dockerfile @@ -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 diff --git a/build/build-image/common.sh b/build/build-image/common.sh index 9539f4f6d4..a43b3bd407 100644 --- a/build/build-image/common.sh +++ b/build/build-image/common.sh @@ -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 } diff --git a/build/common.sh b/build/common.sh index bf6e73ff4a..d09c7f9c05 100644 --- a/build/common.sh +++ b/build/common.sh @@ -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 <" | awk '{print $3}') 2> /dev/null } # Build a docker image from a Dockerfile.