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}`)