From b001e2d03c502445d6f22a8922496f59141081dc Mon Sep 17 00:00:00 2001 From: Shubhankar45 Date: Wed, 28 Oct 2026 09:09:23 +0000 Subject: [PATCH] Restart Celtic automatically and cap container memory The VPS is shared with other workloads and has no swap. On 2026-10-28 a Docker daemon restart stopped every container; those with restart: unless-stopped (all of Celtic) stayed down ~65 minutes until started by hand. - restart: always on all services so the stack returns after a daemon restart - mem_limit per service (db 512m, api 768m, backup 256m, web/caddy 128m) - oom_score_adj -500 on db and api so the kernel kills other workloads first Co-Authored-By: Claude Opus 5.5 --- docker-compose.yml | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index ba7f635..759d90a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,7 +26,13 @@ services: interval: 5s timeout: 5s retries: 10 - restart: unless-stopped + # `always`, not `unless-stopped`: after a Docker daemon restart, unless-stopped + # containers on this host stayed down until started by hand (2026-10-28, 65 min). + restart: always + # The VPS is shared and has no swap; the limit keeps one service from starving + # the box, and the negative score makes the kernel kill other workloads first. + mem_limit: 512m + oom_score_adj: -500 logging: *default-logging # Daily pg_dump of the whole database into ./backups on the host, the last 14 days kept. @@ -46,7 +52,8 @@ services: - ./backups:/backups - ./scripts/backup.sh:/backup.sh:ro entrypoint: ["/bin/sh", "/backup.sh"] - restart: unless-stopped + restart: always + mem_limit: 256m logging: *default-logging api: @@ -75,14 +82,18 @@ services: - no-new-privileges:true cap_drop: - ALL - restart: unless-stopped + restart: always + # Headroom for WeasyPrint PDF rendering on top of two uvicorn workers. + mem_limit: 768m + oom_score_adj: -500 logging: *default-logging # Responsive React web application. It is static after its production build; # Caddy below provides the public TLS endpoint. web: build: ./web - restart: unless-stopped + restart: always + mem_limit: 128m logging: *default-logging # Automatic HTTPS via Let's Encrypt — two lines of config, auto-renewal, @@ -103,7 +114,8 @@ services: - ./Caddyfile:/etc/caddy/Caddyfile:ro - caddydata:/data - caddyconfig:/config - restart: unless-stopped + restart: always + mem_limit: 128m logging: *default-logging volumes: