Files
SillyTavern/docker/docker-compose.yml
T
Cohee 2c09d32b5b feat(docker): add robust healthcheck script (#5028)
* feat(docker): add robust healthcheck script

- Added `docker/healthcheck.cjs`: A standalone, dependency-free Node.js script for verifying server status.
- Updated `Dockerfile`: Added HEALTHCHECK instruction and script copy step.
- Features: Auto-detects port from env/config, handles IPv4/IPv6 fallback, auto-retries HTTPS on socket hangup, and sets custom User-Agent.

* feat(docker): new healthcheck with /api/health endpoint

- Added `GET /api/health` endpoint to `server.js` (unauthenticated) for lightweight status checks.
- Update `docker/healthcheck.cjs`: Rewrite
- Updated Error handle for `HEALTHCHECK`

* feat(docker): switch to heartbeat file healthcheck mechanism

- Replaced network-based check with a file-based heartbeat approach.
- Updated `src/command-line.js`: Added `heartbeatInterval` argument with explicit ENV override (`SILLYTAVERN_HEARTBEAT_INTERVAL`).
- Updated `src/server-main.js`: Added logic to write `heartbeat.json` to data directory at set intervals.
- Rewrote `docker/healthcheck.cjs`: Script now monitors the heartbeat file timestamp (zero dependencies, no config parsing required).
- Updated `Dockerfile`: Sets default heartbeat interval to 30s and ensures script availability.
- Updated `config.yaml`: Added `heartbeatInterval` defaulting to 0 (disabled) for non-Docker users.

* Fix variable names

* Convert to ESM, use serverDirectory variable

* Move file to /src

* fix: update heartbeat path to use global DATA_ROOT variable

* Pretty colors

* Move healthcheck to docker-compose.yml

* Comment fixed

* Even cleaner diff!

---------

Co-authored-by: Pavdig <101715456+Pavdig@users.noreply.github.com>
2026-01-18 16:36:37 +02:00

25 lines
671 B
YAML

services:
sillytavern:
build: ..
container_name: sillytavern
hostname: sillytavern
image: ghcr.io/sillytavern/sillytavern:latest
environment:
- NODE_ENV=production
- FORCE_COLOR=1
- SILLYTAVERN_HEARTBEATINTERVAL=30
ports:
- "8000:8000"
volumes:
- "./config:/home/node/app/config"
- "./data:/home/node/app/data"
- "./plugins:/home/node/app/plugins"
- "./extensions:/home/node/app/public/scripts/extensions/third-party"
healthcheck:
test: ["CMD", "node", "src/healthcheck.js"]
interval: 30s
timeout: 10s
start_period: 20s
retries: 3
restart: unless-stopped