Skip to content

Commit b46f7ae

Browse files
authored
Merge pull request #1260 from jembi/emergency-backup-zip
Emergency backup/restore cron job / pen testing setup / municipality support / hotfixes
2 parents c84e70e + 3866261 commit b46f7ae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1205
-501
lines changed

AUTHORS

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
OpenCRVS was originally coded between 2017 and 2019 by the organisations
2-
Plan International, Jembi Health Systems & Dynamic Solution Innovators
1+
OpenCRVS has been produced by the funding and support from the organisations
2+
Plan International, Jembi Health Systems & Vital Strategies,
3+
with coding assistance from Dynamic Solution Innovators & Futurice.
34

45
https://plan-international.org/
56
https://www.jembi.org/
67
http://www.dsinnovators.com/
8+
https://www.vitalstrategies.org/
9+
https://www.futurice.com/
710

811
Here is an inevitably incomplete list of MUCH-APPRECIATED CONTRIBUTORS --
912
people who have submitted code and generally made OpenCRVS that much better:
@@ -12,7 +15,7 @@ Euan Millar https://github.com/euanmillar
1215
Ryan Crichton https://github.com/rcrichton
1316
Riku Rouvila https://github.com/rikukissa
1417
Anik Mushraful Hoque https://github.com/mushrafulhoque-dsi
15-
Asif Atick https://github.com/asifatick
18+
Atiq Zaman https://github.com/atiqzaman-dsi
1619
Tahmid Rahman https://github.com/tahmidrahman-dsi
1720
Sahriar Toufiq https://github.com/sahriartoufiq
1821
Yeasin Hossain https://github.com/yeasinhossain-dsi
@@ -27,6 +30,14 @@ The core product and design team, list of supporters and supporting organisation
2730
can be found at https://www.opencrvs.org without who's leadership, funding and guidance
2831
OpenCRVS would never have existed. THANK YOU!
2932

33+
OpenCRVS is the brainchild of our Product Manager Ed Duffus from Plan International.
34+
35+
Ed Duffus https://github.com/eduffus
36+
37+
Extra special thanks to our Plan International Product Owner Annina Wersun, and Design Lead Jonathan Pye-Finch
38+
39+
Design and Product thanks must also be extended to Umesh Pandya, Isa Jokela-Gomes & George Bevan.
40+
3041
This Source Code Form is subject to the terms of the Mozilla Public
3142
License, v. 2.0. If a copy of the MPL was not distributed with this
3243
file, You can obtain one at https://mozilla.org/MPL/2.0/.

deploy.sh

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
set -e
1111

1212
print_usage_and_exit () {
13-
echo 'Usage: ./deploy.sh COUNTRY --clear-data=yes|no --restore-metadata=yes|no HOST VERSION'
13+
echo 'Usage: ./deploy.sh COUNTRY --clear-data=yes|no --restore-metadata=yes|no HOST ENV VERSION'
1414
echo " Script must receive a first COUNTRY parameter of 'bgd' or 'zmb' set as a supported alpha-3 country code e.g.: ./deploy.sh bgd"
1515
echo " --clear-data must have a value of 'yes' or 'no' set e.g. --clear-data=yes"
1616
echo " --restore-metadata must have a value of 'yes' or 'no' set e.g. --restore-metadata=yes"
1717
echo ' HOST is the server to deploy to'
18+
echo " ENV can be 'production' or 'development'"
1819
echo " VERSION can be any docker image tag or 'latest'"
1920
exit 1
2021
}
@@ -40,13 +41,19 @@ if [ -z "$4" ] ; then
4041
fi
4142

4243
if [ -z "$5" ] ; then
43-
echo 'Error: Argument VERSION is required in postition 5.'
44+
echo 'Error: Argument ENV is required in postition 5.'
45+
print_usage_and_exit
46+
fi
47+
48+
if [ -z "$6" ] ; then
49+
echo 'Error: Argument VERSION is required in postition 6.'
4450
print_usage_and_exit
4551
fi
4652

