Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update local dev MongoDB versions #15334

Open
wants to merge 16 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
working mongo docker compose 🎉
negue committed Dec 3, 2024
commit 82445d23600a52bb84e0ba91ac1a0a3483122ceb
4 changes: 2 additions & 2 deletions config.json.example
Original file line number Diff line number Diff line change
@@ -34,8 +34,8 @@
"LOGGLY_TOKEN": "example-token",
"LOG_REQUESTS_EXCESSIVE_MODE": "false",
"MAINTENANCE_MODE": "false",
"NODE_DB_URI": "mongodb://localhost:27017/habitica-dev?replicaSet=rs&directConnection=true",
"TEST_DB_URI": "mongodb://localhost:27017/habitica-test?replicaSet=rs&directConnection=true",
"NODE_DB_URI": "mongodb://localhost:27017/habitica-dev?replicaSet=rs&directConnection=true&readPreference=secondary",
"TEST_DB_URI": "mongodb://localhost:27017/habitica-test?replicaSet=rs&directConnection=true&readPreference=secondary",
"MONGODB_POOL_SIZE": "10",
"MONGODB_SOCKET_TIMEOUT": "20000",
"NODE_ENV": "development",
46 changes: 34 additions & 12 deletions docker-compose.mongo-local.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,37 @@
# big thanks to https://pakisan.github.io/posts/docker-compose-mongodb-single-node-replica-set/ <3

version: "3.9"
networks:
mongodb-network:
name: "mongodb-network"
driver: bridge
services:
mongo:
image: mongo:7.0
restart: unless-stopped
command: ["--replSet", "rs", "--bind_ip_all", "--port", "27017"]
healthcheck:
test: echo "try { rs.status() } catch (err) { rs.initiate() }" | mongosh --port 27017 --quiet
interval: 10s
timeout: 30s
start_period: 0s
retries: 30
volumes:
- "./mongodb-data2:/data/db"
mongodb:
image: "mongo:7.0"
container_name: "mongodb"
networks:
- mongodb-network
hostname: "mongodb"
ports:
- "27017:27017"
restart: "unless-stopped"
volumes:
- "./mongodb-data:/data/db"
entrypoint: [ "/usr/bin/mongod", "--bind_ip_all", "--replSet", "rs" ]
mongoinit:
image: "mongo:7.0"
container_name: "mongodb_replSet_initializer"
restart: "on-failure" # WITHOUT THIS, the initializer tries only once and fails
depends_on:
- mongodb
networks:
- mongodb-network

command: >
mongosh --host mongodb:27017 --eval "rs.initiate({
_id: \"rs\",
members: [
{_id: 0, host: \"mongodb\"}
]
})"
Loading