Merge branch '21494-sdk-doc-build'
[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 CWL_UTILS=path         (optional) Path to cwl-utils git repository.
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 context_dir="$(mktemp --directory --tmpdir dev-jobs.XXXXXXXX)"
31 trap 'rm -rf "$context_dir"' EXIT INT TERM QUIT
32
33 for src_dir in "$WORKSPACE/sdk/python" "${CWLTOOL:-}" "${CWL_UTILS:-}" "${SALAD:-}" "$WORKSPACE/sdk/cwl"; do
34     if [[ -z "$src_dir" ]]; then
35         continue
36     fi
37     env -C "$src_dir" python3 setup.py sdist --dist-dir="$context_dir"
38 done
39
40 cd "$WORKSPACE"
41 . build/run-library.sh
42 # This defines python_sdk_version and cwl_runner_version with python-style
43 # package suffixes (.dev/rc)
44 calculate_python_sdk_cwl_package_versions
45
46 set -x
47 docker build --no-cache \
48        -f "$WORKSPACE/sdk/dev-jobs.dockerfile" \
49        -t arvados/jobs:$cwl_runner_version \
50        "$context_dir"
51
52 arv-keepdocker arvados/jobs $cwl_runner_version