forked from caraml-dev/turing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-entrypoint.sh
executable file
·70 lines (58 loc) · 1.58 KB
/
docker-entrypoint.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
61
62
63
64
65
66
67
68
69
#!/bin/bash
set -e
CMD=()
TURING_UI_CONFIG_PATH=
TURING_UI_DIST_DIR=${TURING_UI_DIST_DIR:-}
TURING_UI_DIST_CONFIG_FILE=${TURING_UI_DIST_DIR}/app.config.js
TURING_API_BIN=${TURING_API_BIN:?"ERROR: TURING_API_BIN is not specified"}
show_help() {
cat <<EOF
Usage: $(basename "$0") <options> <...>
-ui-config JSON file containing configuration of Turing UI
EOF
}
main(){
parse_command_line "$@"
if [[ -n "$TURING_UI_CONFIG_PATH" ]]; then
echo "Turing UI config found at ${TURING_UI_CONFIG_PATH}..."
if [[ -n "$TURING_UI_DIST_DIR" ]]; then
echo "Overriding UI config at $TURING_UI_DIST_CONFIG_FILE"
echo "var config = $(cat $TURING_UI_CONFIG_PATH);" > "$TURING_UI_DIST_CONFIG_FILE"
echo "Done."
else
echo "TURING_UI_DIST_DIR: Turing UI static build directory not provided. Skipping."
fi
else
echo "Turing UI config is not provided. Skipping."
fi
}
parse_command_line(){
while [[ $# -gt 0 ]]; do
case "$1" in
-ui-config)
if [[ -n "$2" ]]; then
TURING_UI_CONFIG_PATH="$2"
shift
else
echo "ERROR: '-ui-config' cannot be empty." >&2
show_help
exit 1
fi
;;
*)
CMD+=("$1")
;;
esac
shift
done
if [[ -n "$TURING_UI_CONFIG_PATH" ]]; then
if [ ! -f "$TURING_UI_CONFIG_PATH" ]; then
echo "ERROR: config file $TURING_UI_CONFIG_PATH does not exist." >&2
show_help
exit 1
fi
fi
}
main "$@"
echo "Launching turing-api server: " "$TURING_API_BIN" "${CMD[@]}"
exec "$TURING_API_BIN" "${CMD[@]}"