Skip to content

Commit a002c75

Browse files
committed
deploy each env to its own directory
1 parent 7f8de50 commit a002c75

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

infrastructure/deployment/deploy.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,12 @@ generate_password() {
208208

209209
to_remote_paths() {
210210
paths=$@
211-
echo "$paths" | sed "s|/tmp/|/opt/opencrvs/infrastructure/|g" | sed "s|$INFRASTRUCTURE_DIRECTORY/docker-compose|/opt/opencrvs/infrastructure/docker-compose|g"
211+
echo "$paths" | sed "s|/tmp/|/opt/opencrvs/$STACK/infrastructure/|g" | sed "s|$INFRASTRUCTURE_DIRECTORY/docker-compose|/opt/opencrvs/$STACK/infrastructure/docker-compose|g"
212212
}
213213

214214
rotate_secrets() {
215215
files_to_rotate=$(to_remote_paths $COMPOSE_FILES_USED)
216-
configured_ssh '/opt/opencrvs/infrastructure/rotate-secrets.sh '$files_to_rotate' | tee -a '$LOG_LOCATION'/rotate-secrets.log'
216+
configured_ssh '/opt/opencrvs/$STACK/infrastructure/rotate-secrets.sh '$files_to_rotate' | tee -a '$LOG_LOCATION'/rotate-secrets.log'
217217
}
218218

219219

@@ -412,14 +412,15 @@ echo "Deploying COUNTRY_CONFIG_VERSION $COUNTRY_CONFIG_VERSION to $SSH_HOST..."
412412
echo
413413
echo "Syncing configuration files to the target server"
414414

415-
configured_rsync -rlD $PROJECT_ROOT/infrastructure $SSH_USER@$SSH_HOST:/opt/opencrvs/ --delete --no-perms --omit-dir-times --verbose
415+
configured_rsync -rlD $PROJECT_ROOT/infrastructure $SSH_USER@$SSH_HOST:/opt/opencrvs/$STACK --delete --no-perms --omit-dir-times --verbose
416416

417417
echo "Logging to Dockerhub"
418418

419419
configured_ssh "docker login -u $DOCKER_USERNAME -p $DOCKER_TOKEN"
420420

421+
421422
# Setup configuration files and compose file for the deployment domain
422-
configured_ssh "/opt/opencrvs/infrastructure/setup-deploy-config.sh $HOST"
423+
configured_ssh "/opt/opencrvs/$STACK/infrastructure/setup-deploy-config.sh $HOST $STACK"
423424

424425
rotate_secrets
425426

@@ -436,7 +437,7 @@ if [ "$UPDATE_DEPENDENCIES" = true ]; then
436437
echo 'Setting up elastalert indices'
437438

438439
while true; do
439-
if configured_ssh "/opt/opencrvs/infrastructure/elasticsearch/setup-elastalert-indices.sh"; then
440+
if configured_ssh "/opt/opencrvs/$STACK/infrastructure/elasticsearch/setup-elastalert-indices.sh"; then
440441
break
441442
fi
442443
sleep 5
@@ -445,7 +446,7 @@ if [ "$UPDATE_DEPENDENCIES" = true ]; then
445446
echo "Setting up Kibana config & alerts"
446447

447448
while true; do
448-
if configured_ssh "HOST=kibana.$HOST /opt/opencrvs/infrastructure/monitoring/kibana/setup-config.sh"; then
449+
if configured_ssh "HOST=kibana.$HOST /opt/opencrvs/$STACK/infrastructure/monitoring/kibana/setup-config.sh"; then
449450
break
450451
fi
451452
sleep 5
@@ -454,7 +455,7 @@ else
454455
echo 'Waiting for Elasticsearch to be ready'
455456

456457
while true; do
457-
if configured_ssh "/opt/opencrvs/infrastructure/elasticsearch/wait-for-elasticsearch.sh"; then
458+
if configured_ssh "/opt/opencrvs/$STACK/infrastructure/elasticsearch/wait-for-elasticsearch.sh"; then
458459
break
459460
fi
460461
sleep 5

infrastructure/monitoring/kibana/setup-config.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ response_text_from_curl_output() {
2626
}
2727

2828
curl_raw() {
29-
docker run --rm -v /opt/opencrvs/infrastructure/monitoring/kibana/config.ndjson:/config.ndjson --network=dependencies_elasticsearch_net curlimages/curl -s -w "\n%{http_code}" "$@"
29+
docker run --rm -v /opt/opencrvs/$STACK/infrastructure/monitoring/kibana/config.ndjson:/config.ndjson --network=dependencies_elasticsearch_net curlimages/curl -s -w "\n%{http_code}" "$@"
3030
}
3131

3232
parse_url_from_string() {

infrastructure/setup-deploy-config.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@ set -e
1010
echo
1111

1212
HOST=$1
13-
13+
STACK=$2
1414
echo "Setting up deployment config for $HOST - `date --iso-8601=ns`"
1515

1616
# Set hostname in compose file
17-
for file in /opt/opencrvs/infrastructure/docker-compose*.yml; do
17+
for file in /opt/opencrvs/$STACK/infrastructure/docker-compose*.yml; do
1818
sed -i "s/{{hostname}}/$HOST/g" "$file"
1919
done
2020

2121
# Setup an encryption key for Kibana
2222
KIBANA_ENCRYPTION_KEY=`uuidgen`
23-
sed -i "s/{{KIBANA_ENCRYPTION_KEY}}/$KIBANA_ENCRYPTION_KEY/g" /opt/opencrvs/infrastructure/monitoring/kibana/kibana.yml
23+
sed -i "s/{{KIBANA_ENCRYPTION_KEY}}/$KIBANA_ENCRYPTION_KEY/g" /opt/opencrvs/$STACK/infrastructure/monitoring/kibana/kibana.yml
2424

25-
sed -i -e "s%{{MINIO_ROOT_USER}}%$MINIO_ROOT_USER%" /opt/opencrvs/infrastructure/mc-config/config.json
26-
sed -i -e "s%{{MINIO_ROOT_PASSWORD}}%$MINIO_ROOT_PASSWORD%" /opt/opencrvs/infrastructure/mc-config/config.json
25+
sed -i -e "s%{{MINIO_ROOT_USER}}%$MINIO_ROOT_USER%" /opt/opencrvs/$STACK/infrastructure/mc-config/config.json
26+
sed -i -e "s%{{MINIO_ROOT_PASSWORD}}%$MINIO_ROOT_PASSWORD%" /opt/opencrvs/$STACK/infrastructure/mc-config/config.json
2727

2828
echo "DONE - `date --iso-8601=ns`"
2929
echo

0 commit comments

Comments
 (0)