-
Notifications
You must be signed in to change notification settings - Fork 53
/
start.sh
executable file
·65 lines (55 loc) · 1.65 KB
/
start.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
#!/bin/bash
###########
# This script is used for local development only.
# It will ensure certs are generated using mkcert and
# the certs have the correct names for the nginx container.
# It will also install node_modules so they are present to be
# mounted into the frontend container.
###########
# This function shuts down docker compose on CTRL+C
cleanup() {
echo
echo "App stopped, shutting down containers..."
docker compose -f docker-compose.yml $fileFlag exec backend gradle clean --stop
docker compose -f docker-compose.yml $fileFlag down
echo "Thanks for using Simple Report!"
exit
}
if ! [ -x "$(command -v mkcert)" ]; then
echo 'Error: mkcert is not installed. Please check the README for installation instructions.' >&2
exit 1
fi
echo "Checking for certs..."
mkdir -p certs
if [ -n "$(ls -A certs 2>/dev/null)" ]; then
echo "Certs found! Skipping generation."
else
echo "Certs missing, generating..."
mkcert -install
cd certs
mkcert localhost.simplereport.gov
mv localhost.simplereport.gov.pem localhost.simplereport.gov.crt
mv localhost.simplereport.gov-key.pem localhost.simplereport.gov.key
cd ..
echo "🎉 Certs generated!"
fi
echo "Starting Docker Compose..."
while getopts ":l:b" opt; do
case $opt in
l)
echo "Composing with Locust!"
fileFlag="-f docker-compose.locust.yml"
;;
b)
echo "Building any changes!"
buildFlag="--build"
;;
\?)
echo "Invalid start option: -$OPTARG"
;;
esac
done
docker compose -f docker-compose.yml $fileFlag pull
docker compose -f docker-compose.yml $fileFlag up $buildFlag -d
docker compose -f docker-compose.yml $fileFlag logs -f
trap "cleanup" EXIT