aboutsummaryrefslogtreecommitdiff
path: root/tools/build-docker-image
diff options
context:
space:
mode:
authorSam Yaple <sam@yaple.net>2015-05-10 23:50:59 -0500
committerSam Yaple <sam@yaple.net>2015-05-12 22:16:59 -0500
commite057343c2fc712762397e065e660197530416b4f (patch)
tree62d403b5c0ef6c3231cab9571bcf544b31d46f63 /tools/build-docker-image
parent52847aa1b92b20f6e60b28bdd3d9847964c547f7 (diff)
downloadkolla-e057343c2fc712762397e065e660197530416b4f.tar.gz
kolla-e057343c2fc712762397e065e660197530416b4f.zip
Allow private docker registries
Change the sed seperator to accept a namespace with a private registry and add an option to specify the registry. Below is an example for a registry located at 192.168.0.10:5000. $ ./build-all-docker-images -r 192.168.0.10:5000 The final image name would be something like this: '192.168.0.10:5000/kollaglue/centos-rdo-base' All build, push, and pull commands will still function the same. Change-Id: Ic0ff96bb8119ddfab15b99e9f1e21cfe8d321dab
Diffstat (limited to 'tools/build-docker-image')
-rwxr-xr-xtools/build-docker-image17
1 files changed, 13 insertions, 4 deletions
diff --git a/tools/build-docker-image b/tools/build-docker-image
index 5d85f6263..c816fd089 100755
--- a/tools/build-docker-image
+++ b/tools/build-docker-image
@@ -15,6 +15,7 @@ Usage: $0 [options]
Options:
+--private-registry, -r <registry_address[:port]>
--namespace, -n <namespace>
--tag, -t <tag>
--push, -p
@@ -29,7 +30,7 @@ EOF
[ -f $TOPDIR/.buildconf ] && . $TOPDIR/.buildconf
[ -f $IMGDIR/.buildconf ] && . $IMGDIR/.buildconf
-ARGS=$(getopt -o hn:t:pfuN -l help,namespace:,push,pull,release,tag:,force-rm,no-cache,no-use-released-parent -- "$@") || { usage >&2; exit 2; }
+ARGS=$(getopt -o hr:n:t:pfuN -l help,namespace:,push,private-registry:,release,tag:,force-rm,no-cache,no-use-released-parent -- "$@") || { usage >&2; exit 2; }
eval set -- "$ARGS"
@@ -63,6 +64,11 @@ while :; do
BUILDFLAGS="${BUILDFLAGS} --no-cache"
;;
+ (--private-registry|-r)
+ shift
+ REGISTRY="$1"
+ ;;
+
(--namespace|-n)
shift
NAMESPACE="$1"
@@ -94,6 +100,9 @@ if [ "$NAMESPACE" = "$RELEASE_NAMESPACE" ] \
exit 1
fi
+if [[ -n $REGISTRY ]]; then
+ NAMESPACE="${REGISTRY}/${NAMESPACE}"
+fi
IMAGE="${PREFIX}${IMGDIR##*/}"
FULLIMAGE="${NAMESPACE}/${IMAGE}${TAG:+:${TAG}}"
@@ -113,9 +122,9 @@ TMPDIR=$(mktemp -d /tmp/kolla-build.XXXXXXXXXX)
cp -aL $IMGDIR/* $TMPDIR
# Use an extension for in-place editing for portability, as GNU and BSD
# versions of sed behave differently otherwise
-sed -i.bak "s/%%KOLLA_NAMESPACE%%/${NAMESPACE}/g" $TMPDIR/Dockerfile
-sed -i.bak "s/%%KOLLA_PREFIX%%/${PREFIX}/g" $TMPDIR/Dockerfile
-sed -i.bak "s/%%KOLLA_TAG%%/${PARENT_TAG}/g" $TMPDIR/Dockerfile
+sed -i.bak "s|%%KOLLA_NAMESPACE%%|${NAMESPACE}|g" $TMPDIR/Dockerfile
+sed -i.bak "s|%%KOLLA_PREFIX%%|${PREFIX}|g" $TMPDIR/Dockerfile
+sed -i.bak "s|%%KOLLA_TAG%%|${PARENT_TAG}|g" $TMPDIR/Dockerfile
if ! docker build ${BUILDFLAGS} -t "$FULLIMAGE" $TMPDIR; then
echo "ERROR: failed to build $FULLIMAGE"