From 2844a2510249a200f87d8d173ce5da9f1361757c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Andr=C3=A9?= <martin.andre@kvhasia.com> Date: Tue, 26 May 2015 10:59:49 +0900 Subject: [PATCH] Always provide a tag when building with build-all-docker-images When we're not providing a tag, the build script will use one based on the short SHA of the tip of the current git branch. Make the `build-all-docker-images` script always provide a tag to `build-docker-image` in order to prevent issues with Docker not being able to find the base image when changing branches during an ongoing build. Closes-Bug: #1458739 Change-Id: Id6925b792f46d14b20a7dbebfaf0d351ddec6538 --- tools/build-all-docker-images | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tools/build-all-docker-images b/tools/build-all-docker-images index ed8c526da6..945fd2480c 100755 --- a/tools/build-all-docker-images +++ b/tools/build-all-docker-images @@ -146,7 +146,7 @@ trap 'interrupted' INT ARGS=$@ -PARSED_ARGS=$(getopt -q -o hr:n: -l help,namespace:,private-registry:,from:,to:,testmode -- "$@") +PARSED_ARGS=$(getopt -q -o hr:n:t: -l help,namespace:,release,tag:,private-registry:,from:,to:,testmode -- "$@") eval set -- "$PARSED_ARGS" @@ -162,6 +162,15 @@ while :; do FORCE_NAMESPACE="$1" ;; + (--release) + RELEASE_SPECIFIED=1 + ;; + + (--tag|-t) + shift + TAG_SPECIFIED=1 + ;; + (--private-registry|-r) shift REGISTRY="$1" @@ -199,6 +208,12 @@ BASE=$(echo "${PREFIX}" | cut -d- -f1) # TYPE == binary, source, rdo TYPE=$(echo "${PREFIX}" | cut -d- -f2) +# Ensure a tag is specified otherwise build may fail when changing git branch +# The release tag is automatically appended when --release flag is used. +if [[ $RELEASE_SPECIFIED != 1 ]] && [[ $TAG_SPECIFIED != 1 ]]; then + TAG=$(git rev-parse --short HEAD) + ARGS+=" --tag $TAG" +fi # Do a first pass to find images to build and their dependencies for dockerfile in $(find "${DOCKERDIR}/${BASE}/${TYPE}" -name Dockerfile); do