forked from aplotor/expanse
-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.sh
executable file
·55 lines (52 loc) · 1.56 KB
/
run.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
#!/bin/sh
if [ "$1" != "dev" ] && [ "$1" != "prod" ]; then
echo "Invalid environment. Valid options: 'dev' and 'prod'"
return
fi
export $(cat backend/.env_$1 | sed -E -e 's/#.*//' -e 's/="/=/' -e 's/(".*$|" *#)//' -e '/^\s*$/d' | xargs -d '\n')
COMPOSER_FILE=./compose.%env%%db_type%.yaml
COMPOSER_FILE=$(echo $COMPOSER_FILE | sed "s/%env%/$1/")
[ $DB_DRIVER = 'sqlite' ] && DB_TYPE=".lite" || DB_TYPE=""
COMPOSER_FILE=$(echo $COMPOSER_FILE | sed "s/%db_type%/$DB_TYPE/")
if [ "$1" = "dev" ]; then
if [ "$2" = "audit" ]; then
(cd ./backend/ && npm audit)
cd ./frontend/ && npm audit
return
elif [ "$2" = "outdated" ]; then
(cd ./backend/ && npm outdated)
cd ./frontend/ && npm outdated
return
elif [ "$2" = "build" ]; then
(cd ./backend/ && npm install)
(cd ./frontend/ && npm install && npm run build)
PWD=${PWD} docker compose -f $COMPOSER_FILE build
return
elif [ "$2" = "up" ]; then
PWD=${PWD} docker compose -f $COMPOSER_FILE up --no-build
return
fi
elif [ "$1" = "prod" ]; then
if [ "$2" = "up" ]; then
if [ "$3" = "--no-d" ]; then
PWD=${PWD} docker compose -f $COMPOSER_FILE up
return
fi
PWD=${PWD} docker compose -f $COMPOSER_FILE up -d
return
elif [ "$2" = "down" ]; then
PWD=${PWD} docker compose -f $COMPOSER_FILE down
return
elif [ "$2" = "update" ]; then
sh ./run.sh prod down
git pull
PWD=${PWD} docker compose -f $COMPOSER_FILE pull
PWD=${PWD} docker compose -f $COMPOSER_FILE build
sh ./run.sh prod up
return
elif [ "$2" = "logs" ]; then
shift
PWD=${PWD} docker compose -f $COMPOSER_FILE $@
return
fi
fi