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 for tag in $(echo $tags|tr "," " " )
101 # Sometimes docker push fails; retry it a few times if necessary.
102 for i in `seq 1 5`; do
105 if [[ "$ECODE" == "0" ]]; then
110 if [[ "$ECODE" != "0" ]]; then
111 title "!!!!!! docker push $1:$tag failed !!!!!!"
112 EXITCODE=$(($EXITCODE + $ECODE))
122 echo -n "$(($SECONDS - $t0))s"
126 if ! [[ -n "$WORKSPACE" ]]; then
128 echo >&2 "Error: WORKSPACE environment variable not set"
135 # find the docker binary
136 DOCKER=`which docker.io`
138 if [[ "$DOCKER" == "" ]]; then
139 DOCKER=`which docker`
142 if [[ "$DOCKER" == "" ]]; then
143 title "Error: you need to have docker installed. Could not find the docker executable."
148 title "Starting docker build"
152 # clean up the docker build environment
155 if [[ "$images" =~ demo ]]; then
156 title "Starting arvbox build localdemo"
158 tools/arvbox/bin/arvbox build localdemo
161 if [[ "$ECODE" != "0" ]]; then
162 title "!!!!!! docker BUILD FAILED !!!!!!"
163 EXITCODE=$(($EXITCODE + $ECODE))
167 if [[ "$images" =~ dev ]]; then
168 title "Starting arvbox build dev"
170 tools/arvbox/bin/arvbox build dev
174 if [[ "$ECODE" != "0" ]]; then
175 title "!!!!!! docker BUILD FAILED !!!!!!"
176 EXITCODE=$(($EXITCODE + $ECODE))
180 title "docker build complete (`timer`)"
182 if [[ "$EXITCODE" != "0" ]]; then
183 title "upload arvados images SKIPPED because build failed"
185 if [[ $upload == true ]]; then
186 title "uploading images"
189 ## 20150526 nico -- *sometimes* dockerhub needs re-login
190 ## even though credentials are already in .dockercfg
191 docker login -u arvados
193 if [[ "$images" =~ dev ]]; then
194 docker_push arvados/arvbox-dev
196 if [[ "$images" =~ demo ]]; then
197 docker_push arvados/arvbox-demo
199 title "upload arvados images complete (`timer`)"
201 title "upload arvados images SKIPPED because no --upload option set"