Merge branch '11807-yaml-to-json'
[arvados.git] / build / build-dev-docker-jobs-image.sh
1 #!/bin/bash
2 # Copyright (C) The Arvados Authors. All rights reserved.
3 #
4 # SPDX-License-Identifier: AGPL-3.0
5
6 read -rd "\000" helpmessage <<EOF
7 Build an arvados/jobs Docker image from local git tree.
8
9 Intended for use by developers working on arvados-python-client or
10 arvados-cwl-runner and need to run a crunch job with a custom package
11 version.  Also supports building custom cwltool if CWLTOOL is set.
12
13 Syntax:
14         WORKSPACE=/path/to/arvados $(basename $0)
15
16 WORKSPACE=path         Path to the Arvados source tree to build packages from
17 CWLTOOL=path           (optional) Path to cwltool git repository.
18
19 EOF
20
21 set -e
22
23 if [[ -z "$WORKSPACE" ]] ; then
24     echo "$helpmessage"
25     echo
26     echo "Must set WORKSPACE"
27     exit 1
28 fi
29
30 if [[ -z "$ARVADOS_API_HOST" || -z "$ARVADOS_API_TOKEN" ]] ; then
31     echo "$helpmessage"
32     echo
33     echo "Must set ARVADOS_API_HOST and ARVADOS_API_TOKEN"
34     exit 1
35 fi
36
37 cd "$WORKSPACE"
38
39 (cd sdk/python && python setup.py sdist)
40 sdk=$(cd sdk/python/dist && ls -t arvados-python-client-*.tar.gz | head -n1)
41
42 (cd sdk/cwl && python setup.py sdist)
43 runner=$(cd sdk/cwl/dist && ls -t arvados-cwl-runner-*.tar.gz | head -n1)
44
45 rm -rf sdk/cwl/cwltool_dist
46 mkdir -p sdk/cwl/cwltool_dist
47 if [[ -n "$CWLTOOL" ]] ; then
48     (cd "$CWLTOOL" && python setup.py sdist)
49     cwltool=$(cd "$CWLTOOL/dist" && ls -t cwltool-*.tar.gz | head -n1)
50     cp "$CWLTOOL/dist/$cwltool" $WORKSPACE/sdk/cwl/cwltool_dist
51 fi
52
53 . build/run-library.sh
54
55 python_sdk_ts=$(cd sdk/python && timestamp_from_git)
56 cwl_runner_ts=$(cd sdk/cwl && timestamp_from_git)
57
58 if [[ $python_sdk_ts -gt $cwl_runner_ts ]]; then
59     gittag=$(git log --first-parent --max-count=1 --format=format:%H sdk/python)
60 else
61     gittag=$(git log --first-parent --max-count=1 --format=format:%H sdk/cwl)
62 fi
63
64 docker build --build-arg sdk=$sdk --build-arg runner=$runner --build-arg cwltool=$cwltool -f "$WORKSPACE/sdk/dev-jobs.dockerfile" -t arvados/jobs:$gittag "$WORKSPACE/sdk"
65 echo arv-keepdocker arvados/jobs $gittag
66 arv-keepdocker arvados/jobs $gittag