2 # Copyright (C) The Arvados Authors. All rights reserved.
4 # SPDX-License-Identifier: AGPL-3.0
8 echo >&2 "usage: $0 [options]"
10 echo >&2 "$0 options:"
11 echo >&2 " -t, --tags [csv_tags] comma separated tags"
12 echo >&2 " -i, --images [dev,demo] Choose which images to build (default: dev and demo)"
13 echo >&2 " -u, --upload Upload the images (docker push)"
14 echo >&2 " -h, --help Display this help and exit"
16 echo >&2 " If no options are given, just builds the images."
22 # NOTE: This requires GNU getopt (part of the util-linux package on Debian-based distros).
23 TEMP=`getopt -o hut:i: \
24 --long help,upload,tags:,images: \
27 if [ $? != 0 ] ; then echo "Use -h for help"; exit 1 ; fi
28 # Note the quotes around `$TEMP': they are essential!
41 echo "ERROR: --images needs a parameter";
54 echo "ERROR: --tags needs a parameter";
81 printf "\n%*s\n\n" $(((${#title}+$COLUMNS)/2)) "********** $1 **********"
85 # docker always creates a local 'latest' tag, and we don't want to push that
86 # tag in every case. Remove it.
89 GITHEAD=$(cd $WORKSPACE && git log --format=%H -n1 HEAD)
93 for tag in $( echo $tags|tr "," " " )
95 $DOCKER tag $1:$GITHEAD $1:$tag
99 # Sometimes docker push fails; retry it a few times if necessary.
100 for i in `seq 1 5`; do
103 if [[ "$ECODE" == "0" ]]; then
108 if [[ "$ECODE" != "0" ]]; then
109 title "!!!!!! docker push $* failed !!!!!!"
110 EXITCODE=$(($EXITCODE + $ECODE))
119 echo -n "$(($SECONDS - $t0))s"
123 if ! [[ -n "$WORKSPACE" ]]; then
125 echo >&2 "Error: WORKSPACE environment variable not set"
132 # find the docker binary
133 DOCKER=`which docker.io`
135 if [[ "$DOCKER" == "" ]]; then
136 DOCKER=`which docker`
139 if [[ "$DOCKER" == "" ]]; then
140 title "Error: you need to have docker installed. Could not find the docker executable."
145 title "Starting docker build"
149 # clean up the docker build environment
152 if [[ "$images" =~ demo ]]; then
153 title "Starting arvbox build localdemo"
155 tools/arvbox/bin/arvbox build localdemo
158 if [[ "$ECODE" != "0" ]]; then
159 title "!!!!!! docker BUILD FAILED !!!!!!"
160 EXITCODE=$(($EXITCODE + $ECODE))
164 if [[ "$images" =~ dev ]]; then
165 title "Starting arvbox build dev"
167 tools/arvbox/bin/arvbox build dev
171 if [[ "$ECODE" != "0" ]]; then
172 title "!!!!!! docker BUILD FAILED !!!!!!"
173 EXITCODE=$(($EXITCODE + $ECODE))
177 title "docker build complete (`timer`)"
179 if [[ "$EXITCODE" != "0" ]]; then
180 title "upload arvados images SKIPPED because build failed"
182 if [[ $upload == true ]]; then
183 title "uploading images"
186 ## 20150526 nico -- *sometimes* dockerhub needs re-login
187 ## even though credentials are already in .dockercfg
188 docker login -u arvados
190 if [[ "$images" =~ dev ]]; then
191 docker_push arvados/arvbox-dev
193 if [[ "$images" =~ demo ]]; then
194 docker_push arvados/arvbox-demo
196 title "upload arvados images complete (`timer`)"
198 title "upload arvados images SKIPPED because no --upload option set"