aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorLars Kellogg-Stedman <lars@redhat.com>2014-10-03 16:20:18 -0400
committerLars Kellogg-Stedman <lars@redhat.com>2014-10-04 11:03:39 -0400
commit24b6db92bc5cf56a5e2c1da3481ee57bddba7c80 (patch)
tree5a2473f302db43d4ddf329f1cc9a38d1c87b0ec6 /tools
parent9ce465d544cfecb7f96e7b453d7ad567775da648 (diff)
downloadkolla-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')
-rwxr-xr-xtools/build-docker-image94
-rwxr-xr-xtools/update-build-links10
2 files changed, 104 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
diff --git a/tools/update-build-links b/tools/update-build-links
new file mode 100755
index 000000000..ac6fa53a8
--- /dev/null
+++ b/tools/update-build-links
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+cd $(git rev-parse --show-toplevel)
+find docker -name Dockerfile | while read dockerfile; do
+ dir=${dockerfile%/*}
+ link=$(python -c 'import os,sys; print os.path.relpath(sys.argv[1], sys.argv[2])' \
+ $PWD/tools/build-docker-image $dir)
+ ln -sf $link $dir/build
+done
+