-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-run.sh
More file actions
executable file
·182 lines (158 loc) · 4.35 KB
/
docker-run.sh
File metadata and controls
executable file
·182 lines (158 loc) · 4.35 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#!/bin/bash
# Quick Docker run script for PixIntelligence
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Check if Docker is installed
if ! command -v docker &> /dev/null; then
echo -e "${RED}❌ Docker is not installed${NC}"
echo "Please install Docker: https://docs.docker.com/get-docker/"
exit 1
fi
# Check if Docker Compose is available
if ! command -v docker-compose &> /dev/null && ! docker compose version &> /dev/null; then
echo -e "${RED}❌ Docker Compose is not installed${NC}"
echo "Please install Docker Compose: https://docs.docker.com/compose/install/"
exit 1
fi
# Function to display help
show_help() {
cat << EOF
${BLUE}PixIntelligence Docker Management Script${NC}
Usage: $0 [COMMAND]
Commands:
start Build and start PixIntelligence (detached)
stop Stop PixIntelligence container
restart Restart PixIntelligence container
logs Show container logs (follow mode)
status Show container status
shell Access container shell
build Build Docker image only
clean Stop and remove container and image
update Pull latest code and rebuild
help Show this help message
Examples:
$0 start # Start the service
$0 logs # View logs
$0 shell # Access container shell
EOF
}
# Function to start the service
start_service() {
echo -e "${BLUE}🚀 Starting PixIntelligence...${NC}"
# Create .env if it doesn't exist
if [ ! -f ".env" ]; then
echo -e "${YELLOW}⚠ No .env file found, creating from .env.example${NC}"
cp .env.example .env
fi
docker-compose up -d --build
echo -e "${GREEN}✅ PixIntelligence started successfully!${NC}"
echo ""
echo -e "${BLUE}Access the application:${NC}"
echo -e " Web UI: ${GREEN}http://localhost:8000/ui${NC}"
echo -e " API: ${GREEN}http://localhost:8000/docs${NC}"
echo -e " Health: ${GREEN}http://localhost:8000/${NC}"
echo ""
echo -e "View logs: ${YELLOW}$0 logs${NC}"
}
# Function to stop the service
stop_service() {
echo -e "${YELLOW}🛑 Stopping PixIntelligence...${NC}"
docker-compose down
echo -e "${GREEN}✅ Stopped${NC}"
}
# Function to restart the service
restart_service() {
echo -e "${BLUE}♻️ Restarting PixIntelligence...${NC}"
docker-compose restart
echo -e "${GREEN}✅ Restarted${NC}"
}
# Function to show logs
show_logs() {
echo -e "${BLUE}📋 Showing logs (Ctrl+C to exit)...${NC}"
docker-compose logs -f
}
# Function to show status
show_status() {
echo -e "${BLUE}📊 Container Status:${NC}"
docker-compose ps
echo ""
echo -e "${BLUE}🐳 Docker Images:${NC}"
docker images pixintelligence
}
# Function to access shell
access_shell() {
echo -e "${BLUE}🐚 Accessing container shell...${NC}"
docker-compose exec pixintelligence bash
}
# Function to build only
build_only() {
echo -e "${BLUE}🔨 Building Docker image...${NC}"
docker-compose build
echo -e "${GREEN}✅ Build complete${NC}"
}
# Function to clean everything
clean_all() {
echo -e "${RED}🧹 Cleaning Docker resources...${NC}"
read -p "This will remove containers and images. Continue? (y/N) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
docker-compose down --rmi all --volumes
echo -e "${GREEN}✅ Cleanup complete${NC}"
else
echo -e "${YELLOW}Cancelled${NC}"
fi
}
# Function to update
update_service() {
echo -e "${BLUE}🔄 Updating PixIntelligence...${NC}"
git pull
docker-compose down
docker-compose up -d --build
echo -e "${GREEN}✅ Update complete${NC}"
}
# Main command handler
case "${1:-help}" in
start)
start_service
;;
stop)
stop_service
;;
restart)
restart_service
;;
logs)
show_logs
;;
status)
show_status
;;
shell)
access_shell
;;
build)
build_only
;;
clean)
clean_all
;;
update)
update_service
;;
help|--help|-h)
show_help
;;
*)
echo -e "${RED}❌ Unknown command: $1${NC}"
echo ""
show_help
exit 1
;;
esac