# QuantDinger Docker Compose
# Quick start: docker-compose up -d

version: '3.8'

services:
  # Backend API Service
  backend:
    build:
      context: ./backend_api_python
      dockerfile: Dockerfile
    container_name: quantdinger-backend
    restart: unless-stopped
    ports:
      - "127.0.0.1:5000:5000"
    volumes:
      # Persistent database and logs
      # - ./backend_api_python/quantdinger.db:/app/quantdinger.db
      - ./backend_api_python/logs:/app/logs
      - ./backend_api_python/data:/app/data
      # Configuration file (optional, for development)
      # NOTE: must be writable for /api/settings/save to persist changes
      - ./backend_api_python/.env:/app/.env
    environment:
      - PYTHON_API_HOST=0.0.0.0
      - PYTHON_API_PORT=5000
      - TZ=Asia/Shanghai
      - SQLITE_DATABASE_FILE=/app/data/quantdinger.db
    networks:
      - quantdinger-network
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:5000/api/health"]
      interval: 30s
      timeout: 10s
      retries: 3

  # Frontend Web Service
  frontend:
    build:
      context: ./quantdinger_vue
      dockerfile: Dockerfile
    container_name: quantdinger-frontend
    restart: unless-stopped
    ports:
      - "8888:80"
    depends_on:
      - backend
    networks:
      - quantdinger-network
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost/health"]
      interval: 30s
      timeout: 10s
      retries: 3

networks:
  quantdinger-network:
    driver: bridge

# Optional: Add data volumes (for more complex persistence)
# volumes:
#   backend-data:
#   backend-logs:
