version: '3.8'

services:
  backend:
    build:
      context: ./backend
      dockerfile: Dockerfile
    ports:
      - "8000:8000"
    environment:
      - AI_SERVICE_URL=http://ai-service:8001
      - MARKET=US  # CN=中国, US=北美
      - PYTHONUNBUFFERED=1
      - DATABASE_URL=postgresql://homerenovation:home123@db:5432/homerenovation
    depends_on:
      - ai-service
      - db
    restart: unless-stopped

  ai-service:
    build:
      context: ./ai-service
      dockerfile: Dockerfile
    ports:
      - "8001:8001"
    environment:
      - PYTHONUNBUFFERED=1
    volumes:
      - ./ai-service/.env:/app/.env
    restart: unless-stopped

  # PostgreSQL 数据库
  db:
    image: postgres:14
    environment:
      - POSTGRES_USER=homerenovation
      - POSTGRES_PASSWORD=home123
      - POSTGRES_DB=homerenovation
    ports:
      - "5432:5432"
    volumes:
      - db_data:/var/lib/postgresql/data
    restart: unless-stopped

  # 可选：添加 Redis 等
  # redis:
  #   image: redis:alpine
  #   ports:
  #     - "6379:6379"

volumes:
  db_data:
