# Surowan — Docker Compose deployment template
#
# Quick start:
#   1. mkdir -p config data
#   2. Place your config.jsonc and key.json in ./config/   (the entrypoint sets chmod 600)
#   3. Place system-prompt.md and any chat instruction files in ./config/
#   4. docker compose up -d
#
# In config.jsonc, use container-internal paths:
#
#   "data_dir": "/data",
#   "paths": {
#     "database": "/data/surowan.sqlite",
#     "media_cache": "/data/media-cache",
#     "backups": "/data/backups"
#   }
#
# Prompt files (system_prompt_file, instructions_file) resolve relative
# to the config file, so keep them in ./config/ alongside config.jsonc.

services:
  plasticwan:
    # Stable release. For development builds from main, use `main` (rolling) or a
    # pinned `0.0.0-next-<timestamp>` tag from the GitHub pre-releases (only the
    # newest 20 are kept).
    image: ghcr.io/tuuject/surowan:latest
    restart: unless-stopped
    # Graceful shutdown gives a running Invocation up to 30s to finish, then
    # aborts what is left, stops the image/MCP workers and closes SQLite.
    # Docker's default is 10s: it would SIGKILL the process mid-drain, and the
    # next start would have to recover the invocation as `process_restart`
    # instead of a clean abort. Keep this above that 30s budget, and pass
    # `-t <seconds>` when a single `docker compose down` should wait longer.
    stop_grace_period: 45s
    environment:
      # Declares that something restarts the process, which is what the restart
      # policy above does. It is what enables the Admin Panel's "restart now";
      # drop it together with `restart:`, or the panel offers a button that
      # stops the bot until someone starts it by hand.
      PLASTICWAN_SUPERVISED: "1"
      # Secrets referenced by the example config. Uncomment and export them in
      # the shell (or inject them from your deploy system); never paste the
      # real values here. Skip these if you use key.json instead.
      # TELEGRAM_BOT_TOKEN: ${TELEGRAM_BOT_TOKEN:?set TELEGRAM_BOT_TOKEN outside this file}
      # SUROWAN_API_KEY: ${SUROWAN_API_KEY:?set SUROWAN_API_KEY outside this file}
      # Optional: match host UID/GID to avoid permission issues with bind mounts
      # PUID: "1000"
      # PGID: "1000"
    volumes:
      - ./data:/data
      - ./config:/config
    # Admin panel binds to admin.host from config.jsonc (typically 127.0.0.1,
    # which Docker port publishing cannot reach). To publish the panel, set
    # admin.host to 0.0.0.0 in config.jsonc and uncomment:
    # ports:
    #   - "127.0.0.1:8787:8787"
