Files
dragonsstash/docker-compose.yml
adminandClaude Opus 4.8 2e7e6cca9b Backup: switch NAS transport to SMB/CIFS, fix crond/OOM/live-tar defects
Wire the backup service against the Synology share over SMB/CIFS (the NAS
authenticates with a user/password; NFS is IP-allowlist only). Also fixes
three defects found bringing the service up live:

- entrypoint crash-loop: dcron's crond fails "setpgid: Operation not
  permitted" in this runtime -> use busybox crond; make repo-init idempotent
  (check via `restic cat config`, tolerate init-on-existing) so a transient
  CIFS/lock hiccup can't kill PID 1.
- OOM: pg_dump of a ~276MB DB + tar + restic exceeded the 256M cap -> 1G.
- live tar abort: GNU tar exits 1 when TDLib files change mid-read (worker is
  live); per design this is best-effort, so tolerate exit 1, fatal only >=2.

Kuma push is now optional (empty URL disables alerting) since it's deferred.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-24 11:36:19 +02:00

168 lines
4.6 KiB
YAML

services:
app:
build:
context: .
dockerfile: Dockerfile
pull_policy: never
ports:
- "${APP_PORT:-3000}:${APP_PORT:-3000}"
environment:
- DATABASE_URL=postgresql://${POSTGRES_USER:-dragons}:${POSTGRES_PASSWORD:-stash}@db:5432/${POSTGRES_DB:-dragonsstash}
- AUTH_SECRET=${AUTH_SECRET:?Set AUTH_SECRET in .env}
- AUTH_TRUST_HOST=true
- AUTH_GITHUB_ID=${AUTH_GITHUB_ID:-}
- AUTH_GITHUB_SECRET=${AUTH_GITHUB_SECRET:-}
- NEXT_PUBLIC_APP_URL=${NEXT_PUBLIC_APP_URL:-http://localhost:3000}
- TELEGRAM_API_KEY=${TELEGRAM_API_KEY:-}
- BOT_TOKEN=${BOT_TOKEN:-}
- BOT_USERNAME=${BOT_USERNAME:-}
- LOG_LEVEL=${LOG_LEVEL:-info}
- WORKER_INTERVAL_MINUTES=${WORKER_INTERVAL_MINUTES:-60}
- PORT=${APP_PORT:-3000}
depends_on:
db:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "wget -q --spider http://localhost:$$PORT/api/health || exit 1"]
interval: 30s
timeout: 5s
retries: 3
start_period: 60s
volumes:
- manual_uploads:/data/uploads
restart: unless-stopped
deploy:
resources:
limits:
memory: 512M
networks:
- frontend
worker:
build:
context: .
dockerfile: worker/Dockerfile
pull_policy: never
environment:
- DATABASE_URL=postgresql://${POSTGRES_USER:-dragons}:${POSTGRES_PASSWORD:-stash}@db:5432/${POSTGRES_DB:-dragonsstash}
- TELEGRAM_API_ID=${TELEGRAM_API_ID:-}
- TELEGRAM_API_HASH=${TELEGRAM_API_HASH:-}
- WORKER_INTERVAL_MINUTES=${WORKER_INTERVAL_MINUTES:-60}
- WORKER_TEMP_DIR=/tmp/zips
- TDLIB_STATE_DIR=/data/tdlib
- WORKER_MAX_ZIP_SIZE_MB=${WORKER_MAX_ZIP_SIZE_MB:-4096}
- MULTIPART_TIMEOUT_HOURS=${MULTIPART_TIMEOUT_HOURS:-0}
- LOG_LEVEL=${LOG_LEVEL:-info}
volumes:
- tdlib_state:/data/tdlib
- tmp_zips:/tmp/zips
- manual_uploads:/data/uploads
depends_on:
db:
condition: service_healthy
restart: unless-stopped
deploy:
resources:
limits:
memory: 1G
reservations:
memory: 256M
networks:
- backend
bot:
profiles: ["bot", "full"]
build:
context: .
dockerfile: bot/Dockerfile
pull_policy: never
environment:
- DATABASE_URL=postgresql://${POSTGRES_USER:-dragons}:${POSTGRES_PASSWORD:-stash}@db:5432/${POSTGRES_DB:-dragonsstash}
- BOT_TOKEN=${BOT_TOKEN:-}
- TELEGRAM_API_ID=${TELEGRAM_API_ID:-}
- TELEGRAM_API_HASH=${TELEGRAM_API_HASH:-}
- LOG_LEVEL=${LOG_LEVEL:-info}
volumes:
- tdlib_bot_state:/data/tdlib
depends_on:
db:
condition: service_healthy
restart: unless-stopped
deploy:
resources:
limits:
memory: 512M
reservations:
memory: 128M
networks:
- backend
backup:
build:
context: .
dockerfile: backup/Dockerfile
pull_policy: never
environment:
- POSTGRES_USER=${POSTGRES_USER:-dragons}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-stash}
- PGPASSWORD=${POSTGRES_PASSWORD:-stash}
- POSTGRES_DB=${POSTGRES_DB:-dragonsstash}
- RESTIC_REPOSITORY=/backups/restic-repo
- RESTIC_PASSWORD=${RESTIC_PASSWORD:?Set RESTIC_PASSWORD in .env}
- KUMA_PUSH_URL=${KUMA_PUSH_URL:-}
- TZ=${TZ:-Etc/UTC}
volumes:
- tdlib_state:/data/tdlib-worker:ro
- tdlib_bot_state:/data/tdlib-bot:ro
- nas_backups:/backups
depends_on:
db:
condition: service_healthy
restart: unless-stopped
deploy:
resources:
limits:
memory: 1G
networks:
- backend
db:
image: postgres:16-alpine
environment:
POSTGRES_USER: ${POSTGRES_USER:-dragons}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-stash}
POSTGRES_DB: ${POSTGRES_DB:-dragonsstash}
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-dragons} -d ${POSTGRES_DB:-dragonsstash}"]
interval: 10s
timeout: 5s
retries: 5
restart: unless-stopped
deploy:
resources:
limits:
memory: 1G
networks:
frontend: {}
backend:
aliases:
- dragonsstash-db
volumes:
postgres_data:
tdlib_state:
tdlib_bot_state:
tmp_zips:
manual_uploads:
nas_backups:
driver_opts:
type: cifs
o: "username=${NAS_USERNAME},password=${NAS_PASSWORD},vers=3.0,uid=0,gid=0,file_mode=0660,dir_mode=0770"
device: "//${NAS_HOST}/${NAS_SHARE}"
networks:
frontend:
backend: