version: '3.8'

services:
  postgres:
    image: postgres:15-alpine
    environment:
      POSTGRES_DB: ${DB_NAME:-fund_data}
      POSTGRES_USER: ${DB_USER:-fund_user}
      POSTGRES_PASSWORD: ${DB_PASS:-fund_pass123}
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data
    restart: unless-stopped

  web:
    image: docker.cnb.cool/happy_move/cnb/fund/fund_crawl_web:${IMAGE_TAG:-latest}
    ports:
      - "5000:5000"
    environment:
      DB_HOST: postgres
      DB_PORT: 5432
      DB_NAME: ${DB_NAME:-fund_data}
      DB_USER: ${DB_USER:-fund_user}
      DB_PASS: ${DB_PASS:-fund_pass123}
      EMAIL_HOST: ${EMAIL_HOST:-smtp.gmail.com}
      EMAIL_PORT: ${EMAIL_PORT:-587}
      EMAIL_USE_TLS: ${EMAIL_USE_TLS:-True}
      EMAIL_HOST_USER: ${EMAIL_HOST_USER}
      EMAIL_HOST_PASSWORD: ${EMAIL_HOST_PASSWORD}
      EMAIL_RECIPIENTS: ${EMAIL_RECIPIENTS}
    depends_on:
      - postgres
    restart: unless-stopped

  frontend:
    image: docker.cnb.cool/happy_move/cnb/fund/fund_crawl_web_frontend:${IMAGE_TAG:-latest}
    ports:
      - "5173:5173"
    depends_on:
      - web
    restart: unless-stopped

  mcp-server:
    image: docker.cnb.cool/happy_move/cnb/fund/mcp_server:${IMAGE_TAG:-latest}
    ports:
      - "8000:8000"
    environment:
      FLASK_API_BASE_URL: http://web:5000/api
      FLASK_API_TIMEOUT: 30
      JWT_TOKEN: ${JWT_TOKEN:-}
      MCP_TRANSPORT: http
      MCP_HOST: 0.0.0.0
      MCP_PORT: 8000
    depends_on:
      - web
    restart: unless-stopped
    stdin_open: true
    tty: true

volumes:
  postgres_data:
