# 生产：先在 Windows 运行 build-linux-amd64.bat 生成 dist/mengyaping-backend，再 docker compose build（镜像内不再编译 Go）
# 若需在服务器上用源码构建镜像：docker build -f Dockerfile.source -t mengyaping-backend:source .
version: '3.8'

services:
  mengyaping-backend:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: mengyaping-backend
    restart: unless-stopped
    ports:
      - "6161:8080"
    volumes:
      # 持久化数据目录
      - /shumengya/docker/mengyaping-backend/data/:/app/data
    environment:
      # 服务器配置
      - SERVER_PORT=8080
      - SERVER_HOST=0.0.0.0
      # 监控默认值（首次写入 MySQL monitor_kv；周期也可在管理后台改，须为 10/20/30/60/180/360 分钟之一）
      - MONITOR_INTERVAL=30m
      - MONITOR_TIMEOUT=10s
      - MONITOR_RETRY_COUNT=3
      - MONITOR_HISTORY_DAYS=7
      # 若设置则覆盖数据库 monitor_kv 中的 admin_token（部署密文推荐用环境变量）
      - ADMIN_TOKEN=shumengya520
    networks:
      - mengyaping-network
    healthcheck:
      test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8080/api/health"]
      interval: 30s
      timeout: 3s
      retries: 3
      start_period: 5s
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "3"

networks:
  mengyaping-network:
    driver: bridge
