2 # Copyright (C) The Arvados Authors. All rights reserved.
4 # SPDX-License-Identifier: AGPL-3.0
8 echo >&2 "usage: WORKSPACE=/path/to/arvados $0 [options]"
10 echo >&2 "$0 options:"
11 echo >&2 " -t, --tags version tag for docker"
12 echo >&2 " -r, --repo Arvados package repo to use: dev (default), testing, stable"
13 echo >&2 " -u, --upload Upload the images (docker push)"
14 echo >&2 " --no-cache Don't use build cache"
15 echo >&2 " -h, --help Display this help and exit"
17 echo >&2 " WORKSPACE=path Path to the Arvados source tree to build from"
23 # NOTE: This requires GNU getopt (part of the util-linux package on Debian-based distros).
24 TEMP=`getopt -o hut:r: \
25 --long help,upload,no-cache,tags:,repo: \
28 if [ $? != 0 ] ; then echo "Use -h for help"; exit 1 ; fi
29 # Note the quotes around `$TEMP': they are essential!
46 echo "ERROR: --tags needs a parameter";
59 echo "ERROR: --repo needs a parameter";
89 if ! [[ -n "$WORKSPACE" ]]; then
91 echo >&2 "Error: WORKSPACE environment variable not set"
99 . $WORKSPACE/build/run-library.sh
102 # Sometimes docker push fails; retry it a few times if necessary.
103 for i in `seq 1 5`; do
106 if [[ "$ECODE" == "0" ]]; then
111 if [[ "$ECODE" != "0" ]]; then
112 EXITCODE=$(($EXITCODE + $ECODE))
114 checkexit $ECODE "docker push $*"
117 # find the docker binary
118 DOCKER=`which docker.io`
120 if [[ "$DOCKER" == "" ]]; then
121 DOCKER=`which docker`
124 if [[ "$DOCKER" == "" ]]; then
125 title "Error: you need to have docker installed. Could not find the docker executable."
130 title "Starting docker build"
134 # clean up the docker build environment
137 if [[ -z "$ARVADOS_BUILDING_VERSION" ]] && ! [[ -z "$version_tag" ]]; then
138 ARVADOS_BUILDING_VERSION="$version_tag"
139 ARVADOS_BUILDING_ITERATION="1"
142 calculate_python_sdk_cwl_package_versions
144 echo cwl_runner_version $cwl_runner_version python_sdk_version $python_sdk_version
146 if [[ "${python_sdk_version}" != "${ARVADOS_BUILDING_VERSION}" ]]; then
147 python_sdk_version="${python_sdk_version}-1"
149 python_sdk_version="${ARVADOS_BUILDING_VERSION}-${ARVADOS_BUILDING_ITERATION}"
152 cwl_runner_version_orig=$cwl_runner_version
154 if [[ "${cwl_runner_version}" != "${ARVADOS_BUILDING_VERSION}" ]]; then
155 cwl_runner_version="${cwl_runner_version}-1"
157 cwl_runner_version="${ARVADOS_BUILDING_VERSION}-${ARVADOS_BUILDING_ITERATION}"
161 docker build $NOCACHE \
162 --build-arg python_sdk_version=${python_sdk_version} \
163 --build-arg cwl_runner_version=${cwl_runner_version} \
164 --build-arg repo_version=${REPO} \
165 -t arvados/jobs:$cwl_runner_version_orig .
169 if [[ "$ECODE" != "0" ]]; then
170 EXITCODE=$(($EXITCODE + $ECODE))
173 checkexit $ECODE "docker build"
174 title "docker build complete (`timer`)"
176 if [[ "$ECODE" != "0" ]]; then
182 if docker --version |grep " 1\.[0-9]\." ; then
183 # Docker version prior 1.10 require -f flag
184 # -f flag removed in Docker 1.12
188 #docker export arvados/jobs:$cwl_runner_version_orig | docker import - arvados/jobs:$cwl_runner_version_orig
190 if ! [[ -z "$version_tag" ]]; then
191 docker tag $FORCE arvados/jobs:$cwl_runner_version_orig arvados/jobs:"$version_tag"
193 docker tag $FORCE arvados/jobs:$cwl_runner_version_orig arvados/jobs:latest
198 if [[ "$ECODE" != "0" ]]; then
199 EXITCODE=$(($EXITCODE + $ECODE))
202 checkexit $ECODE "docker tag"
203 title "docker tag complete (`timer`)"
205 title "uploading images"
209 if [[ "$ECODE" != "0" ]]; then
210 title "upload arvados images SKIPPED because build or tag failed"
212 if [[ $upload == true ]]; then
213 ## 20150526 nico -- *sometimes* dockerhub needs re-login
214 ## even though credentials are already in .dockercfg
215 docker login -u arvados
216 if ! [[ -z "$version_tag" ]]; then
217 docker_push arvados/jobs:"$version_tag"
219 docker_push arvados/jobs:$cwl_runner_version_orig
220 docker_push arvados/jobs:latest
222 title "upload arvados images finished (`timer`)"
224 title "upload arvados images SKIPPED because no --upload option set (`timer`)"