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 " -u, --upload Upload the images (docker push)"
12 echo >&2 " --no-cache Don't use build cache"
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,no-cache,tags: \
25 if [ $? != 0 ] ; then echo "Use -h for help"; exit 1 ; fi
26 # Note the quotes around `$TEMP': they are essential!
43 echo "ERROR: --tags needs a parameter";
48 echo "WARNING: --tags is deprecated and doesn't do anything";
73 . $WORKSPACE/build/run-library.sh
76 # Sometimes docker push fails; retry it a few times if necessary.
77 for i in `seq 1 5`; do
80 if [[ "$ECODE" == "0" ]]; then
85 if [[ "$ECODE" != "0" ]]; then
86 EXITCODE=$(($EXITCODE + $ECODE))
88 checkexit $ECODE "docker push $*"
92 if ! [[ -n "$WORKSPACE" ]]; then
94 echo >&2 "Error: WORKSPACE environment variable not set"
101 # find the docker binary
102 DOCKER=`which docker.io`
104 if [[ "$DOCKER" == "" ]]; then
105 DOCKER=`which docker`
108 if [[ "$DOCKER" == "" ]]; then
109 title "Error: you need to have docker installed. Could not find the docker executable."
114 title "Starting docker build"
118 # clean up the docker build environment
121 python_sdk_ts=$(cd sdk/python && timestamp_from_git)
122 cwl_runner_ts=$(cd sdk/cwl && timestamp_from_git)
124 python_sdk_version=$(cd sdk/python && nohash_version_from_git 0.1)-2
125 cwl_runner_version=$(cd sdk/cwl && nohash_version_from_git 1.0)-3
127 if [[ $python_sdk_ts -gt $cwl_runner_ts ]]; then
128 cwl_runner_version=$(cd sdk/python && nohash_version_from_git 1.0)-3
129 gittag=$(git log --first-parent --max-count=1 --format=format:%H sdk/python)
131 gittag=$(git log --first-parent --max-count=1 --format=format:%H sdk/cwl)
134 echo cwl_runner_version $cwl_runner_version python_sdk_version $python_sdk_version
137 docker build $NOCACHE \
138 --build-arg python_sdk_version=$python_sdk_version \
139 --build-arg cwl_runner_version=$cwl_runner_version \
140 -t arvados/jobs:$gittag .
144 if [[ "$ECODE" != "0" ]]; then
145 EXITCODE=$(($EXITCODE + $ECODE))
148 checkexit $ECODE "docker build"
149 title "docker build complete (`timer`)"
151 if [[ "$ECODE" != "0" ]]; then
157 if docker --version |grep " 1\.[0-9]\." ; then
158 # Docker version prior 1.10 require -f flag
159 # -f flag removed in Docker 1.12
163 docker tag $FORCE arvados/jobs:$gittag arvados/jobs:latest
167 if [[ "$ECODE" != "0" ]]; then
168 EXITCODE=$(($EXITCODE + $ECODE))
171 checkexit $ECODE "docker tag"
172 title "docker tag complete (`timer`)"
174 title "uploading images"
178 if [[ "$ECODE" != "0" ]]; then
179 title "upload arvados images SKIPPED because build or tag failed"
181 if [[ $upload == true ]]; then
182 ## 20150526 nico -- *sometimes* dockerhub needs re-login
183 ## even though credentials are already in .dockercfg
184 docker login -u arvados
186 docker_push arvados/jobs:$gittag
187 docker_push arvados/jobs:latest
188 title "upload arvados images finished (`timer`)"
190 title "upload arvados images SKIPPED because no --upload option set (`timer`)"