Set up MongoDB as a single-server replication set

This is necessary because the account server uses transactions, which only work in a replication set.
This commit is contained in:
Matthew Lopez 2023-12-18 20:51:45 -05:00
parent a82ecdae31
commit 1d6f6a9f59
No known key found for this signature in database
GPG Key ID: 302A6EE3D63B7E0E
4 changed files with 18 additions and 1 deletions

View File

@ -53,6 +53,12 @@ services:
# For connecting with mongosh or MongoDB Compass
- 127.0.0.1:27017:27017
volumes:
- type: bind
source: ./config/mongod.conf
target: /etc/mongod.conf
- type: bind
source: ./config/mongodb-init.js
target: /docker-entrypoint-initdb.d/init.js
- type: volume
source: mongodb-database
target: /data/db

10
config/mongod.conf Normal file
View File

@ -0,0 +1,10 @@
storage:
dbPath: /data/db
net:
port: 27017
bindIp: 0.0.0.0
replication:
oplogSizeMB: 2000
replSetName: rs

1
config/mongodb-init.js Normal file
View File

@ -0,0 +1 @@
rs.initiate();

View File

@ -1,7 +1,7 @@
GENERATE_NEW_KEYS=true
PN_ACT_PREFER_ENV_CONFIG=true
PN_ACT_CONFIG_HTTP_PORT=8080
PN_ACT_CONFIG_MONGO_CONNECTION_STRING=mongodb://mongodb:27017/pretendo_account
PN_ACT_CONFIG_MONGO_CONNECTION_STRING=mongodb://mongodb:27017/pretendo_account?replicaSet=rs&directConnection=true
PN_ACT_CONFIG_MONGOOSE_OPTION_useNewUrlParser=true
PN_ACT_CONFIG_MONGOOSE_OPTION_useUnifiedTopology=true
PN_ACT_CONFIG_S3_ENDPOINT=http://minio:9000