From a0dc80e96b04d2a96a79fb9c1f40a69d2c770133 Mon Sep 17 00:00:00 2001 From: mindesbunister Date: Fri, 14 Nov 2025 10:46:15 +0100 Subject: [PATCH] docs: add Docker cleanup instructions to prevent disk full issues - Document build cache accumulation problem (40-50 GB typical) - Add cleanup commands: image prune, builder prune, volume prune - Recommend running after each deployment or weekly - Typical space freed: 40-55 GB per cleanup - Clarify what's safe vs not safe to delete - Part of maintaining healthy development environment --- .github/copilot-instructions.md | 43 ++++++++++++++++++++++++++++ lib/startup/init-position-manager.ts | 2 +- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index fc69261..ba514d5 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -292,6 +292,49 @@ docker logs trading-bot-v4 | grep "Server starting" | head -1 **DO NOT use:** `docker compose build trading-bot` in foreground - one network hiccup kills 60s of work +### Docker Cleanup After Builds + +**CRITICAL: Prevent disk full issues from build cache accumulation** + +Docker builds create intermediate layers (1.3+ GB per build) that accumulate over time. Build cache can reach 40-50 GB after frequent rebuilds. + +**After successful deployment, clean up:** +```bash +# Remove dangling images (old builds) +docker image prune -f + +# Remove build cache (biggest space hog - 40+ GB typical) +docker builder prune -f + +# Optional: Remove dangling volumes (if no important data) +docker volume prune -f + +# Check space saved +docker system df +``` + +**When to run:** +- After each successful deployment (recommended) +- Weekly if building frequently +- When disk space warnings appear +- Before major updates/migrations + +**Space typically freed:** +- Dangling images: 2-5 GB +- Build cache: 40-50 GB +- Dangling volumes: 0.5-1 GB +- **Total: 40-55 GB per cleanup** + +**What's safe to delete:** +- `` tagged images (old builds) +- Build cache (recreated on next build) +- Dangling volumes (orphaned from removed containers) + +**What NOT to delete:** +- Named volumes (contain data: `trading-bot-postgres`, etc.) +- Active containers +- Tagged images currently in use + --- ## Critical Components diff --git a/lib/startup/init-position-manager.ts b/lib/startup/init-position-manager.ts index 6221017..0df2a0c 100644 --- a/lib/startup/init-position-manager.ts +++ b/lib/startup/init-position-manager.ts @@ -109,7 +109,7 @@ async function validateOpenTrades() { } // Position EXISTS on Drift - const driftDirection = position.direction.toLowerCase() as 'long' | 'short' + const driftDirection = position.side.toLowerCase() as 'long' | 'short' if (driftDirection !== trade.direction) { console.log(`⚠️ DIRECTION MISMATCH: ${trade.symbol} DB=${trade.direction} Drift=${driftDirection}`)