4753
COUNTRY=$1
4854
HOST=$4
49-
VERSION=$5
55+
ENV=$5
56+
VERSION=$6
5057
SSH_USER=${SSH_USER:-root}
5158
SSH_HOST=${SSH_HOST:-$HOST}
5259
LOG_LOCATION=${LOG_LOCATION:-/var/log}
@@ -55,16 +62,16 @@ echo
5562
echo "Deploying version $VERSION to $SSH_HOST..."
5663
echo
5764

58-
mkdir -p /tmp/compose/infrastructure/backups
65+
mkdir -p /tmp/compose/infrastructure/default_backups
5966

6067
# Copy selected country config to public & infrastructure folder
6168
cp packages/resources/src/$COUNTRY/config/client-config.prod.js /tmp/compose/infrastructure/client-config.js
6269
cp packages/resources/src/$COUNTRY/config/login-config.prod.js /tmp/compose/infrastructure/login-config.js
6370

64-
# Copy selected country backups to infrastructure backups folder
65-
cp packages/resources/src/$COUNTRY/backups/hearth-dev.gz /tmp/compose/infrastructure/backups/hearth-dev.gz
66-
cp packages/resources/src/$COUNTRY/backups/openhim-dev.gz /tmp/compose/infrastructure/backups/openhim-dev.gz
67-
cp packages/resources/src/$COUNTRY/backups/user-mgnt.gz /tmp/compose/infrastructure/backups/user-mgnt.gz
71+
# Copy selected country default backups to infrastructure default_backups folder
72+
cp packages/resources/src/$COUNTRY/backups/hearth-dev.gz /tmp/compose/infrastructure/default_backups/hearth-dev.gz
73+
cp packages/resources/src/$COUNTRY/backups/openhim-dev.gz /tmp/compose/infrastructure/default_backups/openhim-dev.gz
74+
cp packages/resources/src/$COUNTRY/backups/user-mgnt.gz /tmp/compose/infrastructure/default_backups/user-mgnt.gz
6875

6976
# Copy all infrastructure files to the server
7077
rsync -rP docker-compose* infrastructure $SSH_USER@$SSH_HOST:/tmp/compose/
@@ -76,13 +83,20 @@ rsync -rP packages/resources/src/$COUNTRY/config/docker-compose* infrastructure
7683
rsync -rP /tmp/compose/infrastructure $SSH_USER@$SSH_HOST:/tmp/compose
7784

7885
# Prepare docker-compose.deploy.yml and docker-compose.<COUNTRY>.yml file - rotate secrets etc
79-
ssh $SSH_USER@$SSH_HOST '/tmp/compose/infrastructure/rotate-secrets.sh /tmp/compose/docker-compose.deploy.yml /tmp/compose/docker-compose.'$COUNTRY'.deploy.yml | tee -a '$LOG_LOCATION'/rotate-secrets.log'
80-
86+
if [[ "$ENV" = "development" ]]; then
87+
ssh $SSH_USER@$SSH_HOST '/tmp/compose/infrastructure/rotate-secrets.sh /tmp/compose/docker-compose.deploy.yml /tmp/compose/docker-compose.'$COUNTRY'.deploy.yml | tee -a '$LOG_LOCATION'/rotate-secrets.log'
88+
else
89+
ssh $SSH_USER@$SSH_HOST '/tmp/compose/infrastructure/rotate-secrets.sh /tmp/compose/docker-compose.deploy.yml /tmp/compose/docker-compose.prod-deploy.yml /tmp/compose/docker-compose.'$COUNTRY'.deploy.yml | tee -a '$LOG_LOCATION'/rotate-secrets.log'
90+
fi
8191
# Setup configuration files and compose file for the deployment domain
8292
ssh $SSH_USER@$SSH_HOST '/tmp/compose/infrastructure/setup-deploy-config.sh '$HOST' | tee -a '$LOG_LOCATION'/setup-deploy-config.log'
8393

8494
# Deploy the OpenCRVS stack onto the swarm
95+
if [[ "$ENV" = "development" ]]; then
8596
ssh $SSH_USER@$SSH_HOST 'cd /tmp/compose && COUNTRY='$COUNTRY' VERSION='$VERSION' docker stack deploy -c docker-compose.deps.yml -c docker-compose.yml -c docker-compose.deploy.yml -c docker-compose.'$COUNTRY'.deploy.yml --with-registry-auth opencrvs'
97+
else
98+
ssh $SSH_USER@$SSH_HOST 'cd /tmp/compose && COUNTRY='$COUNTRY' VERSION='$VERSION' docker stack deploy -c docker-compose.deps.yml -c docker-compose.yml -c docker-compose.deploy.yml -c docker-compose.prod-deploy.yml -c docker-compose.'$COUNTRY'.deploy.yml --with-registry-auth opencrvs'
99+
fi
86100

87101
if [ $2 == "--clear-data=yes" ] || [ $3 == "--restore-metadata=yes" ] ; then
88102
echo

docker-compose.deploy.yml

Lines changed: 53 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
# Copyright (C) The OpenCRVS Authors. OpenCRVS and the OpenCRVS
99
# graphic logo are (registered/a) trademark(s) of Plan International.
10-
version: '3.3'
10+
version: "3.3"
1111

1212
services:
1313
# Configure reverse proxy for public endpoints
@@ -16,8 +16,8 @@ services:
1616
traefik:
1717
image: traefik:1.7.16
1818
ports:
19-
- '80:80'
20-
- '443:443'
19+
- "80:80"
20+
- "443:443"
2121
volumes:
2222
- /var/run/docker.sock:/var/run/docker.sock
2323
- /data/traefik/acme.json:/acme.json
@@ -36,7 +36,7 @@ services:
3636
mongo1:
3737
command: --replSet rs0
3838
volumes:
39-
- '/data/mongo:/data/db'
39+
- "/data/mongo:/data/db"
4040
deploy:
4141
replicas: 1
4242
placement:
@@ -50,7 +50,7 @@ services:
5050
restart: unless-stopped
5151
command: --replSet rs0
5252
volumes:
53-
- '/data/mongo:/data/db'
53+
- "/data/mongo:/data/db"
5454
deploy:
5555
replicas: 1
5656
placement:
@@ -64,7 +64,7 @@ services:
6464
restart: unless-stopped
6565
command: --replSet rs0
6666
volumes:
67-
- '/data/mongo:/data/db'
67+
- "/data/mongo:/data/db"
6868
deploy:
6969
replicas: 1
7070
placement:
@@ -94,7 +94,10 @@ services:
9494
# Configure elasticsearch
9595
elasticsearch:
9696
volumes:
97-
- '/data/elasticsearch:/usr/share/elasticsearch/data'
97+
- "/data/elasticsearch:/usr/share/elasticsearch/data"
98+
- "/backups/elasticsearch:/backups/elasticsearch"
99+
- "/tmp/compose/infrastructure/elasticsearch/elasticsearch.yml:/config/elasticsearch.yml"
100+
- "/tmp/compose/infrastructure/elasticsearch/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml"
98101
deploy:
99102
replicas: 1
100103
placement:
@@ -106,7 +109,8 @@ services:
106109
# Configure influxdb
107110
influxdb:
108111
volumes:
109-
- '/data/influxdb:/var/lib/influxdb'
112+
- "/data/influxdb:/var/lib/influxdb"
113+
- "/backups/influxdb:/backups/influxdb"
110114
deploy:
111115
replicas: 1
112116
placement:
@@ -122,12 +126,12 @@ services:
122126
target: /usr/share/nginx/html/config.js
123127
deploy:
124128
labels:
125-
- 'traefik.enable=true'
126-
- 'traefik.frontend.rule=Host: register.{{hostname}},{{hostname}}'
127-
- 'traefik.frontend.redirect.regex=^https?://{{hostname}}/(.*)'
128-
- 'traefik.frontend.redirect.replacement=https://register.{{hostname}}/$${1}'
129-
- 'traefik.port=80'
130-
- 'traefik.docker.network=opencrvs_overlay_net'
129+
- "traefik.enable=true"
130+
- "traefik.frontend.rule=Host: register.{{hostname}},{{hostname}}"
131+
- "traefik.frontend.redirect.regex=^https?://{{hostname}}/(.*)"
132+
- "traefik.frontend.redirect.replacement=https://register.{{hostname}}/$${1}"
133+
- "traefik.port=80"
134+
- "traefik.docker.network=opencrvs_overlay_net"
131135
replicas: 2
132136
networks:
133137
- overlay_net
@@ -138,21 +142,21 @@ services:
138142
target: /usr/share/nginx/html/config.js
139143
deploy:
140144
labels:
141-
- 'traefik.enable=true'
142-
- 'traefik.frontend.rule=Host: performance.{{hostname}}'
143-
- 'traefik.port=80'
144-
- 'traefik.docker.network=opencrvs_overlay_net'
145+
- "traefik.enable=true"
146+
- "traefik.frontend.rule=Host: performance.{{hostname}}"
147+
- "traefik.port=80"
148+
- "traefik.docker.network=opencrvs_overlay_net"
145149
replicas: 2
146150
networks:
147151
- overlay_net
148152

149153
styleguide:
150154
deploy:
151155
labels:
152-
- 'traefik.enable=true'
153-
- 'traefik.frontend.rule=Host: styleguide.{{hostname}}'
154-
- 'traefik.port=6060'
155-
- 'traefik.docker.network=opencrvs_overlay_net'
156+
- "traefik.enable=true"
157+
- "traefik.frontend.rule=Host: styleguide.{{hostname}}"
158+
- "traefik.port=6060"
159+
- "traefik.docker.network=opencrvs_overlay_net"
156160
replicas: 1
157161
networks:
158162
- overlay_net
@@ -163,10 +167,10 @@ services:
163167
target: /usr/share/nginx/html/config.js
164168
deploy:
165169
labels:
166-
- 'traefik.enable=true'
167-
- 'traefik.frontend.rule=Host: login.{{hostname}}'
168-
- 'traefik.port=80'
169-
- 'traefik.docker.network=opencrvs_overlay_net'
170+
- "traefik.enable=true"
171+
- "traefik.frontend.rule=Host: login.{{hostname}}"
172+
- "traefik.port=80"
173+
- "traefik.docker.network=opencrvs_overlay_net"
170174
replicas: 2
171175
networks:
172176
- overlay_net
@@ -181,10 +185,10 @@ services:
181185
- CERT_PUBLIC_KEY_PATH=/run/secrets/jwt-public-key.{{ts}}
182186
deploy:
183187
labels:
184-
- 'traefik.enable=true'
185-
- 'traefik.frontend.rule=Host: auth.{{hostname}}'
186-
- 'traefik.port=4040'
187-
- 'traefik.docker.network=opencrvs_overlay_net'
188+
- "traefik.enable=true"
189+
- "traefik.frontend.rule=Host: auth.{{hostname}}"
190+
- "traefik.port=4040"
191+
- "traefik.docker.network=opencrvs_overlay_net"
188192
replicas: 2
189193
networks:
190194
- overlay_net
@@ -217,10 +221,10 @@ services:
217221
- CERT_PUBLIC_KEY_PATH=/run/secrets/jwt-public-key.{{ts}}
218222
deploy:
219223
labels:
220-
- 'traefik.enable=true'
221-
- 'traefik.frontend.rule=Host: gateway.{{hostname}}'
222-
- 'traefik.port=7070'
223-
- 'traefik.docker.network=opencrvs_overlay_net'
224+
- "traefik.enable=true"
225+
- "traefik.frontend.rule=Host: gateway.{{hostname}}"
226+
- "traefik.port=7070"
227+
- "traefik.docker.network=opencrvs_overlay_net"
224228
replicas: 2
225229
networks:
226230
- overlay_net
@@ -254,10 +258,10 @@ services:
254258
- TEST_USER_PASSWORD=test
255259
deploy:
256260
labels:
257-
- 'traefik.enable=true'
258-
- 'traefik.frontend.rule=Host: resources.{{hostname}}'
259-
- 'traefik.port=3040'
260-
- 'traefik.docker.network=opencrvs_overlay_net'
261+
- "traefik.enable=true"
262+
- "traefik.frontend.rule=Host: resources.{{hostname}}"
263+
- "traefik.port=3040"
264+
- "traefik.docker.network=opencrvs_overlay_net"
261265
replicas: 2
262266
networks:
263267
- overlay_net
@@ -302,24 +306,24 @@ services:
302306
- mongo3
303307
deploy:
304308
labels:
305-
- 'traefik.enable=true'
306-
- 'traefik.docker.network=opencrvs_overlay_net'
307-
- 'traefik.openhim-api.frontend.rule=Host: openhim-api.{{hostname}}'
308-
- 'traefik.openhim-api.protocol=https'
309-
- 'traefik.openhim-api.port=8080'
310-
- 'traefik.router.frontend.rule=Host: api.{{hostname}}'
311-
- 'traefik.router.port=5001'
309+
- "traefik.enable=true"
310+
- "traefik.docker.network=opencrvs_overlay_net"
311+
- "traefik.openhim-api.frontend.rule=Host: openhim-api.{{hostname}}"
312+
- "traefik.openhim-api.protocol=https"
313+
- "traefik.openhim-api.port=8080"
314+
- "traefik.router.frontend.rule=Host: api.{{hostname}}"
315+
- "traefik.router.port=5001"
312316
replicas: 2
313317
networks:
314318
- overlay_net
315319

