Skip to content

Commit 411422c

Browse files
committed
Bring sh in line with js in readme. Add note about RBAC
1 parent e80cea2 commit 411422c

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,13 @@ If you are using mongodb < 6.0, you can create a `init-mongo.sh` file with the f
8282
#!/bin/bash
8383

8484
mongo <<EOF
85-
use admin
86-
db.auth("${MONGO_INITDB_ROOT_USERNAME}", "${MONGO_INITDB_ROOT_PASSWORD}")
87-
use ${MONGO_DBNAME}
85+
use MONGO_DBNAME
8886
db.createUser({
89-
user: "${MONGO_USER}",
90-
pwd: "${MONGO_PASS}",
87+
user: "MONGO_USER",
88+
pwd: "MONGO_PASS",
9189
roles: [
92-
{ db: "${MONGO_DBNAME}", role: "dbOwner" },
93-
{ db: "${MONGO_DBNAME}_stat", role: "dbOwner" }
90+
{ db: "MONGO_DBNAME", role: "dbOwner" },
91+
{ db: "MONGO_DBNAME_stat", role: "dbOwner" }
9492
]
9593
})
9694
EOF
@@ -123,7 +121,7 @@ For example:
123121
124122
*Note that the init script method will only work on first run. If you start the Mongodb container without an init script it will generate test data automatically and you will have to manually create your databases, or restart with a clean `/data/db` volume and an init script mounted.*
125123

126-
*If you are using the init JS method do not also set `MONGO_INITDB_ROOT_USERNAME`, `MONGO_INITDB_ROOT_PASSWORD`, or any other "INITDB" values as they will cause conflicts. Setting these variables for the .sh file is necessary*
124+
*If you are using the provided init JS or SH snippets, do not also set `MONGO_INITDB_ROOT_USERNAME`, `MONGO_INITDB_ROOT_PASSWORD`, or any other "INITDB" values as they will cause conflicts. If you wish to enable Role Based Access Control (RBAC) in mongodb, you will have to create your own init JS or SH, or create the user and databases manually.*
127125

128126
You can also run the commands directly against the database using either `mongo` (< 6.0) or `mongosh` (>= 6.0).
129127

readme-vars.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,13 @@ app_setup_block: |
7979
#!/bin/bash
8080
8181
mongo <<EOF
82-
use admin
83-
db.auth("${MONGO_INITDB_ROOT_USERNAME}", "${MONGO_INITDB_ROOT_PASSWORD}")
84-
use ${MONGO_DBNAME}
82+
use MONGO_DBNAME
8583
db.createUser({
86-
user: "${MONGO_USER}",
87-
pwd: "${MONGO_PASS}",
84+
user: "MONGO_USER",
85+
pwd: "MONGO_PASS",
8886
roles: [
89-
{ db: "${MONGO_DBNAME}", role: "dbOwner" },
90-
{ db: "${MONGO_DBNAME}_stat", role: "dbOwner" }
87+
{ db: "MONGO_DBNAME", role: "dbOwner" },
88+
{ db: "MONGO_DBNAME_stat", role: "dbOwner" }
9189
]
9290
})
9391
EOF
@@ -120,7 +118,7 @@ app_setup_block: |
120118
121119
*Note that the init script method will only work on first run. If you start the Mongodb container without an init script it will generate test data automatically and you will have to manually create your databases, or restart with a clean `/data/db` volume and an init script mounted.*
122120
123-
*If you are using the init JS method do not also set `MONGO_INITDB_ROOT_USERNAME`, `MONGO_INITDB_ROOT_PASSWORD`, or any other "INITDB" values as they will cause conflicts. Setting these variables for the .sh file is necessary*
121+
*If you are using the provided init JS or SH snippets, do not also set `MONGO_INITDB_ROOT_USERNAME`, `MONGO_INITDB_ROOT_PASSWORD`, or any other "INITDB" values as they will cause conflicts. If you wish to enable Role Based Access Control (RBAC) in mongodb, you will have to create your own init JS or SH, or create the user and databases manually.*
124122
125123
You can also run the commands directly against the database using either `mongo` (< 6.0) or `mongosh` (>= 6.0).
126124

0 commit comments

Comments
 (0)