# ── 全局日志策略：所有服务强制轮转，防磁盘爆满 ──
x-logging: &default-logging
  driver: "json-file"
  options:
    max-size: "20m"
    max-file: "3"

services:
  # ---- 后端 API (Gunicorn + Uvicorn Workers) ----
  backend:
    build:
      context: .
      dockerfile: Dockerfile.backend
    container_name: crm-backend
    env_file:
      - ./server/.env
    environment:
      - TZ=Asia/Shanghai
    restart: always
    volumes:
      # 上传文件目录 — 挂载群晖 NAS (192.168.1.48)
      - /mnt/nas-uploads:/app/uploads
    extra_hosts:
      - "host.docker.internal:host-gateway"
    logging: *default-logging

  # ---- 前端网关 (Nginx + Vue3 SPA) ----
  frontend:
    build:
      context: .
      dockerfile: Dockerfile.frontend
    container_name: crm-frontend
    ports:
      - "80:80"
    depends_on:
      - backend
    environment:
      - TZ=Asia/Shanghai
    restart: always
    logging: *default-logging
