-
Notifications
You must be signed in to change notification settings - Fork 3
/
prod
executable file
·65 lines (52 loc) · 1.83 KB
/
prod
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
#!/usr/bin/env bash
ENV_FILE='prod.env'
BASE_YML_FILE='base_unbuilt_prod.yml' #replace with base_unbuilt.yml to build yourself
DEV_YML_FILE='prod.yml' #replace with demo_unbuilt.yml to build yourself
DOCKER_TAG='demo-prod'
DOCKER_COMPOSE_COMMAND="docker-compose -f $BASE_YML_FILE -f $DEV_YML_FILE --env-file"
POSTGRES_USER='ptr'
POSTGRES_DB='ptr_api'
DB_DUMP_BACKUP_LOCATION="./db/prod_entrypoint/dump"
if [ $# -gt 0 ]; then
if [ "$1" == "start" ]; then
$DOCKER_COMPOSE_COMMAND $ENV_FILE up -d
elif [ "$1" == "stop" ]; then
$DOCKER_COMPOSE_COMMAND $ENV_FILE down
elif [ "$1" == "reset" ]; then
$DOCKER_COMPOSE_COMMAND $ENV_FILE down -v
elif [ "$1" == "enter" ]; then
shift 1
docker exec -it $@ sh
elif [ "$1" == "log" ]; then
shift 1
docker logs --follow $@
elif [ "$1" == "destroy" ]; then
$DOCKER_COMPOSE_COMMAND $ENV_FILE down -v
docker system prune --volume --all
# docker image prune --all -f
# docker container prune
elif [ "$1" == "clean" ]; then
shift 1
$DOCKER_COMPOSE_COMMAND $ENV_FILE down
docker image rm ptr-"$@":$DOCKER_TAG -f
$DOCKER_COMPOSE_COMMAND $ENV_FILE up --no-cache -d
elif
[ "$1" == "db-backup" ]
then
$DOCKER_COMPOSE_COMMAND $ENV_FILE exec \
db pg_dump -U ${POSTGRES_USER} ${POSTGRES_DB} >"${DB_DUMP_BACKUP_LOCATION}"
elif
[ "$1" == "db-login" ]
then
$DOCKER_COMPOSE_COMMAND $ENV_FILE exec \
db sh -c \
"psql -d ${POSTGRES_DB} -U ${POSTGRES_USER}"
elif [ "$1" == "reload-nginx" ]; then
$DOCKER_COMPOSE_COMMAND $ENV_FILE exec \
proxy nginx -s reload
else
$DOCKER_COMPOSE_COMMAND $ENV_FILE "$@"
fi
else
$DOCKER_COMPOSE_COMMAND $ENV_FILE ps
fi