diff options
| author | Lars Kellogg-Stedman <lars@redhat.com> | 2014-10-03 16:20:18 -0400 |
|---|---|---|
| committer | Lars Kellogg-Stedman <lars@redhat.com> | 2014-10-04 11:03:39 -0400 |
| commit | 24b6db92bc5cf56a5e2c1da3481ee57bddba7c80 (patch) | |
| tree | 5a2473f302db43d4ddf329f1cc9a38d1c87b0ec6 /tools/build-docker-image | |
| parent | 9ce465d544cfecb7f96e7b453d7ad567775da648 (diff) | |
| download | kolla-24b6db92bc5cf56a5e2c1da3481ee57bddba7c80.tar.gz kolla-24b6db92bc5cf56a5e2c1da3481ee57bddba7c80.zip | |
introduce a new build mechanism
This patch replaces the collection of individual "build" scripts with a
single script (tools/build-docker-image), made available as "build"
inside each image directory.
The build-docker-image script will, by default, build images tagged with
the current commit id in order to prevent developers from accidentally
stepping on each other or on release images.
Documentation in docs/image-building.md describes the script in more
detail.
Change-Id: I444d5c2256a85223f8750a0904cb4b07f18ab67f
Diffstat (limited to 'tools/build-docker-image')
| -rwxr-xr-x | tools/build-docker-image | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/tools/build-docker-image b/tools/build-docker-image new file mode 100755 index 000000000..66e534fa4 --- /dev/null +++ b/tools/build-docker-image @@ -0,0 +1,94 @@ +#!/bin/bash + +NAMESPACE=kollaglue +PREFIX=fedora-rdo- +TAG=$(git rev-parse --short HEAD) +IMAGE="${PREFIX}${PWD##*/}" + +TOPDIR=$(git rev-parse --show-toplevel) + +usage () { + cat <<EOF +$0: usage: $0 [options] + +Options: + +--namespace, -n <namespace> +--tag, -t <tag> +--push, -p +--no-cache, -N +--release +EOF +} + +[ -f ./.buildconf ] && . ./.buildconf +[ -f $TOPDIR/.buildconf ] && . $TOPDIR/.buildconf + +ARGS=$(getopt -o 'n:t:pN' -l help,namespace:,push,release,tag:,no-cache -- "$@") || { usage >&2; exit 2; } + +eval set -- "$ARGS" + +while :; do + case "$1" in + + (--help) usage + exit 0 + ;; + + (--release) MODE=release + TAG=latest + ;; + + (--tag|-t) shift + TAG="$1" + ;; + + (--push|-p) PUSH=1 + ;; + + (--no-cache|-N) + BUILDFLAGS="${BUILDFLAGS} --no-cache" + ;; + + (--namespace|-n) + shift + NAMESPACE="1" + ;; + + (--) break + ;; + + esac + + shift +done + +FULLIMAGE="${NAMESPACE}/${IMAGE}${TAG:+:${TAG}}" + +cat <<EOF +====================================================================== +$FULLIMAGE +====================================================================== + +EOF + +if [ "$MODE" = "release" ]; then + echo "*** YOU ARE BUILDING A RELEASE IMAGE ***" + echo +fi + +if ! docker build ${BUILDFLAGS} -t "$FULLIMAGE" .; then + echo "ERROR: failed to build $FULLIMAGE" + exit 1 +fi + +echo "Built: $FULLIMAGE" + +if [ "$PUSH" = 1 ]; then + if ! docker push "$FULLIMAGE"; then + echo "ERROR: failed to push $FULLIMAGE" + exit 1 + fi + + echo "Pushed: $FULLIMAGE" +fi |
