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 version tag for docker"
12 echo >&2 " -u, --upload Upload the images (docker push)"
13 echo >&2 " --no-cache Don't use build cache"
14 echo >&2 " -h, --help Display this help and exit"
16 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";
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)
125 cwl_runner_version=$(cd sdk/cwl && nohash_version_from_git 1.0)
127 if [[ $python_sdk_ts -gt $cwl_runner_ts ]]; then
128 cwl_runner_version=$(cd sdk/python && nohash_version_from_git 1.0)
131 echo cwl_runner_version $cwl_runner_version python_sdk_version $python_sdk_version
134 docker build $NOCACHE \
135 --build-arg python_sdk_version=${python_sdk_version}-2 \
136 --build-arg cwl_runner_version=${cwl_runner_version}-3 \
137 -t arvados/jobs:$cwl_runner_version .
141 if [[ "$ECODE" != "0" ]]; then
142 EXITCODE=$(($EXITCODE + $ECODE))
145 checkexit $ECODE "docker build"
146 title "docker build complete (`timer`)"
148 if [[ "$ECODE" != "0" ]]; then
154 if docker --version |grep " 1\.[0-9]\." ; then
155 # Docker version prior 1.10 require -f flag
156 # -f flag removed in Docker 1.12
159 if ! [[ -z "$version_tag" ]]; then
160 docker tag $FORCE arvados/jobs:$cwl_runner_version arvados/jobs:"$version_tag"
162 docker tag $FORCE arvados/jobs:$cwl_runner_version 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
185 if ! [[ -z "$version_tag" ]]; then
186 docker_push arvados/jobs:"$version_tag"
188 docker_push arvados/jobs:$cwl_runner_version
189 docker_push arvados/jobs:latest
191 title "upload arvados images finished (`timer`)"
193 title "upload arvados images SKIPPED because no --upload option set (`timer`)"