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 " -u, --upload Upload the images (docker push)"
13 echo >&2 " -h, --help Display this help and exit"
15 echo >&2 " If no options are given, just builds the images."
20 # NOTE: This requires GNU getopt (part of the util-linux package on Debian-based distros).
21 TEMP=`getopt -o hut: \
22 --long help,upload,tags: \
25 if [ $? != 0 ] ; then echo "Use -h for help"; exit 1 ; fi
26 # Note the quotes around `$TEMP': they are essential!
39 echo "ERROR: --tags needs a parameter";
66 printf "\n%*s\n\n" $(((${#title}+$COLUMNS)/2)) "********** $1 **********"
72 for tag in $( echo $tags|tr "," " " )
74 $DOCKER tag $1 $1:$tag
78 # Sometimes docker push fails; retry it a few times if necessary.
79 for i in `seq 1 5`; do
82 if [[ "$ECODE" == "0" ]]; then
87 if [[ "$ECODE" != "0" ]]; then
88 title "!!!!!! docker push $* failed !!!!!!"
89 EXITCODE=$(($EXITCODE + $ECODE))
98 echo -n "$(($SECONDS - $t0))s"
102 if ! [[ -n "$WORKSPACE" ]]; then
104 echo >&2 "Error: WORKSPACE environment variable not set"
111 # find the docker binary
112 DOCKER=`which docker.io`
114 if [[ "$DOCKER" == "" ]]; then
115 DOCKER=`which docker`
118 if [[ "$DOCKER" == "" ]]; then
119 title "Error: you need to have docker installed. Could not find the docker executable."
124 title "Starting docker build"
128 # clean up the docker build environment
131 tools/arvbox/bin/arvbox build localdemo
134 if [[ "$ECODE" != "0" ]]; then
135 title "!!!!!! docker BUILD FAILED !!!!!!"
136 EXITCODE=$(($EXITCODE + $ECODE))
139 tools/arvbox/bin/arvbox build dev
143 if [[ "$ECODE" != "0" ]]; then
144 title "!!!!!! docker BUILD FAILED !!!!!!"
145 EXITCODE=$(($EXITCODE + $ECODE))
148 title "docker build complete (`timer`)"
150 title "uploading images"
154 if [[ "$EXITCODE" != "0" ]]; then
155 title "upload arvados images SKIPPED because build failed"
157 if [[ $upload == true ]]; then
158 ## 20150526 nico -- *sometimes* dockerhub needs re-login
159 ## even though credentials are already in .dockercfg
160 docker login -u arvados
162 docker_push arvados/arvbox-dev
163 docker_push arvados/arvbox-demo
164 title "upload arvados images complete (`timer`)"
166 title "upload arvados images SKIPPED because no --upload option set"