version: '3.8'

services:
  sproutworkcollect-api:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: sproutworkcollect-backend
    restart: unless-stopped
    ports:
      - "${SPROUTWORKCOLLECT_PORT:-5000}:5000"
    environment:
      - PORT=5000
      - SPROUTWORKCOLLECT_DATA_DIR=/data
    volumes:
      # 默认后端持久化路径：/shumengya/docker/sproutworkcollect/data/
      - "${SPROUTWORKCOLLECT_DATA_PATH:-/shumengya/docker/sproutworkcollect/data}/works:/data/works"
      - "${SPROUTWORKCOLLECT_DATA_PATH:-/shumengya/docker/sproutworkcollect/data}/config:/data/config"
    healthcheck:
      test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:5000/api/settings').read()"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s
