-
Notifications
You must be signed in to change notification settings - Fork 10
/
docker-compose.local.run.sh
executable file
·118 lines (105 loc) · 3.62 KB
/
docker-compose.local.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
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
DANGER_REMOVE_CONTAINERS="false"
DANGER_DROP_VOLUMES="false"
for i in "$@"
do
case $i in
--stop)
STOP_CONTAINERS="true"
;;
--remove-domifa-containers)
STOP_CONTAINERS="true"
REMOVE_CONTAINERS="true"
;;
--drop-domifa-volumes)
STOP_CONTAINERS="true"
REMOVE_CONTAINERS="true"
DANGER_DROP_VOLUMES="true"
;;
--with-dev-containers)
WITH_DEV_CONTAINERS="true"
;;
*)
# unknown option
echo ""
echo "----------------------------------------------------------------------------------------------"
echo "[WARN] INVALID OPTION '$i': ignore"
echo "----------------------------------------------------------------------------------------------"
echo ""
;;
esac
done
echo "WITH_DEV_CONTAINERS: $WITH_DEV_CONTAINERS"
if [ "$STOP_CONTAINERS" == "true" ]; then
echo "###########################################"
echo "# [WARN] STOP domifa containers"
echo "###########################################"
# stop all domifa containers
(set -x && APP_DIR=$(pwd) docker-compose --project-name domifa --env-file ./.env -f ./docker-compose.local.yml down)
if [ "$REMOVE_CONTAINERS" == "true" ]; then
echo "###########################################"
echo "# [WARN] REMOVE domifa containers"
echo "###########################################"
# remove all domifa containers
(set -x && APP_DIR=$(pwd) docker-compose --project-name domifa --env-file ./.env -f ./docker-compose.local.yml rm)
if [ "$DANGER_DROP_VOLUMES" == "true" ]; then
echo "###########################################"
echo "# [DANGER] DROP domifa volumes"
echo "###########################################"
read -r -p "All 'domifa' volumes data WILL BE LOST. Are you sure? [y/N] " response
case "$response" in
[yY][eE][sS]|[yY])
# DANGER!!! purge all domifa volumes
(set -x && docker volume rm $(docker volume ls -f dangling=true -q | grep domifa))
;;
*)
echo "# [SKIP]"
;;
esac
fi
fi
exit 0
fi
echo ""
echo "###########################################"
echo "# START DOCKER ENV..."
echo "#"
echo ""
if [ "$WITH_DEV_CONTAINERS" == "true" ]; then
echo "###########################################"
echo "# [INFO] START domifa containers: postgres + backend + frontend"
echo "###########################################"
# start backend + frontend + postgres (with initial dumps)
(set -x && APP_DIR=$(pwd) docker-compose --project-name domifa --env-file ./.env -f ./docker-compose.local.yml up --build --detach --force-recreate)
else
echo "###########################################"
echo "# [INFO] START domifa containers: postgres (only)"
echo "###########################################"
# start postgres only (with initial dumps)
(set -x && APP_DIR=$(pwd) docker-compose --project-name domifa --env-file ./.env -f ./docker-compose.local.yml up --build --detach --force-recreate postgres minio minio-console)
fi
(set -x && docker ps -a)
echo ""
echo "###########################################"
echo "# TO RUN BACKEND:"
echo ""
echo "docker exec -it domifa-backend bash"
echo ""
echo ""
echo "###########################################"
echo "# TO RUN STRUCTURES FRONTEND:"
echo ""
echo "docker exec -it domifa-frontend bash"
echo ""
echo ""
echo "###########################################"
echo "# TO RUN USAGERS FRONTEND:"
echo ""
echo "docker exec -it domifa-portail-usagers bash"
echo ""
echo ""
echo "###########################################"
echo "# TO RUN ADMINS FRONTEND:"
echo ""
echo "docker exec -it domifa-portail-admins bash"
echo ""