diff --git a/AGENTS.md b/AGENTS.md index 6a36b25..16b5847 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -49,6 +49,8 @@ ``` - **Container Orchestration**: `docker-compose.yml` has NO `depends_on` declarations. All service ordering is handled in `scripts/dev.sh` via phased startup with explicit health checks. - **Startup Phases**: (1) Create all containers, (2) Start anvil+postgres and wait for healthy, (3) Start bootstrap and wait for completion, (4) Start ponder and wait for healthy, (5) Start webapp/landing/txn-bot, (6) Start caddy. +- **Logging Configuration**: All services have log rotation configured (max 10MB per file, 3 files max = 30MB per container) to prevent disk bloat. Logs are automatically rotated by Docker. +- **Disk Management**: `./scripts/dev.sh stop` automatically prunes unused Docker resources. For aggressive cleanup, run `./scripts/cleanup-disk.sh`. ## Guardrails & Tips - `token0isWeth` flips amount semantics; confirm ordering before seeding or interpreting liquidity. diff --git a/docker-compose.yml b/docker-compose.yml index c972c2d..ffa7317 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,6 +4,13 @@ networks: harb-network: driver: bridge +# Global logging configuration to prevent disk bloat +x-logging: &default-logging + driver: "json-file" + options: + max-size: "10m" + max-file: "3" + services: anvil: image: ghcr.io/foundry-rs/foundry:latest @@ -17,6 +24,7 @@ services: restart: unless-stopped networks: - harb-network + logging: *default-logging healthcheck: test: ["CMD", "cast", "block-number", "--rpc-url", "http://127.0.0.1:8545"] interval: 2s @@ -37,6 +45,7 @@ services: restart: unless-stopped networks: - harb-network + logging: *default-logging healthcheck: test: ["CMD-SHELL", "pg_isready -U ponder"] interval: 5s @@ -56,6 +65,7 @@ services: networks: - harb-network restart: "no" + logging: *default-logging healthcheck: test: ["CMD", "test", "-f", "/workspace/tmp/containers/contracts.env"] interval: 5s @@ -84,6 +94,7 @@ services: restart: unless-stopped networks: - harb-network + logging: *default-logging healthcheck: test: ["CMD", "wget", "--spider", "-q", "http://127.0.0.1:42069/"] interval: 5s @@ -112,6 +123,7 @@ services: restart: unless-stopped networks: - harb-network + logging: *default-logging healthcheck: test: ["CMD", "wget", "--spider", "-q", "http://127.0.0.1:5173/"] interval: 5s @@ -137,6 +149,7 @@ services: restart: unless-stopped networks: - harb-network + logging: *default-logging healthcheck: test: ["CMD", "wget", "--spider", "-q", "http://127.0.0.1:5174/"] interval: 5s @@ -161,6 +174,7 @@ services: restart: unless-stopped networks: - harb-network + logging: *default-logging healthcheck: test: ["CMD", "wget", "--spider", "-q", "http://127.0.0.1:43069/status"] interval: 5s @@ -176,6 +190,7 @@ services: restart: unless-stopped networks: - harb-network + logging: *default-logging healthcheck: test: ["CMD", "wget", "--spider", "-q", "http://127.0.0.1:80"] interval: 2s diff --git a/scripts/cleanup-disk.sh b/scripts/cleanup-disk.sh new file mode 100755 index 0000000..4bb85b3 --- /dev/null +++ b/scripts/cleanup-disk.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Disk cleanup utility for Harb stack +# Use this to aggressively free up disk space + +cd "$(dirname "$0")/.." + +echo "=== Harb Stack Disk Cleanup ===" +echo "" + +# Detect container runtime +if command -v docker &> /dev/null; then + RUNTIME_CMD="docker" +elif command -v podman &> /dev/null; then + RUNTIME_CMD="podman" +else + echo "Error: docker/podman not found" + exit 1 +fi + +echo "Current disk usage:" +df -h / | tail -1 +echo "" + +# Stop the stack first +if [[ -f "./scripts/dev.sh" ]]; then + echo "Stopping stack..." + ./scripts/dev.sh stop || true +fi + +echo "" +echo "Pruning Docker resources..." +echo " - Stopped containers" +echo " - Unused volumes" +echo " - Dangling images" +echo " - Build cache" +echo "" + +# Aggressive pruning +${RUNTIME_CMD} system prune -af --volumes + +echo "" +echo "Cleaning npm caches..." +rm -rf ~/.npm ~/.cache 2>/dev/null || true + +echo "" +echo "Cleaning journal logs..." +sudo journalctl --vacuum-size=500M 2>/dev/null || echo " (skipped: needs sudo)" + +echo "" +echo "Final disk usage:" +df -h / | tail -1 +echo "" +echo "[ok] Cleanup complete" diff --git a/scripts/dev.sh b/scripts/dev.sh index 580d89a..c033563 100755 --- a/scripts/dev.sh +++ b/scripts/dev.sh @@ -162,7 +162,12 @@ start_stack() { stop_stack() { cleanup_existing ${COMPOSE_CMD} down - echo "[ok] Stack stopped" + + # Prune Docker resources to prevent disk bloat + echo " Pruning Docker resources..." + ${RUNTIME_CMD} system prune -f --volumes 2>&1 | grep -E "Total reclaimed|deleted" || true + + echo "[ok] Stack stopped and cleaned" } check_health() {