From 047683d12c96f3b1cfddd906a515fd01bc122aa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Andr=C3=A9?= Date: Tue, 5 May 2015 12:33:37 +0900 Subject: [PATCH] Initial support for taggable dependencies Introduce a new --no-use-released-parent option to `build-docker-image` that allows specifying whether the parent image uses the same tag as the one that's currently build or the release tag. Default is to use the release tag for parent image, however `build-all-docker-images` script forces it to be the current tag. Change to Dockerfile is coming next. Change-Id: Ief11c9abb722c181ca85f38ee11800dbf4332a5f --- tools/build-all-docker-images | 5 +++-- tools/build-docker-image | 19 ++++++++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/tools/build-all-docker-images b/tools/build-all-docker-images index 74aa80fb8a..c890b872b2 100755 --- a/tools/build-all-docker-images +++ b/tools/build-all-docker-images @@ -27,7 +27,7 @@ function warn { } function set_defaults { - PREFIX=fedora-rdo- + PREFIX=centos-rdo- NAMESPACE=kollaglue } @@ -56,7 +56,7 @@ function build_image { if [ -x "$dir/build" ]; then printf "\n" info "Building image in $dir" - if $dir/build $ARGS; then + if $dir/build $ARGS --no-use-released-parent; then success "Successfully built image in $dir" status[$image]="rebuilt" else @@ -78,6 +78,7 @@ function init_image { local base_image=$(cat $img_dir/Dockerfile | gawk 'match($0, /^\s*FROM\s+(\S+)/, matches) {print matches[1]}' ) base_image=${base_image//%%KOLLA_NAMESPACE%%/$NAMESPACE} base_image=${base_image//%%KOLLA_PREFIX%%/$PREFIX} + base_image=${base_image//:%%KOLLA_TAG%%/} img_dirs[$image]=$img_dir dependency[$image]=$base_image diff --git a/tools/build-docker-image b/tools/build-docker-image index adffdf8754..974c5a5eb9 100755 --- a/tools/build-docker-image +++ b/tools/build-docker-image @@ -7,6 +7,7 @@ RELEASE_NAMESPACE=kollaglue NAMESPACE=kollaglue PREFIX=centos-rdo- TAG=$(git rev-parse --short HEAD) +RELEASE_TAG=icehouse usage () { cat <&2; exit 2; } +ARGS=$(getopt -o hn:t:pN -l help,namespace:,push,release,tag:,no-cache,no-use-released-parent -- "$@") || { usage >&2; exit 2; } eval set -- "$ARGS" @@ -38,7 +40,7 @@ while :; do (--release) MODE=release NAMESPACE=$RELEASE_NAMESPACE - TAG=latest + TAG=$RELEASE_TAG ;; (--tag|-t) shift @@ -57,6 +59,10 @@ while :; do NAMESPACE="$1" ;; + (--no-use-released-parent) + USE_CURRENT_TAG=1 + ;; + (--) break ;; @@ -65,8 +71,14 @@ while :; do shift done +if [[ $USE_CURRENT_TAG = 1 ]]; then + PARENT_TAG=$TAG +else + PARENT_TAG=$RELEASE_TAG +fi + if [ "$NAMESPACE" = "$RELEASE_NAMESPACE" ] \ - && [ "$TAG" = "latest" ] \ + && [ "$TAG" = "$RELEASE_TAG" ] \ && ! [ "$MODE" = "release" ]; then echo "ERROR: use --release to build a release image" >&2 @@ -94,6 +106,7 @@ cp -aL $IMGDIR/* $TMPDIR # 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 if ! docker build ${BUILDFLAGS} -t "$FULLIMAGE" $TMPDIR; then echo "ERROR: failed to build $FULLIMAGE"