version: '3.8'

services:
  # Ana uygulama
  app:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: cadde-auto-app
    ports:
      - "3000:3000"
    environment:
      - NODE_ENV=production
      - VEHICLE_API_MOCK=true
      - SESSION_SECRET=your-super-secret-session-key-here
      - ADMIN_PASSWORD_HASH=bc3a62e99574f0cafaaaca73d419743d:bdab0a68af6ee97bec70c082dbb93301aa8c44f3c68de86700d2f9d2568606bd464c29e6a3304244e22fd45b8a28a56098a39243072d8cf0ded9e7670a03af8a
    volumes:
      - ./data:/app/data
      - ./uploads:/app/uploads
      - app-logs:/app/logs
    restart: unless-stopped
    networks:
      - cadde-auto-network
    depends_on:
      - mongodb
    healthcheck:
      test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/api/health"]
      timeout: 5s
      retries: 5
      start_period: 20s

  # MongoDB (opsiyonel - mock mode kullanıyorsanız gerekli değil)
  mongodb:
    image: mongo:6.0
    container_name: cadde-auto-db
    environment:
      MONGO_INITDB_ROOT_USERNAME: admin
      MONGO_INITDB_ROOT_PASSWORD: secure_password_here
      MONGO_INITDB_DATABASE: cadde_auto
    volumes:
      - mongodb-data:/data/db
      - ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
    ports:
      - "27017:27017"
    restart: unless-stopped
    networks:
      - cadde-auto-network

  # Nginx Reverse Proxy
  nginx:
    image: nginx:alpine
    container_name: cadde-auto-nginx
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
      - ./nginx/ssl:/etc/nginx/ssl:ro
      - nginx-logs:/var/log/nginx
    depends_on:
      - app
    restart: unless-stopped
    networks:
      - cadde-auto-network

  # Redis (cache için - opsiyonel)
  redis:
    image: redis:7-alpine
    container_name: cadde-auto-redis
    command: redis-server --requirepass your_redis_password
    ports:
      - "6379:6379"
    volumes:
      - redis-data:/data
    restart: unless-stopped
    networks:
      - cadde-auto-network

volumes:
  mongodb-data:
    driver: local
  redis-data:
    driver: local
  app-logs:
    driver: local
  nginx-logs:
    driver: local

networks:
  cadde-auto-network:
    driver: bridge
