docker-compose.dev.yml's mongodb service sets MONGO_INITDB_ROOT_USERNAME/ PASSWORD, which makes the official mongo image enable --auth — but the app service's MONGODB_URI was unauthenticated (mongodb://mongodb:27017/mozdit). Same bug class as MITHOME-32 (staging/production), but that ticket covers docker-compose.staging.yml /docker-compose.prod.yml specifically, not this dev file — hence the separate MITHOME-98. Why /api/health never caught it: that route is a pure liveness check and never touches MongoDB. Only an endpoint that actually performs a DB operation exercises the bug. Verified live (docker compose -f docker-compose.dev.yml up --build): - Reproduced the failure first: inside the running app container, a plain `mongodb://mongodb:27017/mozdit` connection's findOne() throws "Command find requires authentication" — confirms the hypothesis that the app fails only on a real query, not at startup. - With the fix in place: POST /api/contact returns 200 with a submissionId, and the document is actually present in contact_submissions (checked via mongosh) — a real, previously- broken write path now works end to end. - npm test: 58/58 passed (unaffected, as expected for a docker-compose/doc-only change). Also fixed the same stale unauthenticated example in DOCKER.md. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
113 lines
2.9 KiB
YAML
Executable File
113 lines
2.9 KiB
YAML
Executable File
version: '3.8'
|
|
|
|
services:
|
|
# Next.js Application
|
|
app:
|
|
build:
|
|
context: ./proto
|
|
dockerfile: Dockerfile
|
|
target: builder # Use builder stage for development
|
|
container_name: mozdit-app-dev
|
|
ports:
|
|
- "127.0.0.1:8080:3000"
|
|
environment:
|
|
- NODE_ENV=development
|
|
# WHY authSource=admin: the mongodb service below only creates a root
|
|
# user (via MONGO_INITDB_ROOT_USERNAME/PASSWORD), which forces --auth
|
|
# on the mongod process — an unauthenticated URI fails every query
|
|
# with "Command find requires authentication" (MITHOME-98).
|
|
- MONGODB_URI=mongodb://admin:password123@mongodb:27017/mozdit?authSource=admin
|
|
- MONGODB_DB=mozdit
|
|
- NEXT_PUBLIC_SITE_URL=http://localhost:8080
|
|
- NEXT_PUBLIC_COMPANY_NAME=mozdIT Bt.
|
|
- NEXT_PUBLIC_CONTACT_EMAIL=info@mozdit.hu
|
|
- NEXT_PUBLIC_WEBMAIL_URL=https://mail.mozdit.hu
|
|
- LOKI_HOST=http://loki:3100
|
|
volumes:
|
|
- ./proto:/app
|
|
- /app/node_modules
|
|
- /app/.next
|
|
command: npm run dev
|
|
depends_on:
|
|
- mongodb
|
|
- loki
|
|
networks:
|
|
- mozdit-network
|
|
restart: unless-stopped
|
|
|
|
# MongoDB Database
|
|
mongodb:
|
|
image: mongo:7.0
|
|
container_name: mozdit-mongodb-dev
|
|
ports:
|
|
- "127.0.0.1:27018:27017"
|
|
environment:
|
|
- MONGO_INITDB_ROOT_USERNAME=admin
|
|
- MONGO_INITDB_ROOT_PASSWORD=password123
|
|
- MONGO_INITDB_DATABASE=mozdit
|
|
volumes:
|
|
- mongodb_data:/data/db
|
|
- ./docker/mongodb/init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro
|
|
networks:
|
|
- mozdit-network
|
|
restart: unless-stopped
|
|
|
|
# MongoDB Express (Web UI)
|
|
mongo-express:
|
|
image: mongo-express:1.0.2
|
|
container_name: mozdit-mongo-express-dev
|
|
ports:
|
|
- "127.0.0.1:8081:8081"
|
|
environment:
|
|
- ME_CONFIG_MONGODB_ADMINUSERNAME=admin
|
|
- ME_CONFIG_MONGODB_ADMINPASSWORD=password123
|
|
- ME_CONFIG_MONGODB_URL=mongodb://admin:password123@mongodb:27017/
|
|
- ME_CONFIG_BASICAUTH=false
|
|
depends_on:
|
|
- mongodb
|
|
networks:
|
|
- mozdit-network
|
|
restart: unless-stopped
|
|
|
|
# Loki for Logging
|
|
loki:
|
|
image: grafana/loki:2.9.0
|
|
container_name: mozdit-loki-dev
|
|
ports:
|
|
- "127.0.0.1:3100:3100"
|
|
command: -config.file=/etc/loki/local-config.yaml
|
|
volumes:
|
|
- loki_data:/loki
|
|
networks:
|
|
- mozdit-network
|
|
restart: unless-stopped
|
|
|
|
# Grafana for Monitoring
|
|
grafana:
|
|
image: grafana/grafana:10.2.0
|
|
container_name: mozdit-grafana-dev
|
|
ports:
|
|
- "127.0.0.1:3001:3000"
|
|
environment:
|
|
- GF_SECURITY_ADMIN_PASSWORD=admin123
|
|
volumes:
|
|
- grafana_data:/var/lib/grafana
|
|
- ./docker/grafana/provisioning:/etc/grafana/provisioning
|
|
depends_on:
|
|
- loki
|
|
networks:
|
|
- mozdit-network
|
|
restart: unless-stopped
|
|
|
|
volumes:
|
|
mongodb_data:
|
|
driver: local
|
|
loki_data:
|
|
driver: local
|
|
grafana_data:
|
|
driver: local
|
|
|
|
networks:
|
|
mozdit-network:
|
|
driver: bridge
|