-
Notifications
You must be signed in to change notification settings - Fork 2
/
entryProd.js
31 lines (22 loc) · 1.32 KB
/
entryProd.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 = cat(_getEnv("MONGO_INITDB_ROOT_USERNAME_FILE"));
mongoRootPassword = cat(_getEnv("MONGO_INITDB_ROOT_PASSWORD_FILE"));
mongoAdminUser = cat(_getEnv("MONGO_DB_ADMIN_USERNAME_FILE"));
mongoAdminPassword = cat(_getEnv("MONGO_DB_ADMIN_PASSWORD_FILE"));
mongoReplicaUser = cat(_getEnv("MONGO_REPLICA_ADMIN_USERNAME_FILE"));
mongoReplicaPassword = cat(_getEnv("MONGO_REPLICA_ADMIN_PASSWORD_FILE"));
mongoUser = cat(_getEnv("MONGO_USER_USERNAME_FILE"));
mongoPassword = cat(_getEnv("MONGO_USER_PASSWORD_FILE"));
// 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: _getEnv("MONGO_INITDB_DATABASE")}]});
// creation of the replica user
db.createUser({user: mongoReplicaUser, pwd: mongoReplicaPassword, roles: [{role: "clusterAdmin", db: _getEnv("MONGO_INITDB_DATABASE")}]});
// 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})