-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathentry.js
31 lines (22 loc) · 1.2 KB
/
entry.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
mongoRootUser = _getEnv("MONGO_INITDB_ROOT_USERNAME");
mongoRootPassword = _getEnv("MONGO_INITDB_ROOT_PASSWORD");
mongoAdminUser = _getEnv("MONGO_DB_ADMIN_USERNAME");
mongoAdminPassword = _getEnv("MONGO_DB_ADMIN_PASSWORD");
mongoReplicaUser = _getEnv("MONGO_REPLICA_ADMIN_USERNAME");
mongoReplicaPassword = _getEnv("MONGO_REPLICA_ADMIN_PASSWORD");
mongoUser = _getEnv("MONGO_USER_USERNAME");
mongoPassword = _getEnv("MONGO_USER_PASSWORD");
// authenticate with root credentials
db.auth(mongoRootUser, mongoRootPassword);
// select database
db = db.getSiblingDB(_getEnv("MONGO_INITDB_DATABASE"));
// creation of the admin user
db.createUser({user: mongoAdminUser, pwd: mongoAdminPassword, roles: [{role: "userAdminAnyDatabase", db: "admin"}]});
// creation of the replica user
db.createUser({user: mongoReplicaUser, pwd: mongoReplicaPassword, roles: [{role: "clusterAdmin", db: "admin"}]});
// select database
db = db.getSiblingDB(_getEnv("MONGO_DATABASE"));
// creation of the crud user
db.createUser({user: mongoUser, pwd: mongoPassword, roles: [{role: "readWrite", db: _getEnv("MONGO_DATABASE")}]});
// creation of index on snowflake on the guilds collection
db.guilds.createIndex({"snowflake": 1}, {unique: true})