-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart-db.sh
executable file
·67 lines (59 loc) · 1.22 KB
/
start-db.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
#!/bin/bash
set -e
set -o pipefail
usage() {
cat << EOF
Starts the database only.
Options:
-e <env> --environment <env> The database environment. Choices are: int, prod
-d --detach Detach and run in the background, sets -d for docker compose
-h --help Prints this help message and exits
EOF
}
# defaults
DETACH=false
# parameters
while [ -n "$1" ]; do
case $1 in
-e | --environment)
shift
ENVIRO=$1
;;
-d | --detach)
DETACH=true
;;
-h | --help)
usage
exit 0
;;
*)
echo -e "Unknown option $1...\n"
usage
exit 1
;;
esac
shift
done
case $ENVIRO in
int|prod)
ENVIRO_VALID=true
;;
*)
ENVIRO_VALID=false
echo "Please set environment with -e/--environment to one of: int, prod"
usage
exit 1
;;
esac
ADDITIONAL_OPTIONS=
if $DETACH; then
ADDITIONAL_OPTIONS="${ADDITIONAL_OPTIONS} --detach"
else
ADDITIONAL_OPTIONS="${ADDITIONAL_OPTIONS} --exit-code-from database"
fi
# start the containers
docker compose -p consensus-chess-$ENVIRO \
-f compose.yaml -f compose.$ENVIRO.yaml \
--env-file environments/db-$ENVIRO.env \
up --build $ADDITIONAL_OPTIONS \
database