mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
mongo docker-compose
This commit is contained in:
parent
5b4f94832d
commit
834b88f68f
@ -28,8 +28,8 @@ mongo:
|
||||
dbTimeout: 60
|
||||
dbDatabase: openIM #mongo db 默认即可
|
||||
dbSource: admin
|
||||
dbUserName: #mongo用户名,建议先不设置
|
||||
dbPassword: #mongo密码,建议先不设置
|
||||
dbUserName: openIM #mongo用户名,建议先不设置
|
||||
dbPassword: openIM #mongo密码,建议先不设置
|
||||
dbMaxPoolSize: 100
|
||||
dbRetainChatRecords: 3650 #mongo保存离线消息时间(天),根据需求修改
|
||||
|
||||
|
@ -20,17 +20,21 @@ services:
|
||||
ports:
|
||||
- 37017:27017
|
||||
container_name: mongo
|
||||
command: --wiredTigerCacheSizeGB 1
|
||||
command: --wiredTigerCacheSizeGB 1 --auth
|
||||
volumes:
|
||||
- ./components/mongodb/data/db:/data/db
|
||||
- ./components/mongodb/data/logs:/data/logs
|
||||
- ./components/mongodb/data/conf:/etc/mongo
|
||||
- ./script/mongo-init.sh:/docker-entrypoint-initdb.d/mongo-init.sh
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
# cache
|
||||
- wiredTigerCacheSizeGB=1
|
||||
#- MONGO_INITDB_ROOT_USERNAME=openIM
|
||||
#- MONGO_INITDB_ROOT_PASSWORD=openIM
|
||||
MONGO_USERNAME: openIM
|
||||
MONGO_PASSWORD: openIM
|
||||
MONGO_INITDB_ROOT_USERNAME: root
|
||||
MONGO_INITDB_ROOT_PASSWORD: root
|
||||
MONGO_INITDB_DATABASE: openIM
|
||||
#TZ: Asia/Shanghai
|
||||
restart: always
|
||||
|
||||
|
12
script/mongo-init.sh
Normal file
12
script/mongo-init.sh
Normal file
@ -0,0 +1,12 @@
|
||||
mongo -- "$MONGO_INITDB_DATABASE" <<EOF
|
||||
db = db.getSiblingDB('admin')
|
||||
db.auth('$MONGO_INITDB_ROOT_USERNAME', '$MONGO_INITDB_ROOT_PASSWORD')
|
||||
db = db.getSiblingDB('$MONGO_INITDB_DATABASE')
|
||||
db.createUser({
|
||||
user: "$MONGO_USERNAME",
|
||||
pwd: "$MONGO_PASSWORD",
|
||||
roles: [
|
||||
{ role: 'readWrite', db: '$MONGO_INITDB_DATABASE' }
|
||||
]
|
||||
})
|
||||
EOF
|
Loading…
x
Reference in New Issue
Block a user