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.
90 for tag in $( echo $tags|tr "," " " )
92 $DOCKER tag $1 $1:$tag
96 # Sometimes docker push fails; retry it a few times if necessary.
97 for i in `seq 1 5`; do
100 if [[ "$ECODE" == "0" ]]; then
105 if [[ "$ECODE" != "0" ]]; then
106 title "!!!!!! docker push $* failed !!!!!!"
107 EXITCODE=$(($EXITCODE + $ECODE))
116 echo -n "$(($SECONDS - $t0))s"
120 if ! [[ -n "$WORKSPACE" ]]; then
122 echo >&2 "Error: WORKSPACE environment variable not set"
129 # find the docker binary
130 DOCKER=`which docker.io`
132 if [[ "$DOCKER" == "" ]]; then
133 DOCKER=`which docker`
136 if [[ "$DOCKER" == "" ]]; then
137 title "Error: you need to have docker installed. Could not find the docker executable."
142 title "Starting docker build"
146 # clean up the docker build environment
149 if [[ "$images" =~ demo ]]; then
150 title "Starting arvbox build localdemo"
152 tools/arvbox/bin/arvbox build localdemo
155 if [[ "$ECODE" != "0" ]]; then
156 title "!!!!!! docker BUILD FAILED !!!!!!"
157 EXITCODE=$(($EXITCODE + $ECODE))
161 if [[ "$images" =~ dev ]]; then
162 title "Starting arvbox build dev"
164 tools/arvbox/bin/arvbox build dev
168 if [[ "$ECODE" != "0" ]]; then
169 title "!!!!!! docker BUILD FAILED !!!!!!"
170 EXITCODE=$(($EXITCODE + $ECODE))
174 title "docker build complete (`timer`)"
176 if [[ "$EXITCODE" != "0" ]]; then
177 title "upload arvados images SKIPPED because build failed"
179 if [[ $upload == true ]]; then
180 title "uploading images"
183 ## 20150526 nico -- *sometimes* dockerhub needs re-login
184 ## even though credentials are already in .dockercfg
185 docker login -u arvados
187 if [[ "$images" =~ dev ]]; then
188 docker_push arvados/arvbox-dev
190 if [[ "$images" =~ demo ]]; then
191 docker_push arvados/arvbox-demo
193 title "upload arvados images complete (`timer`)"
195 title "upload arvados images SKIPPED because no --upload option set"