-
Notifications
You must be signed in to change notification settings - Fork 0
/
rcms.sh
executable file
·214 lines (199 loc) · 5.53 KB
/
rcms.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
#!/bin/sh
rcms_help()
{
echo "";
echo "Management options:";
echo "";
echo "--deployment Create images, containers and build dependencies";
echo "--start-development Create containers and start services";
echo "--start-production Create containers and start services";
echo "--start-production-stack Use Docker deploy stack";
echo "--restart-development Restart services";
echo "--restart-production Restart services";
echo "--stop-development Stop services";
echo "--stop-production Stop services";
echo "--stop-production-stack Stop and remove stack services";
echo "--remove-development Remove containers";
echo "--remove-production Remove containers";
echo "--install-dependencies Install dependencies";
echo "--build-images Build images";
echo "";
echo "If you want to show some container logs you can run:";
echo "\$docker logs <container-name> -f --tail 100";
}
rcms_deployment()
{
echo "Deployment";
base_dir=./docker/;
mkdir -p ${base_dir}../database/data/db/;
mkdir -p ${base_dir}../database/data/mongodb/;
docker build -f ${base_dir}dockerfile/dockerfile-mongodb -t rcms-mongodb-img .;
docker build -f ${base_dir}dockerfile/dockerfile-nginx -t rcms-nginx-img .;
docker build -f ${base_dir}dockerfile/dockerfile-nodejs -t rcms-nodejs-img .;
docker-compose -f ${base_dir}build/rcms-nodejs-builder.yml run --rm rcms-install;
echo "Deployment finished";
echo "For next steps run: rcms.sh after-deploying"
}
rcms_start_development()
{
echo "Starting development";
echo "";
base_dir=./docker/development/;
docker-compose -f ${base_dir}docker-compose.yml -p rcms-development up -d;
echo "";
echo "Starting development finished";
}
rcms_start_production()
{
echo "Starting production";
echo "";
base_dir=./docker/production/;
docker-compose -f ${base_dir}docker-compose.yml -p rcms-production up -d;
docker-compose -f ${base_dir}rcms-dashboard-app-production.yml run --rm rcms-install;
echo "";
echo "Starting production finished";
}
rcms_start_production_stack()
{
echo "Starting production stack";
echo "";
base_dir=./docker/production/;
docker stack deploy -c ${base_dir}docker-compose.yml rcms-production;
docker-compose -f ${base_dir}rcms-dashboard-app-production.yml run --rm rcms-install;
echo "";
echo "Starting production stack finished";
}
rcms_stop_development()
{
echo "Stopping development";
echo "";
base_dir=./docker/development/;
docker-compose -f ${base_dir}docker-compose.yml -p rcms-development stop;
echo "";
echo "Stopping development finished";
}
rcms_stop_production()
{
echo "Stopping production";
echo "";
base_dir=./docker/production/;
docker-compose -f ${base_dir}docker-compose.yml -p rcms-production stop;
echo "";
echo "Stopping production finished";
}
rcms_stop_production_stack()
{
echo "Stopping production stack";
echo "";
docker stack rm rcms-production
echo "";
echo "Stopping production stack finished";
}
rcms_restart_development()
{
echo "Restarting development";
echo "";
base_dir=./docker/development/;
docker-compose -f ${base_dir}docker-compose.yml -p rcms-development stop;
docker-compose -f ${base_dir}docker-compose.yml -p rcms-development start;
echo "";
echo "Restarting development finished";
}
rcms_restart_production()
{
echo "Restarting production";
echo "";
base_dir=./docker/production/;
docker-compose -f ${base_dir}docker-compose.yml -p rcms-production stop;
docker-compose -f ${base_dir}docker-compose.yml -p rcms-production start;
echo "";
echo "Restarting production finished";
}
rcms_remove_development()
{
echo "Removing development";
echo "";
base_dir=./docker/development/;
docker-compose -f ${base_dir}docker-compose.yml -p rcms-development down;
echo "";
echo "Removing development finished";
}
rcms_remove_production()
{
echo "Removing production";
echo "";
base_dir=./docker/production/;
docker-compose -f ${base_dir}docker-compose.yml -p rcms-production down;
echo "";
echo "Removing production finished";
}
rcms_install_dependencies()
{
echo "Installing dependencies";
echo "";
base_dir=./docker/;
docker-compose -f ${base_dir}build/rcms-nodejs-builder.yml run --rm rcms-install;
echo "";
echo "Installing dependencies finished";
}
rcms_build_images() {
echo "Building images";
echo "";
base_dir=./docker/;
docker build --no-cache -f ${base_dir}dockerfile/dockerfile-mongodb -t rcms-mongodb-img .;
docker build --no-cache -f ${base_dir}dockerfile/dockerfile-nginx -t rcms-nginx-img .;
docker build --no-cache -f ${base_dir}dockerfile/dockerfile-nodejs -t rcms-nodejs-img .;
echo ""
echo "Building images finished";
}
echo "== REACTIVE CMS ==";
case $1 in
--deployment)
rcms_deployment;
;;
--start-development)
rcms_start_development;
;;
--start-production)
rcms_start_production;
;;
--start-production-stack)
rcms_start_production_stack;
;;
--stop-development)
rcms_stop_development;
;;
--stop-production)
rcms_stop_production;
;;
--stop-production-stack)
rcms_stop_production_stack;
;;
--restart-development)
rcms_restart_development;
;;
--restart-production)
rcms_restart_production;
;;
--remove-development)
rcms_remove_development;
;;
--remove-production)
rcms_remove_production;
;;
--install-dependencies)
rcms_install_dependencies;
;;
--build-images)
rcms_build_images;
;;
--help)
rcms_help;
;;
*)
rcms_help;
echo "";
echo "Version. 1.0.0 beta";
echo "";
;;
esac