-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdc
More file actions
executable file
·151 lines (125 loc) · 4.1 KB
/
Copy pathdc
File metadata and controls
executable file
·151 lines (125 loc) · 4.1 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/bash
# Live Chat App - Docker Command Wrapper
# Usage: dc [command] [options]
# Unset any existing dc function to avoid conflicts
unset -f dc 2>/dev/null || true
set -e
# Colors for output
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Show help
show_help() {
echo -e "${BLUE}Live Chat App - Docker Commands${NC}"
echo ""
echo "Usage: dc [command]"
echo ""
echo "Available commands:"
echo " ${GREEN}build${NC} - Build all Docker images"
echo " ${GREEN}up${NC} - Start all services"
echo " ${GREEN}down${NC} - Stop all services"
echo " ${GREEN}restart${NC} - Restart all services"
echo " ${GREEN}logs${NC} - Show logs from all services"
echo " ${GREEN}logs-backend${NC} - Show backend logs"
echo " ${GREEN}logs-frontend${NC} - Show frontend logs"
echo " ${GREEN}logs-reverb${NC} - Show reverb logs"
echo ""
echo "Shell access:"
echo " ${GREEN}shell-backend${NC} - Open shell in backend container"
echo " ${GREEN}shell-frontend${NC} - Open shell in frontend container"
echo " ${GREEN}shell-reverb${NC} - Open shell in reverb container"
echo ""
echo "Development commands:"
echo " ${GREEN}install-backend${NC} - Run composer install in backend"
echo " ${GREEN}install-frontend${NC} - Run npm install in frontend"
echo " ${GREEN}migrate${NC} - Run database migrations"
echo " ${GREEN}test${NC} - Run backend tests"
echo " ${GREEN}artisan${NC} [cmd] - Run artisan command (e.g., 'dc artisan cache:clear')"
echo ""
echo "Other:"
echo " ${GREEN}clean${NC} - Clean up Docker resources"
echo " ${GREEN}ps${NC} - Show running containers"
echo " ${GREEN}help${NC} - Show this help message"
echo ""
}
# Main command handler
case "$1" in
build)
echo -e "${YELLOW}Building Docker images...${NC}"
docker-compose build
;;
up)
echo -e "${YELLOW}Starting all services...${NC}"
docker-compose up -d
;;
down)
echo -e "${YELLOW}Stopping all services...${NC}"
docker-compose down
;;
restart)
echo -e "${YELLOW}Restarting all services...${NC}"
docker-compose restart
;;
logs)
docker-compose logs -f
;;
logs-backend)
docker-compose logs -f backend
;;
logs-frontend)
docker-compose logs -f frontend
;;
logs-reverb)
docker-compose logs -f reverb
;;
shell-backend)
docker-compose exec backend bash
;;
shell-frontend)
docker-compose exec frontend sh
;;
shell-reverb)
docker-compose exec reverb bash
;;
install-backend)
echo -e "${YELLOW}Installing backend dependencies...${NC}"
docker-compose exec backend composer install
;;
install-frontend)
echo -e "${YELLOW}Installing frontend dependencies...${NC}"
docker-compose exec frontend npm install
;;
migrate)
echo -e "${YELLOW}Running database migrations...${NC}"
docker-compose exec backend php artisan migrate
;;
test)
echo -e "${YELLOW}Running backend tests...${NC}"
docker-compose exec backend php artisan test
;;
artisan)
if [ -z "$2" ]; then
echo -e "${YELLOW}Usage: dc artisan [command]${NC}"
echo "Example: dc artisan cache:clear"
exit 1
fi
shift
docker-compose exec backend php artisan "$@"
;;
clean)
echo -e "${YELLOW}Cleaning up Docker resources...${NC}"
docker-compose down -v
docker system prune -f
;;
ps)
docker-compose ps
;;
help|--help|-h|"")
show_help
;;
*)
# If command not found, pass it directly to docker-compose
docker-compose "$@"
;;
esac