-
Notifications
You must be signed in to change notification settings - Fork 7
/
reslang-docker.sh
executable file
·60 lines (43 loc) · 1.41 KB
/
reslang-docker.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env bash
set -eu
RESLANG_IMG=gcr.io/liveramp-eng/reslang:master
usage() {
cat <<USAGE
Usage: run a Reslang container image on a specified directory.
$ $0 RESLANG_DIR [ OPTS ...]
Examples:
$ $0 /abs/path/to/reslang_directory
$ $0 /abs/path/to/reslang_directory --diagram diagram_name
OPTS: The following options will **not** work with this script:
--web, --open, --stripped, --testwrite, --testdir
To use those options, please run reslang un-containerized.
USAGE
exit "$1"
}
# is_absolute_path indicates if a string is prefixed with a leading slash.
# It returns a 0 (success) code if the path is absolute, else 1 (error).
# $1 : string
is_absolute_path() {
case "$1" in
/*) return 0 ;;
*) return 1 ;;
esac
}
# Run a reslang container on a user-specified directory.
# NOTE: The reslang directory's parent is mounted into the container, so that
# it can access imported resources from peers. In reslang, all imports refer
# to peer directories.
main() {
if [ "$#" -lt 1 ]; then usage 1 ; fi
local host_path; local workspace;
host_path="$1" ; shift ;
parent_dir="$(dirname "$host_path")"
workspace=/app/reslang/workspace/
if ! is_absolute_path "$host_path"; then
printf "error: expected absolute path, got %s\n" "$host_path"
usage 1
fi
docker run -v "$parent_dir":"$workspace" "$RESLANG_IMG" \
"$workspace"/"$(basename "$host_path")" --stdout "$@"
}
main "$@"