HabitRPG / habitica

A habit tracker app which treats your goals like a Role Playing Game.
https://habitica.com
Other
12.03k stars 4.1k forks source link

Enable Mongo Replication Sets in Docker / Upgrade Mongo to 5.0.23 in Docker #15298

Closed DesBlock closed 2 months ago

DesBlock commented 3 months ago

Fixes #14349

Changes

server:
  build:
    context: .
    dockerfile: ./Dockerfile-Dev
  command: ["npm", "start"]
  depends_on:
    mongo:
      condition: service_healthy
mongo:
image: mongo:5.0.23
  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
    start_interval: 1s
    retries: 30

UUID: Self-hosted

DesBlock commented 3 months ago

Additionally, you may need to set the NODE_DB_URI and TEST_DB_URI values to the service name used within docker-compose.dev.yaml. In the case of the stock docker-compose file that would be mongo

config.json:  "NODE_DB_URI": "mongodb://mongo:27017/habitica?replicaSet=rs",
config.json:  "TEST_DB_URI": "mongodb://mongo:27017/habitica-test?replicaSet=rs",
SabreCat commented 2 months ago

Looking good, @DesBlock! If you do ever set up an account on habitica.com, we can give you contrib credit there!