Skip to content
Snippets Groups Projects
Commit 5cec6533 authored by abdu's avatar abdu
Browse files

add init db script

parent 271e1460
No related branches found
No related tags found
No related merge requests found
...@@ -20,8 +20,15 @@ services: ...@@ -20,8 +20,15 @@ services:
# virtual drive for storage of the db between reboots # virtual drive for storage of the db between reboots
volumes: volumes:
- ./data/db:/data/db - ./data/db:/data/db
- ./init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js
networks: networks:
- todo-network - todo-network
# mongo is being initialized too late so we have to wait for it
healthcheck:
test: [ "CMD", "mongo", "--eval", "db.adminCommand('ping')" ]
interval: 10s
timeout: 5s
retries: 5
# backend stuff # backend stuff
backend: backend:
...@@ -42,7 +49,8 @@ services: ...@@ -42,7 +49,8 @@ services:
ports: ports:
- "9876:9876" - "9876:9876"
depends_on: depends_on:
- mongodb mongodb:
condition: service_healthy
# were gonna use this network for both our backend and frontend # were gonna use this network for both our backend and frontend
networks: networks:
......
db = db.getSiblingDB('admin')
if(db.system.users.find({user: "tododbuser"}).count() === 0){
db.createUser({
user: "tododbuser",
pwd: "tododbadminpassword",
roles: [{
role: "readWrite", db: "todo"
}]
})
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment