Create tables automatically.
This commit is contained in:
parent
891c818d2e
commit
508cc58be5
3 changed files with 16 additions and 0 deletions
|
@ -1,3 +1,4 @@
|
|||
FROM mongo:7.0
|
||||
HEALTHCHECK --interval=5s --timeout=3s --start-period=0s --retries=5 \
|
||||
CMD echo 'db.stats().ok' | mongosh --norc --quiet --host=localhost:27017
|
||||
COPY mongo-init.js /docker-entrypoint-initdb.d/
|
||||
|
|
|
@ -2,3 +2,8 @@ version: "3.7"
|
|||
services:
|
||||
mongodb:
|
||||
build: .
|
||||
image: ghcr.io/benzine-framework/mongodb:latest
|
||||
environment:
|
||||
- MONGO_INITDB_ROOT_USERNAME=admin
|
||||
- MONGO_INITDB_ROOT_PASSWORD=password
|
||||
- MONGO_INITDB_DATABASE=testdb
|
||||
|
|
10
mongodb/mongo-init.js
Normal file
10
mongodb/mongo-init.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
db.createUser({
|
||||
user: process.env.MONGO_INITDB_ROOT_USERNAME,
|
||||
pwd: process.env.MONGO_INITDB_ROOT_PASSWORD,
|
||||
roles: [
|
||||
{
|
||||
role: "readWrite",
|
||||
db: process.env.MONGO_INITDB_DATABASE,
|
||||
},
|
||||
],
|
||||
});
|
Loading…
Reference in a new issue