services:
  # ── MySQL 데이터베이스 ──
  db:
    image: mysql:8.0
    container_name: sg-db
    restart: unless-stopped
    env_file:
      - .env
    ports:
      - "3308:3306"
    volumes:
      - db_data:/var/lib/mysql
      - ./back/init-db:/docker-entrypoint-initdb.d

  # ── FastAPI 백엔드 ──
  api:
    build: ./back
    container_name: sg-api
    restart: unless-stopped
    ports:
      - "5330:5330"
    env_file:
      - ./back/.env
    command: uvicorn main:app --host 0.0.0.0 --port 5330 --reload
    volumes:
      - ./back:/app
      - ./NTT-DATA-2605131357.xlsx:/app/data/manual.xlsx:ro
    extra_hosts:
      - "host.docker.internal:host-gateway"
    depends_on:
      - db
      - vecdb

  # ── Qdrant 벡터 DB ──
  vecdb:
    image: qdrant/qdrant:v1.11.3
    container_name: sg-vecdb
    restart: unless-stopped
    ports:
      - "6333:6333"   # REST + Dashboard (http://localhost:6333/dashboard)
      - "6334:6334"   # gRPC
    volumes:
      - vec_data:/qdrant/storage

  # ── Nginx 프론트엔드 ──
  web:
    build: ./front
    container_name: sg-web
    restart: unless-stopped
    ports:
      - "81:80"
    environment:
      - APP_PREFIX=${APP_PREFIX}
      - API_PORT=${API_PORT}
    volumes:
      - ./front:/usr/share/nginx/html
    depends_on:
      - api

volumes:
  db_data:
  vec_data:
