Commit 9aecf0ea authored by Baptiste Mesta's avatar Baptiste Mesta Committed by GitHub
Browse files

chore(build): tag image directly with the right one on build (#368)

This change is done to avoid conflicts when building docker image in PRs (e.g. PR tag a
7.13.0-SNAPSHOT and dev does the same at the same time)

Add a new option `-t` on the `build.sh`. It takes in input a tag name
and it overrides the default tag (`bonitasoft/...:7.x.y-SNAPSHOT`)

This simplifies the build and push of image on `quay` (it avoid using an
intermediate tag)
parent da22c85f
......@@ -16,6 +16,7 @@ exit_with_usage() {
echo ""
echo "Options:"
echo " -a docker_build_args_file file to read docker build arguments from"
echo " -t tag_name tag the using using this name - by default bonitasoft/bonita:VERSION"
echo " -c use Docker cache while building image - by default build is performed with '--no-cache=true'"
echo ""
echo "Examples:"
......@@ -43,6 +44,13 @@ while [ "$#" -gt 0 ]; do
-c)
no_cache="false"
;;
-t)
shift
TAG_NAME=$1
if [ -z "TAG_NAME" ]; then
exit_with_usage "Option -t requires an argument."
fi
;;
--)
break
;;
......@@ -94,11 +102,16 @@ else
echo "BONITA_VERSION is passed in BUILD_ARGS parameters ($BUILD_ARGS), using it"
fi
IMAGE_NAME=bonitasoft/bonita
IMAGE_NAME_AND_BONITA_VERSION=${IMAGE_NAME}:${BONITA_VERSION}
if [ -n "$TAG_NAME" ]; then
IMAGE_NAME_AND_BONITA_VERSION="$TAG_NAME"
ALL_TAGS="-t $TAG_NAME"
else
IMAGE_NAME_AND_BONITA_VERSION="bonitasoft/bonita:${BONITA_VERSION}"
ALL_TAGS="-t ${IMAGE_NAME_AND_BONITA_VERSION}"
fi
echo ". Building image <${IMAGE_NAME_AND_BONITA_VERSION}>"
build_cmd="docker build ${BUILD_ARGS} -t ${IMAGE_NAME_AND_BONITA_VERSION} ."
build_cmd="docker build ${BUILD_ARGS} ${ALL_TAGS} ."
echo "Running command: '$build_cmd'"
eval "$build_cmd"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment