-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bfc98f5
commit 4293694
Showing
7 changed files
with
102 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
version: "3.8" | ||
|
||
services: | ||
charterafrica: | ||
depends_on: | ||
mongodb_container: | ||
condition: service_healthy | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.charterafrica | ||
args: | ||
MONGO_URL: mongodb://root:rootpassword@host.docker.internal:27017/charterafrica?authSource=admin | ||
PAYLOAD_SECRET_KEY: ${PAYLOAD_SECRET_KEY} | ||
SENTRY_AUTH_TOKEN: ${SENTRY_AUTH_TOKEN} | ||
SENTRY_ORG: ${SENTRY_ORG} | ||
NEXT_PUBLIC_SENTRY_DSN: ${CHARTERAFRICA_SENTRY_DSN} | ||
SENTRY_ENV: ${SENTRY_ENV} | ||
SENTRY_PROJECT: ${SENTRY_PROJECT} | ||
ports: | ||
- 3000:3000 | ||
container_name: charterafrica | ||
env_file: | ||
- apps/charterafrica/.env.local | ||
networks: | ||
- net | ||
|
||
mongodb_container: | ||
container_name: mongodb_container | ||
image: mongo:latest | ||
environment: | ||
MONGO_INITDB_ROOT_USERNAME: root | ||
MONGO_INITDB_ROOT_PASSWORD: rootpassword | ||
ports: | ||
- 27017:27017 | ||
volumes: | ||
- data_container:/data/db | ||
- ./mongo-keyfile:/etc/mongo-keyfile | ||
- ./scripts/db-init.sh:/scripts/db-init.sh | ||
restart: always | ||
healthcheck: | ||
test: echo 'db.runCommand("ping").ok' | mongosh mongodb_container:27017/charterafrica --quiet | ||
interval: 10s | ||
timeout: 5s | ||
retries: 3 | ||
command: | ||
[ | ||
"--replSet", | ||
"dbrs", | ||
"--bind_ip_all", | ||
"--keyFile", | ||
"/etc/mongo-keyfile/mongo-keyfile", | ||
] | ||
networks: | ||
- net | ||
volumes: | ||
data_container: | ||
networks: | ||
net: | ||
driver: bridge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
docker-compose --env-file apps/charterafrica/.env.local up charterafrica --build -d | ||
|
||
sleep 5 | ||
|
||
docker exec mongodb_container /scripts/db-init.sh | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
DELAY=5 | ||
|
||
mongosh -u root -p rootpassword --authenticationDatabase admin <<EOF | ||
var config = { | ||
"_id": "dbrs", | ||
"version": 1, | ||
"members": [ | ||
{ | ||
"_id": 1, | ||
"host": "mongodb_container:27017", | ||
"priority": 1 | ||
}, | ||
] | ||
}; | ||
rs.initiate(config, { force: true }); | ||
EOF | ||
|
||
echo "****** Waiting for ${DELAY} seconds for replicaset configuration to be applied ******" | ||
|
||
sleep $DELAY | ||
|
||
mongosh -u root -p rootpassword --authenticationDatabase admin <<EOF | ||
rs.status(); | ||
db.createUser({ | ||
user: "root", | ||
pwd: "rootpassword", | ||
roles: [{ role: "root", db: "admin" }], | ||
}); | ||
EOF |