-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-dev.sh
More file actions
executable file
·132 lines (110 loc) · 3.07 KB
/
start-dev.sh
File metadata and controls
executable file
·132 lines (110 loc) · 3.07 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
#!/bin/bash
# MyLabVault Development Startup Script
set -e # Exit on any error
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Print colored output
print_status() {
echo -e "${BLUE}[INFO]${NC} $1"
}
print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Check if Docker is running
check_docker() {
print_status "Checking Docker status..."
if ! docker info >/dev/null 2>&1; then
print_error "🛑 Docker is not running. Please start Docker Desktop and try again."
exit 1
fi
print_success "✅ Docker is running"
}
# Check if docker-compose.yml exists
check_compose_file() {
if [ ! -f "docker-compose.yml" ]; then
print_error "🛑 docker-compose.yml not found in current directory"
print_error "🛑 Please run this script from the project root directory"
exit 1
fi
print_success "✅ Found docker-compose.yml"
}
# Clean up existing containers if needed
cleanup_containers() {
print_status "Cleaning up existing containers..."
docker-compose down --remove-orphans >/dev/null 2>&1 || true
print_success "✅ Cleanup completed"
}
# Start the service
start_services() {
print_status "Starting MyLabVault server-side rendered application..."
print_status "Building and starting mylabvault service..."
# Start mylabvault service in detached mode
docker-compose up --build -d mylabvault
if [ $? -eq 0 ]; then
print_success "✅ Application started successfully!"
else
print_error "🛑 Failed to start application"
exit 1
fi
}
# Wait for service to be healthy
wait_for_service() {
print_status "Waiting for application to be ready..."
# Wait for mylabvault health check
print_status "Checking application health..."
timeout=60
counter=0
while [ $counter -lt $timeout ]; do
if docker-compose ps mylabvault | grep -q "healthy"; then
print_success "✅ Application is healthy and ready!"
break
fi
sleep 2
counter=$((counter + 2))
echo -n "."
done
if [ $counter -ge $timeout ]; then
print_warning "Health check timed out, but continuing..."
print_status "You can check the application manually at http://localhost:8000"
fi
}
# Show service status
show_status() {
print_status "Application Status:"
docker-compose ps mylabvault
echo ""
print_success "✅ MyLabVault is ready!"
print_status "Access your application at:"
echo " - Main Application: http://localhost:8000"
echo " - API Documentation: http://localhost:8000/api/docs"
echo ""
print_status "Useful commands:"
echo " - View logs: docker-compose logs -f mylabvault"
echo " - Stop application: docker-compose down"
echo " - Restart application: docker-compose restart mylabvault"
}
# Main execution
main() {
echo "🚀 Starting MyLabVault Application"
echo "=================================="
check_docker
check_compose_file
cleanup_containers
start_services
wait_for_service
show_status
}
# Handle script interruption
trap 'print_error "Script interrupted"; exit 1' INT
# Run main function
main