316320
openhim-console:
317321
deploy:
318322
labels:
319-
- 'traefik.enable=true'
320-
- 'traefik.frontend.rule=Host: openhim.{{hostname}}'
321-
- 'traefik.port=80'
322-
- 'traefik.docker.network=opencrvs_overlay_net'
323+
- "traefik.enable=true"
324+
- "traefik.frontend.rule=Host: openhim.{{hostname}}"
325+
- "traefik.port=80"
326+
- "traefik.docker.network=opencrvs_overlay_net"
323327
replicas: 2
324328
configs:
325329
- source: openhim-console-conf.{{ts}}

docker-compose.deps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
# Copyright (C) The OpenCRVS Authors. OpenCRVS and the OpenCRVS
99
# graphic logo are (registered/a) trademark(s) of Plan International.
10-
version: '3.3'
10+
version: "3.3"
1111

1212
services:
1313
mongo1:

docker-compose.prod-deploy.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
#
5+
# OpenCRVS is also distributed under the terms of the Civil Registration
6+
# & Healthcare Disclaimer located at http://opencrvs.org/license.
7+
#
8+
# Copyright (C) The OpenCRVS Authors. OpenCRVS and the OpenCRVS
9+
# graphic logo are (registered/a) trademark(s) of Plan International.
10+
version: '3.3'
11+
12+
services:
13+
gateway:
14+
environment:
15+
- NODE_ENV=production
16+
17+
workflow:
18+
environment:
19+
- NODE_ENV=production
20+
21+
search:
22+
environment:
23+
- NODE_ENV=production
24+
25+
metrics:
26+
environment:
27+
- NODE_ENV=production
28+
29+
auth:
30+
environment:
31+
- NODE_ENV=production
32+
33+
user-mgnt:
34+
environment:
35+
- NODE_ENV=production
36+
37+
notification:
38+
environment:
39+
- NODE_ENV=production
40+
41+
resources:
42+
environment:
43+
- NODE_ENV=production

0 commit comments

Comments
 (0)