Add authentication mecanisme and secure database.
This commit is contained in:
@@ -4,4 +4,11 @@ services:
|
||||
container_name: "mongo"
|
||||
image: "mongo:latest"
|
||||
ports:
|
||||
- "27017:27017"
|
||||
- "27017:27017"
|
||||
environment:
|
||||
- "MONGO_INITDB_DATABASE=express-test"
|
||||
- "MONGO_INITDB_ROOT_USERNAME=god"
|
||||
- "MONGO_INITDB_ROOT_PASSWORD=P@ssword"
|
||||
volumes:
|
||||
- "./mongodb/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d/:ro"
|
||||
- "./mongodb/data:/data/db"
|
||||
12
docker/mongodb/docker-entrypoint-initdb.d/initDatabase.js
Normal file
12
docker/mongodb/docker-entrypoint-initdb.d/initDatabase.js
Normal file
@@ -0,0 +1,12 @@
|
||||
db.test.insert({id: 'test'});
|
||||
|
||||
db.createUser(
|
||||
{
|
||||
user: "application_user",
|
||||
pwd: "Password1",
|
||||
roles:
|
||||
[
|
||||
{ role: "readWrite", db: "db_application" }
|
||||
]
|
||||
}
|
||||
)
|
||||
Reference in New Issue
Block a user