version: '3.8'

services:
  sproutworkcollect-api:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: sproutworkcollect-backend-go
    restart: unless-stopped
    ports:
      - "${SPROUTWORKCOLLECT_PORT:-5000}:5000"
    environment:
      - PORT=5000
      - SPROUTWORKCOLLECT_DATA_DIR=/data
      # Override the default admin token (strongly recommended in production):
      - ADMIN_TOKEN=shumengya520
      # Enable verbose Gin logging (set to 1 for debugging):
      # - GIN_DEBUG=0
    volumes:
      # 默认挂载项目目录下的 data/，部署到服务器时设置 SPROUTWORKCOLLECT_DATA_PATH 覆盖
      # 例如：export SPROUTWORKCOLLECT_DATA_PATH=/shumengya/docker/sproutworkcollect/data
      - "${SPROUTWORKCOLLECT_DATA_PATH:-./data}/works:/data/works"
      - "${SPROUTWORKCOLLECT_DATA_PATH:-./data}/config:/data/config"
    healthcheck:
      test: ["CMD", "wget", "-qO-", "http://localhost:5000/api/settings"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 15s
