Skip to content

Commit

Permalink
configure database credentials for events service
Browse files Browse the repository at this point in the history
  • Loading branch information
rikukissa committed Nov 22, 2024
1 parent 2877e8b commit 80e8b78
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions infrastructure/deployment/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ export PERFORMANCE_MONGODB_PASSWORD=`generate_password`
export OPENHIM_MONGODB_PASSWORD=`generate_password`
export WEBHOOKS_MONGODB_PASSWORD=`generate_password`
export NOTIFICATION_MONGODB_PASSWORD=`generate_password`
export EVENTS_MONGODB_PASSWORD=`generate_password`

#
# Elasticsearch credentials
Expand Down
1 change: 1 addition & 0 deletions infrastructure/deployment/download-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ export PERFORMANCE_MONGODB_PASSWORD=`generate_password`
export OPENHIM_MONGODB_PASSWORD=`generate_password`
export WEBHOOKS_MONGODB_PASSWORD=`generate_password`
export NOTIFICATION_MONGODB_PASSWORD=`generate_password`
export EVENTS_MONGODB_PASSWORD=`generate_password`

#
# Elasticsearch credentials
Expand Down
6 changes: 6 additions & 0 deletions infrastructure/docker-compose.app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ services:
- HOST=0.0.0.0
- NODE_ENV=production
- LANGUAGES=en,fr
- EVENTS_URL=http://events:5555/
- SENTRY_DSN=${SENTRY_DSN:-}
- DISABLE_RATE_LIMIT=true
- REDIS_HOST=redis.${STACK}_app_net
Expand Down Expand Up @@ -270,6 +271,11 @@ services:
aliases: []
dependencies_minio_net:
aliases: []
events:
image: opencrvs/ocrvs-events:${VERSION}
restart: unless-stopped
environment:
- MONGO_URL=mongodb://${STACK}__events:${METRICS_MONGODB_PASSWORD}@mongo1/${STACK}__events?replicaSet=rs0

workflow:
image: opencrvs/ocrvs-workflow:${VERSION}
Expand Down
22 changes: 22 additions & 0 deletions infrastructure/mongodb/on-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,28 @@ else
EOF
fi

EVENTS_USER=$(echo $(checkIfUserExists "${DATABASE_PREFIX}__events" "${DATABASE_PREFIX}__events"))
if [[ $EVENTS_USER != "FOUND" ]]; then
echo "events user not found"
mongo $(mongo_credentials) --host $HOST <<EOF
use ${DATABASE_PREFIX}__events
db.createUser({
user: '${DATABASE_PREFIX}__events',
pwd: '$EVENTS_MONGODB_PASSWORD',
roles: [{ role: 'readWrite', db: "${DATABASE_PREFIX}__events" }]
})
EOF
else
echo "events user exists"
mongo $(mongo_credentials) --host $HOST <<EOF
use ${DATABASE_PREFIX}__events
db.updateUser('${DATABASE_PREFIX}__events', {
pwd: '$EVENTS_MONGODB_PASSWORD',
roles: [{ role: 'readWrite', db: "${DATABASE_PREFIX}__events" }]
})
EOF
fi

OPENHIM_USER=$(echo $(checkIfUserExists "${DATABASE_PREFIX}__openhim" "${DATABASE_PREFIX}__openhim-dev"))
if [[ $OPENHIM_USER != "FOUND" ]]; then
echo "openhim user not found"
Expand Down

0 comments on commit 80e8b78

Please sign in to comment.