mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
Add support for versions in dockerized build.
This commit is contained in:
parent
7fc3a6c050
commit
c5cb7202af
@ -62,5 +62,8 @@ RUN touch /kube-build-image
|
|||||||
|
|
||||||
WORKDIR /go/src/github.com/GoogleCloudPlatform/kubernetes
|
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
|
# Upload Kubernetes source
|
||||||
ADD kube-source.tar.gz /go/src/github.com/GoogleCloudPlatform/kubernetes
|
ADD kube-source.tar.gz /go/src/github.com/GoogleCloudPlatform/kubernetes
|
||||||
|
@ -25,7 +25,13 @@ readonly KUBE_GO_PACKAGE=github.com/GoogleCloudPlatform/kubernetes
|
|||||||
mkdir -p "${KUBE_TARGET}"
|
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 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
|
fi
|
||||||
|
|
||||||
function make-binary() {
|
function make-binary() {
|
||||||
@ -34,7 +40,7 @@ function make-binary() {
|
|||||||
|
|
||||||
echo "+++ Building ${bin} for ${GOOS}/${GOARCH}"
|
echo "+++ Building ${bin} for ${GOOS}/${GOARCH}"
|
||||||
pushd "${KUBE_REPO_ROOT}"
|
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
|
popd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,9 @@
|
|||||||
# Common utilties, variables and checks for all build scripts.
|
# Common utilties, variables and checks for all build scripts.
|
||||||
|
|
||||||
cd $(dirname "${BASH_SOURCE}")/..
|
cd $(dirname "${BASH_SOURCE}")/..
|
||||||
|
|
||||||
|
source hack/config-go.sh
|
||||||
|
|
||||||
readonly KUBE_REPO_ROOT="${PWD}"
|
readonly KUBE_REPO_ROOT="${PWD}"
|
||||||
|
|
||||||
readonly KUBE_GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
|
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}
|
mkdir -p ${BUILD_CONTEXT_DIR}
|
||||||
tar czf ${BUILD_CONTEXT_DIR}/kube-source.tar.gz "${SOURCE[@]}"
|
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
|
cp build/build-image/Dockerfile ${BUILD_CONTEXT_DIR}/Dockerfile
|
||||||
kube::build::docker-build "${KUBE_BUILD_IMAGE}" "${BUILD_CONTEXT_DIR}"
|
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
|
for b in "${KUBE_RUN_BINARIES[@]}" ; do
|
||||||
kube::build::clean-image "${KUBE_RUN_IMAGE_BASE}-${b}"
|
kube::build::clean-image "${KUBE_RUN_IMAGE_BASE}-${b}"
|
||||||
done
|
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.
|
# Build a docker image from a Dockerfile.
|
||||||
|
Loading…
Reference in New Issue
Block a user