From 2b2f64e7f9cc746762283df171b2b31f2f40ef91 Mon Sep 17 00:00:00 2001 From: Jannis Braun <151788261+TheZwiss@users.noreply.github.com> Date: Thu, 26 Mar 2026 03:31:52 +0100 Subject: [PATCH] fix: prune stale Docker images and build cache after each deploy Adds a post-deploy step that removes Docker images and build cache older than 24 hours. Prevents the gradual disk bloat from repeated docker compose --build invocations (was 71GB on the Pi). --- deploy.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/deploy.sh b/deploy.sh index f0cc9a73..24535741 100755 --- a/deploy.sh +++ b/deploy.sh @@ -70,10 +70,14 @@ deploy() { ./ "$PI_USER@$host:$path" # Rebuild - echo " [3/3] Building and restarting..." + echo " [3/4] Building and restarting..." # Clean up stale renamed containers left by failed recreates (e.g. "d420a6c00439_backspace") ssh "$PI_USER@$host" "cd $path && docker rm -f \$(docker ps -aq --filter 'name=_backspace' 2>/dev/null) 2>/dev/null; docker compose up -d --build" + # Prune old images and build cache to prevent disk bloat + echo " [4/4] Pruning stale Docker data..." + ssh "$PI_USER@$host" "docker image prune -af --filter 'until=24h' 2>/dev/null; docker builder prune -af --filter 'until=24h' 2>/dev/null" || true + echo "" echo " Done: $name" }