From 742e6547626c175a0757112f611e98d55926d786 Mon Sep 17 00:00:00 2001 From: Guido X Jansen Date: Tue, 3 Mar 2026 14:33:51 +0100 Subject: [PATCH] fix(deploy): prune unused Docker images after deploy and add log rotation (#59) After each staging deploy, run `docker image prune -f` to remove dangling images left behind by the previous pull. Without this, every deploy accumulates ~800MB of unreferenced layers, eventually filling the VPS disk (as happened with 146 images consuming 29GB on a 38GB disk). Add json-file log rotation (10MB x 3 files) to all services via a shared x-logging anchor. Docker's default json-file driver has no size limit, so container logs can grow unbounded on long-running instances. --- .github/workflows/deploy-staging.yml | 3 +++ docker-compose.yml | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/.github/workflows/deploy-staging.yml b/.github/workflows/deploy-staging.yml index a5304f3..4cbb826 100644 --- a/.github/workflows/deploy-staging.yml +++ b/.github/workflows/deploy-staging.yml @@ -221,6 +221,9 @@ jobs: echo "Starting containers..." docker compose ${{ env.COMPOSE_FILES }} up -d + echo "Pruning unused images..." + docker image prune -f + echo "Deploy complete at $(date -u '+%Y-%m-%dT%H:%M:%SZ')" # ---------------------------------------------------------------------- diff --git a/docker-compose.yml b/docker-compose.yml index 7621b62..1c915b3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,6 +10,12 @@ # # Startup order: postgres -> valkey -> tap -> barazo-api -> barazo-web -> caddy +x-logging: &default-logging + driver: json-file + options: + max-size: "10m" + max-file: "3" + services: # --------------------------------------------------------------------------- # PostgreSQL 16 with pgvector (full-text + optional semantic search) @@ -17,6 +23,7 @@ services: postgres: image: pgvector/pgvector:pg16 restart: unless-stopped + logging: *default-logging environment: POSTGRES_USER: ${POSTGRES_USER} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} @@ -40,6 +47,7 @@ services: valkey: image: valkey/valkey:9-alpine restart: unless-stopped + logging: *default-logging command: > valkey-server --requirepass ${VALKEY_PASSWORD} @@ -68,6 +76,7 @@ services: image: ghcr.io/bluesky-social/indigo/tap:latest platform: linux/amd64 restart: unless-stopped + logging: *default-logging environment: TAP_RELAY_URL: ${RELAY_URL:-https://bsky.network} TAP_SIGNAL_COLLECTION: forum.barazo.topic.post @@ -88,6 +97,7 @@ services: barazo-api: image: ghcr.io/barazo-forum/barazo-api:${BARAZO_API_VERSION:-latest} restart: unless-stopped + logging: *default-logging environment: NODE_ENV: production DATABASE_URL: ${DATABASE_URL} @@ -137,6 +147,7 @@ services: barazo-web: image: ghcr.io/barazo-forum/barazo-web:${BARAZO_WEB_VERSION:-latest} restart: unless-stopped + logging: *default-logging environment: NODE_ENV: production API_INTERNAL_URL: http://barazo-api:3000 @@ -162,6 +173,7 @@ services: caddy: image: caddy:2-alpine restart: unless-stopped + logging: *default-logging environment: COMMUNITY_DOMAIN: ${COMMUNITY_DOMAIN} ports: -- 2.51.2