7 changed files with 47 additions and 7 deletions
@ -1,5 +1,8 @@ |
|||||||
FROM mongo |
FROM mongo |
||||||
|
|
||||||
COPY dbusersetup.js /docker-entrypoint-initdb.d |
COPY db-user-setup.sh /docker-entrypoint-initdb.d |
||||||
|
|
||||||
|
# ENV mongousr=myTester |
||||||
|
# ENV mongopwd=test |
||||||
|
|
||||||
EXPOSE 27017 |
EXPOSE 27017 |
||||||
@ -1,10 +1,8 @@ |
|||||||
// create test user
|
|
||||||
use test |
|
||||||
db.createUser( |
db.createUser( |
||||||
{ |
{ |
||||||
user: "myTester", |
user: "$mongousr", |
||||||
pwd: "test", |
pwd: "$mongopwd", |
||||||
roles: [ { role: "readWrite", db: "test" }, |
roles: [ { role: "readWrite", db: "test" }, |
||||||
{ role: "read", db: "reporting" } ] |
{ role: "read", db: "reporting" } ] |
||||||
} |
} |
||||||
) |
); |
||||||
@ -0,0 +1,10 @@ |
|||||||
|
set -e |
||||||
|
|
||||||
|
mongo <<EOF |
||||||
|
db.createUser({ |
||||||
|
user: '$mongousr', |
||||||
|
pwd: '$mongopwd', |
||||||
|
roles: [ { role: "readWrite", db: "test" }, |
||||||
|
{ role: "read", db: "reporting" } ] |
||||||
|
}) |
||||||
|
EOF |
||||||
Loading…
Reference in new issue