version: '3.8'

services:
  mongodb:
    image: mongo:7
    container_name: normogen-mongodb
    restart: unless-stopped
    environment:
      MONGO_INITDB_DATABASE: normogen
    ports:
      - "27017:27017"
    volumes:
      - mongodb_data:/data/db
    healthcheck:
      test: echo 'db.runCommand("ping").ok' | mongosh localhost:27017/test --quiet
      interval: 10s
      timeout: 5s
      retries: 5

  backend:
    build: .
    container_name: normogen-backend
    restart: unless-stopped
    ports:
      - "8000:8080"
    environment:
      - DATABASE_URI=mongodb://mongodb:27017
      - DATABASE_NAME=normogen
      - JWT_SECRET=your-secret-key-change-in-production
      - SERVER_HOST=0.0.0.0
      - SERVER_PORT=8080
      - RUST_LOG=debug
    depends_on:
      mongodb:
        condition: service_healthy
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

volumes:
  mongodb_data:
