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 **********"
87 for tag in $( echo $tags|tr "," " " )
89 $DOCKER tag $1 $1:$tag
93 # Sometimes docker push fails; retry it a few times if necessary.
94 for i in `seq 1 5`; do
97 if [[ "$ECODE" == "0" ]]; then
102 if [[ "$ECODE" != "0" ]]; then
103 title "!!!!!! docker push $* failed !!!!!!"
104 EXITCODE=$(($EXITCODE + $ECODE))
113 echo -n "$(($SECONDS - $t0))s"
117 if ! [[ -n "$WORKSPACE" ]]; then
119 echo >&2 "Error: WORKSPACE environment variable not set"
126 # find the docker binary
127 DOCKER=`which docker.io`
129 if [[ "$DOCKER" == "" ]]; then
130 DOCKER=`which docker`
133 if [[ "$DOCKER" == "" ]]; then
134 title "Error: you need to have docker installed. Could not find the docker executable."
139 title "Starting docker build"
143 # clean up the docker build environment
146 if [[ "$images" =~ demo ]]; then
147 title "Starting arvbox build localdemo"
149 tools/arvbox/bin/arvbox build localdemo
152 if [[ "$ECODE" != "0" ]]; then
153 title "!!!!!! docker BUILD FAILED !!!!!!"
154 EXITCODE=$(($EXITCODE + $ECODE))
158 if [[ "$images" =~ dev ]]; then
159 title "Starting arvbox build dev"
161 tools/arvbox/bin/arvbox build dev
165 if [[ "$ECODE" != "0" ]]; then
166 title "!!!!!! docker BUILD FAILED !!!!!!"
167 EXITCODE=$(($EXITCODE + $ECODE))
171 title "docker build complete (`timer`)"
173 if [[ "$EXITCODE" != "0" ]]; then
174 title "upload arvados images SKIPPED because build failed"
176 if [[ $upload == true ]]; then
177 title "uploading images"
180 ## 20150526 nico -- *sometimes* dockerhub needs re-login
181 ## even though credentials are already in .dockercfg
182 docker login -u arvados
184 if [[ "$images" =~ dev ]]; then
185 docker_push arvados/arvbox-dev
187 if [[ "$images" =~ demo ]]; then
188 docker_push arvados/arvbox-demo
190 title "upload arvados images complete (`timer`)"
192 title "upload arvados images SKIPPED because no --upload option set"