This repository was archived by the owner on Jul 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·66 lines (59 loc) · 1.83 KB
/
run.sh
File metadata and controls
executable file
·66 lines (59 loc) · 1.83 KB
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
#!/bin/bash
#Run.sh
while [ ${#} -gt 0 ];do OPTERR=0;OPTIND=1;getopts "hdprw" arg;case "$arg" in
h) help=true
;;
d) development=true
;;
p) production=true
;;
r) rebuild=true
;;
\?) SET+=("$1")
;;
*) printf "\n./run.sh [ -d -r ] | [-h]\n\n">&2
;;
esac;shift;[ "" != "$OPTARG" ] && shift;done
[ ${#SET[@]} -gt 0 ] && set "" "${SET[@]}" && shift
printf "\n\n"
if [[ ! -z "$help" ]]; then
printf "=-=-= Run.sh help page\n\n"
printf "./run.sh [ -d -r ] | [-h]\n\n"
printf " -d Development mode. Starts appserver with hot-module reloading, mongodb and mongopanel.\n"
printf " Production mode. Builds the app and serves everything from containers.\n Default mode if -d is not provided.\n"
printf " -r Rebuild. Rebuilds the containers from current source code.\n Common use case would be when the source code was updated"
printf " -h Shows this help menu\n"
printf "\n\n"
exit
fi
if [[ ! -z "$rebuild" ]]; then
printf "\n=-= REBUILD MODE\n"
printf "\n= Removing containers ...\n"
if [[ ! -z "$development" ]]; then
docker-compose -f docker-compose.dev.yml down
else
docker-compose -f docker-compose.prod.yml down
fi
printf "\n= Building containers ...\n"
if [[ ! -z "$development" ]]; then
docker-compose -f docker-compose.dev.yml build
else
docker-compose -f docker-compose.prod.yml build
fi
else
printf "\n=-= RESUME MODE\n"
printf "\n= Stopping containers ...\n"
if [[ ! -z "$development" ]]; then
docker-compose -f docker-compose.dev.yml stop
else
docker-compose -f docker-compose.prod.yml stop
fi
fi
printf "\n\n"
if [[ ! -z "$development" ]]; then
printf "\n\n=-=-= RUNNING DEVELOPMENT BUILD\n\n"
docker-compose -f docker-compose.dev.yml up
else
printf "\n\n=-=-= RUNNING PRODUCTION BUILD\n\n"
docker-compose -f docker-compose.prod.yml up -d
fi