c45e58c732
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
40 lines
1.4 KiB
YAML
40 lines
1.4 KiB
YAML
# Lokal geliştirme: MongoDB tek düğümlü replica set (rs0) — transaction için zorunlu.
|
||
# Başlat: npm run db:up Durdur: npm run db:down Veriyi sil: docker compose down -v
|
||
name: butcem
|
||
|
||
services:
|
||
mongo:
|
||
image: mongo:9
|
||
container_name: butcem-mongo
|
||
command: ["mongod", "--replSet", "rs0", "--bind_ip_all", "--port", "27017"]
|
||
ports:
|
||
# Yalnızca bu makineden erişilebilir. Host portu 27019 (27017/27018 bu makinede dolu);
|
||
# değiştirmek için: BUTCEM_MONGO_PORT=xxxxx npm run db:up
|
||
- "127.0.0.1:${BUTCEM_MONGO_PORT:-27019}:27017"
|
||
volumes:
|
||
- mongo-data:/data/db
|
||
- mongo-config:/data/configdb
|
||
restart: unless-stopped
|
||
# Healthcheck replica set'i ilk çalıştırmada başlatır; düğüm PRIMARY olana kadar "unhealthy" kalır.
|
||
# Üye adresi konteyner içinden "localhost:27017"; uygulama host'tan directConnection=true ile
|
||
# bağlandığı için üye listesini kullanmaz, port eşlemesi sorun olmaz.
|
||
healthcheck:
|
||
test:
|
||
- CMD
|
||
- mongosh
|
||
- --quiet
|
||
- --eval
|
||
- >-
|
||
try { rs.status() } catch (e) {
|
||
rs.initiate({ _id: "rs0", members: [{ _id: 0, host: "localhost:27017" }] }) }
|
||
if (!db.hello().isWritablePrimary) { quit(1) }
|
||
interval: 5s
|
||
timeout: 10s
|
||
start_period: 20s
|
||
start_interval: 2s
|
||
retries: 30
|
||
|
||
volumes:
|
||
mongo-data:
|
||
mongo-config:
|