X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/5c1410e60eb06769207dbafd77501bf2fa45a29b..84b30d024ee757e32af7e05d00bf4324513c388c:/build/run-build-docker-jobs-image.sh diff --git a/build/run-build-docker-jobs-image.sh b/build/run-build-docker-jobs-image.sh index 15f788163e..83bb5ae716 100755 --- a/build/run-build-docker-jobs-image.sh +++ b/build/run-build-docker-jobs-image.sh @@ -1,22 +1,25 @@ #!/bin/bash +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 function usage { echo >&2 echo >&2 "usage: $0 [options]" echo >&2 echo >&2 "$0 options:" - echo >&2 " -t, --tags [csv_tags] comma separated tags" + echo >&2 " -t, --tags version tag for docker" echo >&2 " -u, --upload Upload the images (docker push)" + echo >&2 " --no-cache Don't use build cache" echo >&2 " -h, --help Display this help and exit" echo >&2 echo >&2 " If no options are given, just builds the images." } - upload=false # NOTE: This requires GNU getopt (part of the util-linux package on Debian-based distros). TEMP=`getopt -o hut: \ - --long help,upload,tags: \ + --long help,upload,no-cache,tags: \ -n "$0" -- "$@"` if [ $? != 0 ] ; then echo "Use -h for help"; exit 1 ; fi @@ -30,6 +33,10 @@ do upload=true shift ;; + --no-cache) + NOCACHE=--no-cache + shift + ;; -t | --tags) case "$2" in "") @@ -38,7 +45,7 @@ do exit 1 ;; *) - tags=$2; + version_tag="$2"; shift 2 ;; esac @@ -66,14 +73,6 @@ COLUMNS=80 . $WORKSPACE/build/run-library.sh docker_push () { - if [[ ! -z "$tags" ]] - then - for tag in $( echo $tags|tr "," " " ) - do - $DOCKER tag $1 $1:$tag - done - fi - # Sometimes docker push fails; retry it a few times if necessary. for i in `seq 1 5`; do $DOCKER push $* @@ -118,19 +117,44 @@ timer_reset # clean up the docker build environment cd "$WORKSPACE" -cd docker -rm -f jobs-image -rm -f config.yml -# Get test config.yml file -cp $HOME/docker/config.yml . +if [[ -z "$ARVADOS_BUILDING_VERSION" ]] && ! [[ -z "$version_tag" ]]; then + ARVADOS_BUILDING_VERSION="$version_tag" + ARVADOS_BUILDING_ITERATION="1" +fi + +python_sdk_ts=$(cd sdk/python && timestamp_from_git) +cwl_runner_ts=$(cd sdk/cwl && timestamp_from_git) -if [[ ! -z "$tags" ]]; then - COMMIT=${tags/,*/} ./build.sh jobs-image +python_sdk_version=$(cd sdk/python && nohash_version_from_git 0.1) +cwl_runner_version=$(cd sdk/cwl && nohash_version_from_git 1.0) + +if [[ $python_sdk_ts -gt $cwl_runner_ts ]]; then + cwl_runner_version=$(cd sdk/python && nohash_version_from_git 1.0) +fi + +echo cwl_runner_version $cwl_runner_version python_sdk_version $python_sdk_version + +if [[ "${python_sdk_version}" != "${ARVADOS_BUILDING_VERSION}" ]]; then + python_sdk_version="${python_sdk_version}-2" +else + python_sdk_version="${ARVADOS_BUILDING_VERSION}-${ARVADOS_BUILDING_ITERATION}" +fi + +cwl_runner_version_orig=$cwl_runner_version + +if [[ "${cwl_runner_version}" != "${ARVADOS_BUILDING_VERSION}" ]]; then + cwl_runner_version="${cwl_runner_version}-4" else - ./build.sh jobs-image + cwl_runner_version="${ARVADOS_BUILDING_VERSION}-${ARVADOS_BUILDING_ITERATION}" fi +cd docker/jobs +docker build $NOCACHE \ + --build-arg python_sdk_version=${python_sdk_version} \ + --build-arg cwl_runner_version=${cwl_runner_version} \ + -t arvados/jobs:$cwl_runner_version_orig . + ECODE=$? if [[ "$ECODE" != "0" ]]; then @@ -140,19 +164,49 @@ fi checkexit $ECODE "docker build" title "docker build complete (`timer`)" +if [[ "$ECODE" != "0" ]]; then + exit_cleanly +fi + +timer_reset + +if docker --version |grep " 1\.[0-9]\." ; then + # Docker version prior 1.10 require -f flag + # -f flag removed in Docker 1.12 + FORCE=-f +fi +if ! [[ -z "$version_tag" ]]; then + docker tag $FORCE arvados/jobs:$cwl_runner_version_orig arvados/jobs:"$version_tag" +else + docker tag $FORCE arvados/jobs:$cwl_runner_version_orig arvados/jobs:latest +fi + +ECODE=$? + +if [[ "$ECODE" != "0" ]]; then + EXITCODE=$(($EXITCODE + $ECODE)) +fi + +checkexit $ECODE "docker tag" +title "docker tag complete (`timer`)" + title "uploading images" timer_reset if [[ "$ECODE" != "0" ]]; then - title "upload arvados images SKIPPED because build failed" + title "upload arvados images SKIPPED because build or tag failed" else - if [[ $upload == true ]]; then - ## 20150526 nico -- *sometimes* dockerhub needs re-login + if [[ $upload == true ]]; then + ## 20150526 nico -- *sometimes* dockerhub needs re-login ## even though credentials are already in .dockercfg docker login -u arvados - - docker_push arvados/jobs + if ! [[ -z "$version_tag" ]]; then + docker_push arvados/jobs:"$version_tag" + else + docker_push arvados/jobs:$cwl_runner_version_orig + docker_push arvados/jobs:latest + fi title "upload arvados images finished (`timer`)" else title "upload arvados images SKIPPED because no --upload option set (`timer`)"