#!/bin/bash # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color echo -e "${BLUE}๐Ÿงน Pipeline Cleanup Utility${NC}" echo "===========================" echo -e "${YELLOW}โš ๏ธ This will remove:${NC}" echo " - All stopped containers" echo " - All unused networks" echo " - All unused images" echo " - All build cache" echo "" echo -e "${RED}โš ๏ธ This will NOT remove:${NC}" echo " - Running containers" echo " - Data volumes (unless specified)" echo "" read -p "Continue with cleanup? (y/N): " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]]; then echo -e "${BLUE}๐Ÿงน Starting cleanup...${NC}" # Stop services first echo -e "${BLUE}โน๏ธ Stopping services...${NC}" docker-compose down # Clean up Docker system echo -e "${BLUE}๐Ÿ—‘๏ธ Removing unused containers, networks, and images...${NC}" docker system prune -f # Optional: Remove volumes read -p "Remove data volumes? This will delete all database data! (y/N): " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]]; then echo -e "${YELLOW}๐Ÿ—‘๏ธ Removing volumes...${NC}" docker-compose down -v docker volume prune -f fi # Optional: Remove all images read -p "Remove all Docker images? This will require re-downloading. (y/N): " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]]; then echo -e "${YELLOW}๐Ÿ—‘๏ธ Removing all images...${NC}" docker image prune -a -f fi echo "" echo -e "${GREEN}โœ… Cleanup completed!${NC}" echo -e "${BLUE}๐Ÿ“Š Current system usage:${NC}" docker system df else echo -e "${BLUE}โŒ Cleanup cancelled${NC}" fi