diff --git a/docker-compose.tmpl.yml b/docker-compose.tmpl.yml index b6df2ab..b1ee846 100644 --- a/docker-compose.tmpl.yml +++ b/docker-compose.tmpl.yml @@ -103,6 +103,13 @@ services: mongodb: image: mongo:4.4 restart: unless-stopped + volumes: + - ./mod/mongo/mongod.conf:/etc/mongod.conf + - ./mod/mongo/init-replica.sh:/docker-entrypoint-initdb.d/init-replica.sh + tmpfs: + - /data/configdb + - /data/db + command: mongod --config /etc/mongod.conf --oplogSize 8 --replSet rs0 --noauth healthcheck: test: bash -c "if mongo --eval 'quit(db.runCommand({ ping':' 1 }).ok ? 0 ':' 2)'; then exit 0; fi; exit 1;" networks: diff --git a/mod/html5/entrypoint.sh b/mod/html5/entrypoint.sh index 09f7694..763522a 100755 --- a/mod/html5/entrypoint.sh +++ b/mod/html5/entrypoint.sh @@ -2,7 +2,7 @@ set -e cd /app -# export MONGO_OPLOG_URL=mongodb://10.7.7.6/local +export MONGO_OPLOG_URL=mongodb://10.7.7.6/local export MONGO_URL=mongodb://10.7.7.6/meteor export NODE_ENV=production export SERVER_WEBSOCKET_COMPRESSION=0 diff --git a/mod/mongo/init-replica.sh b/mod/mongo/init-replica.sh new file mode 100755 index 0000000..e572796 --- /dev/null +++ b/mod/mongo/init-replica.sh @@ -0,0 +1,16 @@ +#!/bin/sh +set -e + + +host=${HOSTNAME:-$(hostname -f)} + +# init replset with defaults +mongo local --eval "rs.initiate({ + _id: 'rs0', + members: [ { _id: 0, host: '127.0.0.1:27017' } ] +})" + +echo "Waiting to become a master" +echo 'while (!db.isMaster().ismaster) { sleep(100); }' | mongo + +echo "I'm the master!" \ No newline at end of file diff --git a/mod/mongo/mongod.conf b/mod/mongo/mongod.conf new file mode 100644 index 0000000..40fbdaf --- /dev/null +++ b/mod/mongo/mongod.conf @@ -0,0 +1,28 @@ +# mongod.conf + +# for documentation of all options, see: +# http://docs.mongodb.org/manual/reference/configuration-options/ + +storage: + dbPath: /data/db + journal: + enabled: true + wiredTiger: + engineConfig: + cacheSizeGB: 0 + journalCompressor: none + directoryForIndexes: true + collectionConfig: + blockCompressor: none + indexConfig: + prefixCompression: false + + +net: + port: 27017 + bindIp: 0.0.0.0 + + +replication: + replSetName: rs0 +