15370: Fix flaky test.
[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 SALAD=path             (optional) Path to schema_salad git repository.
19 PYCMD=pythonexec       (optional) Specify the python3 executable to use in the docker image. Defaults to "python3".
20
21 EOF
22
23 set -e
24
25 if [[ -z "$WORKSPACE" ]] ; then
26     export WORKSPACE=$(readlink -f $(dirname $0)/..)
27     echo "Using WORKSPACE $WORKSPACE"
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 py=python3
40 pipcmd=pip
41 if [[ -n "$PYCMD" ]] ; then
42     py="$PYCMD"
43 fi
44 if [[ $py = python3 ]] ; then
45     pipcmd=pip3
46 fi
47
48 (cd sdk/python && python3 setup.py sdist)
49 sdk=$(cd sdk/python/dist && ls -t arvados-python-client-*.tar.gz | head -n1)
50
51 (cd sdk/cwl && python3 setup.py sdist)
52 runner=$(cd sdk/cwl/dist && ls -t arvados-cwl-runner-*.tar.gz | head -n1)
53
54 rm -rf sdk/cwl/salad_dist
55 mkdir -p sdk/cwl/salad_dist
56 if [[ -n "$SALAD" ]] ; then
57     (cd "$SALAD" && python3 setup.py sdist)
58     salad=$(cd "$SALAD/dist" && ls -t schema-salad-*.tar.gz | head -n1)
59     cp "$SALAD/dist/$salad" $WORKSPACE/sdk/cwl/salad_dist
60 fi
61
62 rm -rf sdk/cwl/cwltool_dist
63 mkdir -p sdk/cwl/cwltool_dist
64 if [[ -n "$CWLTOOL" ]] ; then
65     (cd "$CWLTOOL" && python3 setup.py sdist)
66     cwltool=$(cd "$CWLTOOL/dist" && ls -t cwltool-*.tar.gz | head -n1)
67     cp "$CWLTOOL/dist/$cwltool" $WORKSPACE/sdk/cwl/cwltool_dist
68 fi
69
70 . build/run-library.sh
71
72 # This defines python_sdk_version and cwl_runner_version with python-style
73 # package suffixes (.dev/rc)
74 calculate_python_sdk_cwl_package_versions
75
76 set -x
77 docker build --no-cache --build-arg sdk=$sdk --build-arg runner=$runner --build-arg salad=$salad --build-arg cwltool=$cwltool --build-arg pythoncmd=$py --build-arg pipcmd=$pipcmd -f "$WORKSPACE/sdk/dev-jobs.dockerfile" -t arvados/jobs:$cwl_runner_version "$WORKSPACE/sdk"
78 echo arv-keepdocker arvados/jobs $cwl_runner_version
79 arv-keepdocker arvados/jobs $cwl_runner_version