-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmanage.sh
More file actions
74 lines (68 loc) · 2.51 KB
/
Copy pathmanage.sh
File metadata and controls
74 lines (68 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
# --- Simple management script for the Docker Compose project ---
# Colors for better output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# Function to display help message
usage() {
echo "Usage: $0 {start|stop|restart|rebuild|logs|prune}"
echo ""
echo "Commands:"
echo " start 🚀 Start all services in the background."
echo " stop 🛑 Stop all running services."
echo " restart 🔄 Stop and then start all services."
echo " rebuild 🛠️ Stop, rebuild images, and restart all services."
echo " logs 📋 View logs from all running services."
echo " prune 🔥 Stop and remove all containers, networks, volumes, and images associated with the project."
exit 1
}
# Check if docker-compose.yml exists
if [ ! -f "docker-compose.yml" ]; then
echo -e "${RED}Error: docker-compose.yml not found in the current directory.${NC}"
exit 1
fi
# Main command logic
case "$1" in
start)
echo -e "${GREEN}🚀 Starting all project services in the background...${NC}"
docker-compose up -d
echo -e "${GREEN}✅ Services are up and running!${NC}"
;;
stop)
echo -e "${YELLOW}🛑 Stopping all project services...${NC}"
docker-compose down
echo -e "${YELLOW}✅ Services have been stopped.${NC}"
;;
restart)
echo -e "${YELLOW}🔄 Restarting all services...${NC}"
docker-compose down
docker-compose up -d
echo -e "${GREEN}✅ Services have been restarted.${NC}"
;;
rebuild)
echo -e "${GREEN}🛠️ Rebuilding project images and restarting services...${NC}"
docker-compose up --build -d
echo -e "${GREEN}✅ Project has been rebuilt and restarted successfully!${NC}"
;;
logs)
echo -e "${GREEN}📋 Tailing logs for all services (Press Ctrl+C to stop)...${NC}"
docker-compose logs -f
;;
prune)
echo -e "${RED}🚨 WARNING: This will permanently delete all containers, networks, volumes, and images created by this project.${NC}"
read -p "Are you sure you want to continue? [y/N] " -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo -e "${RED}🔥 Pruning the entire project...${NC}"
docker-compose down --volumes --rmi all
echo -e "${RED}✅ Project has been completely removed from Docker.${NC}"
else
echo "Prune operation cancelled."
fi
;;
*)
usage
;;
esac