-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli
executable file
·68 lines (55 loc) · 1.63 KB
/
cli
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
#!/usr/bin/env bash
# Import the .env file
if [ -f .env ]
then
export $(cat .env | sed 's/#.*//g' | xargs)
fi
if [ "$NODE_ENV" = "production" ]; then
COMPOSE="docker-compose -f docker-compose.yml -f docker-compose.prod.yml"
else
COMPOSE="docker-compose -f docker-compose.yml -f docker-compose.dev.yml"
fi
# If we pass any arguments...
if [ $# -gt 0 ];then
# start the app
if [ "$1" == "start" ]; then
$COMPOSE up -d
# stop the app
elif [ "$1" == "stop" ]; then
$COMPOSE down
# If "yarn" is used, pass-thru to "yarn"
# inside a new container
elif [ "$1" == "yarn" ]; then
shift 1
$COMPOSE run --rm \
-w /app \
app \
yarn "$@"
# If "test" is used, run unit tests,
# pass-thru any extra arguments to test
elif [ "$1" == "test" ]; then
shift 1
$COMPOSE run --rm \
-w /app \
app \
yarn test "$@"
# If "db" is used, run mariadb
# from our mariadb container
elif [ "$1" == "db-backup" ]; then
shift 1
$COMPOSE exec app-mariadb mysqldump -u ${DB_USERNAME} -p${DB_PASSWORD} "$2" > ./data/dumps/dump-$(date +"%d-%m-%Y_%s").sql
elif [ "$1" == "ssl" ]; then
shift 1
/bin/bash ./init-letsencrypt.sh
# Add dhparam after installing ssl
elif [ "$1" == "post-ssl" ]; then
shift 1
curl https://ssl-config.mozilla.org/ffdhe2048.txt > data/certbot/dhparam/dhparam-2048.pem
$COMPOSE exec nginx nginx -s reload
# Else, pass-thru args to docker-compose
else
$COMPOSE "$@"
fi
else
$COMPOSE ps
fi