-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbrahma-server.sh
executable file
·86 lines (84 loc) · 2.57 KB
/
brahma-server.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
echo ""
if [ "$1" == "-dev" ] || [ "$1" == "-d" ]; then
echo "Starting Brahma in DEV Mode..."
trap 'kill $BGPID; exit' INT
trap 'sudo docker stop brahma-mongo; exit' INT
echo ""
echo "Setting up Brahma ENV Variables..."
export BRAHMA_URL=localhost
export BRAHMA_PORT=3000
echo ""
echo "Creating MongoDB Container..."
sudo docker run --name brahma-mongo -d -p 27017:27017 -v /tmp/data:/data/db --rm mongo
echo ""
echo "Building Angular DIST in WATCH Mode (Background)..."
ng serve &
BGPID=$!
echo ""
echo "Starting Express Server (Foreground)..."
node ./server/bin/www
elif [ "$1" == "-vbox" ] || [ "$1" == "-vb" ]; then
echo "Starting Brahma in DEV Mode (assuming inside Virtual Box)..."
trap 'kill $BGPID; exit' INT
trap 'sudo docker stop brahma-mongo; exit' INT
echo ""
echo "Setting up Brahma ENV Variables..."
export BRAHMA_URL=localhost
export BRAHMA_PORT=3000
echo ""
echo "Creating MongoDB Container..."
sudo docker run --name brahma-mongo -d -p 27017:27017 -v /tmp/data:/data/db --rm mongo
echo ""
echo "Building Angular DIST in WATCH Mode (Background)..."
ng serve --host 0.0.0.0 &
BGPID=$!
echo ""
echo "Starting Express Server (Foreground)..."
node ./server/bin/www
elif [ "$1" == "-prod" ] || [ "$1" == "-p" ]; then
echo "Starting Brahma in PROD Mode..."
echo ""
echo "Removing Brahma ENV Variables..."
unset BRAHMA_URL
unset BRAHMA_PORT
echo ""
echo "Building Angular DIST..."
ng build --prod
echo ""
echo "Starting Express Server..."
node ./server/bin/www
elif [ "$1" == "-build" ] || [ "$1" == "-b" ]; then
echo "Building Angular DIST..."
ng build --prod
echo ""
echo "Building Docker Container..."
docker build -t brahma .
elif [ "$1" == "-compose" ] || [ "$1" == "-c" ]; then
if [ "$2" == "-up" ] || [ "$2" == "-u" ]; then
echo "Building Angular DIST..."
ng build --prod
echo ""
echo "Starting Brahma Services..."
sudo docker-compose up --build &
elif [ "$2" == "-down" ] || [ "$2" == "-d" ]; then
echo "Stopping Brahma Services..."
sudo docker-compose down
else
echo "Missing arguments, please specify -up or -down."
echo ""
fi
else
echo ""
echo "Usage: brahma-server [-d] | [-p] | [-b] | [-c [-u|-d]]"
echo ""
echo "Brahma Server Script"
echo ""
echo "Optional Arguments:"
echo "-d -dev Run Server in Development Mode"
echo "-p -prod Run Server in Production Mode"
echo "-b -build Build Docker Container for Brahma Service"
echo "-c -compose Bring Full Brahma Service Up/Down via docker-compose"
echo ""
exit 0
fi