5 echo >&2 "usage: $0 [options]"
8 echo >&2 " -u, --upload Upload the images (docker push)"
9 echo >&2 " --no-cache Don't use build cache"
10 echo >&2 " -h, --help Display this help and exit"
12 echo >&2 " If no options are given, just builds the images."
17 # NOTE: This requires GNU getopt (part of the util-linux package on Debian-based distros).
18 TEMP=`getopt -o hut: \
19 --long help,upload,no-cache,tags: \
22 if [ $? != 0 ] ; then echo "Use -h for help"; exit 1 ; fi
23 # Note the quotes around `$TEMP': they are essential!
40 echo "ERROR: --tags needs a parameter";
45 echo "WARNING: --tags is deprecated and doesn't do anything";
70 . $WORKSPACE/build/run-library.sh
73 # Sometimes docker push fails; retry it a few times if necessary.
74 for i in `seq 1 5`; do
77 if [[ "$ECODE" == "0" ]]; then
82 if [[ "$ECODE" != "0" ]]; then
83 EXITCODE=$(($EXITCODE + $ECODE))
85 checkexit $ECODE "docker push $*"
89 if ! [[ -n "$WORKSPACE" ]]; then
91 echo >&2 "Error: WORKSPACE environment variable not set"
98 # find the docker binary
99 DOCKER=`which docker.io`
101 if [[ "$DOCKER" == "" ]]; then
102 DOCKER=`which docker`
105 if [[ "$DOCKER" == "" ]]; then
106 title "Error: you need to have docker installed. Could not find the docker executable."
111 title "Starting docker build"
115 # clean up the docker build environment
118 python_sdk_ts=$(cd sdk/python && timestamp_from_git)
119 cwl_runner_ts=$(cd sdk/cwl && timestamp_from_git)
121 python_sdk_version=$(cd sdk/python && nohash_version_from_git 0.1)-2
122 cwl_runner_version=$(cd sdk/cwl && nohash_version_from_git 1.0)-3
124 if [[ $python_sdk_ts -gt $cwl_runner_ts ]]; then
125 cwl_runner_version=$(cd sdk/python && nohash_version_from_git 1.0)-3
126 gittag=$(cd sdk/python && git log --first-parent --max-count=1 --format=format:%H)
128 gittag=$(cd sdk/cwl && git log --first-parent --max-count=1 --format=format:%H)
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 \
136 --build-arg cwl_runner_version=$cwl_runner_version \
137 -t arvados/jobs:$gittag .
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
160 docker tag $FORCE arvados/jobs:$gittag arvados/jobs:latest
164 if [[ "$ECODE" != "0" ]]; then
165 EXITCODE=$(($EXITCODE + $ECODE))
168 checkexit $ECODE "docker tag"
169 title "docker tag complete (`timer`)"
171 title "uploading images"
175 if [[ "$ECODE" != "0" ]]; then
176 title "upload arvados images SKIPPED because build or tag failed"
178 if [[ $upload == true ]]; then
179 ## 20150526 nico -- *sometimes* dockerhub needs re-login
180 ## even though credentials are already in .dockercfg
181 docker login -u arvados
183 docker_push arvados/jobs:$gittag
184 docker_push arvados/jobs:latest
185 title "upload arvados images finished (`timer`)"
187 title "upload arvados images SKIPPED because no --upload option set (`timer`)"