Files
aurorabot/shared/scripts/docker-cleanup.sh
syntaxbullet aca5538d57
All checks were successful
Deploy to Production / test (push) Successful in 32s
chore: improve DX scripts, fix test suite, and harden tooling
Scripts:
- remote.sh: remove unused open_browser() function
- deploy-remote.sh: add DB backup before deploy, --skip-backup flag, step numbering
- db-backup.sh: fix macOS compat (xargs -r is GNU-only), use portable approach
- db-restore.sh: add safety backup before restore, SQL file validation, file size display
- logs.sh: default to no-follow with --tail=100, order-independent arg parsing
- docker-cleanup.sh: add Docker health check, colored output
- test-sequential.sh: exclude *.integration.test.ts by default, add --integration flag
- simulate-ci.sh: pass --integration flag (has real DB)

Tests:
- db.test.ts: fix mock path from ./DrizzleClient to @shared/db/DrizzleClient
- server.settings.test.ts: rewrite mocks for gameSettingsService (old config/saveConfig removed)
- server.test.ts: add missing config.lootdrop and BotClient mocks, complete DrizzleClient chain
- indexes.test.ts: rename to indexes.integration.test.ts (requires live DB)

Config:
- package.json: test script uses sequential runner, add test:ci and db:restore aliases
- deploy.yml: use --integration flag in CI (has Postgres service)
2026-02-13 14:39:02 +01:00

116 lines
3.4 KiB
Bash
Executable File

#!/bin/bash
# =============================================================================
# Aurora Docker Cleanup Script
# =============================================================================
# Cleans up Docker resources to free disk space.
#
# Usage: ./docker-cleanup.sh (interactive mode)
# ./docker-cleanup.sh --full (automatic full cleanup)
# =============================================================================
set -e
# Colors
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m'
echo -e "${YELLOW}🧹 Aurora Docker Cleanup${NC}"
echo "========================"
echo ""
# Verify Docker is running
if ! docker info > /dev/null 2>&1; then
echo -e "${RED}Error: Docker is not running.${NC}"
exit 1
fi
# Show current disk usage first
echo "📊 Current Docker disk usage:"
docker system df
echo ""
# Stop running containers for this project
echo "📦 Stopping Aurora containers..."
docker compose down 2>/dev/null || true
# Remove dangling images (untagged images from failed builds)
echo ""
echo "🗑️ Removing dangling images..."
docker image prune -f
# Check for --full flag for aggressive cleanup
if [[ "$1" == "--full" ]]; then
echo ""
echo -e "${YELLOW}🔥 Full cleanup mode - removing all unused Docker resources...${NC}"
# Remove all unused images, not just dangling ones
echo " → Removing unused images..."
docker image prune -a -f
# Remove build cache
echo " → Removing build cache..."
docker builder prune -a -f
# Remove unused volumes (except named ones we need)
echo " → Removing unused volumes..."
docker volume prune -f
# Remove unused networks
echo " → Removing unused networks..."
docker network prune -f
# Remove node_modules volumes
echo " → Removing node_modules volumes..."
docker volume rm aurora_app_node_modules aurora_web_node_modules 2>/dev/null || true
echo ""
echo -e "${GREEN}✅ Full cleanup complete!${NC}"
else
# Interactive mode
echo ""
read -p "🔧 Remove Docker build cache? (y/N): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
docker builder prune -f
echo -e "${GREEN}${NC} Build cache cleared"
fi
echo ""
read -p "🖼️ Remove ALL unused images (not just dangling)? (y/N): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
docker image prune -a -f
echo -e "${GREEN}${NC} Unused images removed"
fi
echo ""
read -p "📁 Remove node_modules volumes? (forces fresh install) (y/N): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
docker volume rm aurora_app_node_modules aurora_web_node_modules 2>/dev/null || true
echo -e "${GREEN}${NC} Node modules volumes removed"
fi
echo ""
read -p "🧨 Run full system prune (removes ALL unused data)? (y/N): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
docker system prune -a -f --volumes
echo -e "${GREEN}${NC} Full system prune complete"
fi
echo ""
echo -e "${GREEN}✅ Cleanup complete!${NC}"
fi
echo ""
echo "📊 Docker disk usage after cleanup:"
docker system df
echo ""
echo "💡 Tip: Check container logs with: sudo du -sh /var/lib/docker/containers/*/*.log"
echo "💡 Tip: Truncate logs with: sudo truncate -s 0 /var/lib/docker/containers/*/*.log"
echo ""
echo "Run 'docker compose up --build' to rebuild"