mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2025-12-19 10:07:46 -05:00
49 lines
1.0 KiB
YAML
49 lines
1.0 KiB
YAML
services:
|
|
db:
|
|
image: mongo:8.0
|
|
container_name: mongodb
|
|
command: mongod --replSet rs0
|
|
restart: unless-stopped
|
|
hostname: mongodb
|
|
ports:
|
|
- 27017:27017
|
|
volumes:
|
|
- db-data:/data/db
|
|
healthcheck:
|
|
test: ['CMD', 'mongosh', '--eval', "db.adminCommand('ping')"]
|
|
interval: 2s
|
|
retries: 5
|
|
|
|
setup:
|
|
image: mongo:8.0
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
restart: on-failure
|
|
# This will try to initiate the replica set, until it succeeds twice (i.e. until the replica set is already initialized)
|
|
command: >
|
|
mongosh --host mongodb:27017 --eval '
|
|
var cfg = {
|
|
_id: "rs0",
|
|
members: [
|
|
{ _id: 0, host: "mongodb:27017" }
|
|
]
|
|
};
|
|
try {
|
|
rs.initiate(cfg);
|
|
} catch (err) {
|
|
if(err.codeName !== "AlreadyInitialized") throw err;
|
|
}
|
|
'
|
|
|
|
mailpit:
|
|
restart: unless-stopped
|
|
image: axllent/mailpit
|
|
ports:
|
|
- '1025:1025'
|
|
- '8025:8025'
|
|
|
|
volumes:
|
|
db-data:
|
|
driver: local
|