version: '3.8'

services:
  backend:
    build:
      context: ./backend
      dockerfile: Dockerfile
    container_name: llm-backend
    command: uvicorn main:app --host 0.0.0.0 --port 8000 --reload
    ports:
      - "23337:8000"
    volumes:
      - ./backend:/app
      - ./data:/app/data
      - ./outputs:/app/outputs
    environment:
      - PYTHONUNBUFFERED=1
      - PYTHONDONTWRITEBYTECODE=1
    restart: unless-stopped
    networks:
      - llm-network
    healthcheck:
      test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

  frontend:
    build:
      context: ./frontend
      dockerfile: Dockerfile
      target: development
    container_name: llm-frontend
    ports:
      - "23338:5173"
    volumes:
      - ./frontend:/app
      - node_modules:/app/node_modules
    environment:
      - NODE_ENV=development
    # 依赖在镜像构建时写入 node_modules volume；package.json 变更见 docs/DOCKER_DEV.md
    command: npm run dev -- --host 0.0.0.0
    depends_on:
      backend:
        condition: service_healthy
    restart: unless-stopped
    networks:
      - llm-network

networks:
  llm-network:
    driver: bridge

volumes:
  node_modules:
