Spaces:
Build error
Build error
File size: 9,544 Bytes
6423ff2 |
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 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
#!/bin/bash
# ============================================
# AudioForge - Professional Presentation Launch
# ============================================
# Enterprise-grade deployment script
# Author: AudioForge Team
# Version: 1.0.0
set -e
# Colors
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
CYAN='\033[0;36m'
MAGENTA='\033[0;35m'
BOLD='\033[1m'
RESET='\033[0m'
# Parse arguments
CLEAN=false
BUILD=false
MONITORING=false
while [[ $# -gt 0 ]]; do
case $1 in
--clean) CLEAN=true; shift ;;
--build) BUILD=true; shift ;;
--monitoring) MONITORING=true; shift ;;
*) echo "Unknown option: $1"; exit 1 ;;
esac
done
# Banner
show_banner() {
echo ""
echo -e "${CYAN}${BOLD}βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${RESET}"
echo -e "${CYAN}${BOLD}β β${RESET}"
echo -e "${CYAN}${BOLD}β ${MAGENTA}π΅ AUDIOFORGE π΅${CYAN} β${RESET}"
echo -e "${CYAN}${BOLD}β β${RESET}"
echo -e "${CYAN}${BOLD}β ${RESET}Open-Source Text-to-Music Generation Platform${CYAN} β${RESET}"
echo -e "${CYAN}${BOLD}β β${RESET}"
echo -e "${CYAN}${BOLD}β ${GREEN}Production-Ready Enterprise Deployment${CYAN} β${RESET}"
echo -e "${CYAN}${BOLD}β β${RESET}"
echo -e "${CYAN}${BOLD}βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${RESET}"
echo ""
}
# Status messages
status() { echo -e "${BLUE}[INFO]${RESET} $1"; }
success() { echo -e "${GREEN}[β]${RESET} $1"; }
warning() { echo -e "${YELLOW}[!]${RESET} $1"; }
error() { echo -e "${RED}[β]${RESET} $1"; }
section() { echo ""; echo -e "${BOLD}${CYAN}βββ $1 βββ${RESET}"; echo ""; }
# Check prerequisites
check_prerequisites() {
section "Checking Prerequisites"
local all_good=true
# Check Docker
if command -v docker &> /dev/null; then
success "Docker: $(docker --version)"
else
error "Docker not found. Please install Docker."
all_good=false
fi
# Check Docker Compose
if command -v docker-compose &> /dev/null; then
success "Docker Compose: $(docker-compose --version)"
else
error "Docker Compose not found."
all_good=false
fi
# Check if Docker is running
if docker ps &> /dev/null; then
success "Docker daemon is running"
else
error "Docker daemon is not running. Please start Docker."
all_good=false
fi
if [ "$all_good" = false ]; then
error "Prerequisites check failed. Please resolve issues and try again."
exit 1
fi
}
# Clean up
cleanup() {
section "Cleaning Up Previous Deployment"
status "Stopping containers..."
docker-compose down -v 2>/dev/null || true
status "Removing unused images..."
docker image prune -f > /dev/null
status "Removing unused volumes..."
docker volume prune -f > /dev/null
success "Cleanup complete"
}
# Build images
build_images() {
section "Building Docker Images"
status "Building backend image..."
docker-compose build backend
status "Building frontend image..."
docker-compose build frontend
success "All images built successfully"
}
# Start services
start_services() {
section "Starting Services"
status "Starting database layer (PostgreSQL, Redis)..."
docker-compose up -d postgres redis
sleep 5
status "Starting backend API..."
docker-compose up -d backend
sleep 10
status "Starting frontend application..."
docker-compose up -d frontend
success "All services started"
}
# Check service health
check_health() {
section "Health Check Status"
local max_retries=30
local retry_count=0
# Check PostgreSQL
status "Checking PostgreSQL..."
retry_count=0
while [ $retry_count -lt $max_retries ]; do
health=$(docker inspect --format='{{.State.Health.Status}}' audioforge-postgres 2>/dev/null || echo "starting")
if [ "$health" = "healthy" ]; then
success "PostgreSQL is healthy"
break
fi
((retry_count++))
sleep 2
done
# Check Redis
status "Checking Redis..."
retry_count=0
while [ $retry_count -lt $max_retries ]; do
health=$(docker inspect --format='{{.State.Health.Status}}' audioforge-redis 2>/dev/null || echo "starting")
if [ "$health" = "healthy" ]; then
success "Redis is healthy"
break
fi
((retry_count++))
sleep 2
done
# Check Backend
status "Checking Backend API..."
retry_count=0
while [ $retry_count -lt $max_retries ]; do
if curl -sf http://localhost:8000/health > /dev/null 2>&1; then
success "Backend API is healthy"
break
fi
((retry_count++))
sleep 2
done
# Check Frontend
status "Checking Frontend..."
retry_count=0
while [ $retry_count -lt $max_retries ]; do
if curl -sf http://localhost:3000 > /dev/null 2>&1; then
success "Frontend is healthy"
break
fi
((retry_count++))
sleep 2
done
}
# Show service status
show_status() {
section "Service Status Dashboard"
docker-compose ps
echo ""
echo -e "${BOLD}Container Resource Usage:${RESET}"
docker stats --no-stream --format "table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.NetIO}}"
}
# Show access information
show_access_info() {
section "Access Information"
echo -e "${BOLD}${GREEN}π Application URLs:${RESET}"
echo ""
echo -e " ${CYAN}Frontend Application:${RESET} http://localhost:3000"
echo -e " ${CYAN}Backend API:${RESET} http://localhost:8000"
echo -e " ${CYAN}API Documentation:${RESET} http://localhost:8000/docs"
echo -e " ${CYAN}API Redoc:${RESET} http://localhost:8000/redoc"
echo -e " ${CYAN}Health Check:${RESET} http://localhost:8000/health"
echo ""
if [ "$MONITORING" = true ]; then
echo -e "${BOLD}${YELLOW}π Monitoring URLs:${RESET}"
echo ""
echo -e " ${CYAN}Prometheus:${RESET} http://localhost:9090"
echo -e " ${CYAN}Grafana:${RESET} http://localhost:3001"
echo -e " ${CYAN}Grafana Credentials:${RESET} admin / admin"
echo ""
fi
echo -e "${BOLD}${MAGENTA}π Database Connections:${RESET}"
echo ""
echo -e " ${CYAN}PostgreSQL:${RESET} localhost:5432"
echo -e " ${CYAN}Database:${RESET} audioforge"
echo -e " ${CYAN}User:${RESET} postgres"
echo ""
echo -e " ${CYAN}Redis:${RESET} localhost:6379"
echo ""
}
# Show logs
show_logs() {
section "Recent Logs"
echo -e "${CYAN}Backend Logs:${RESET}"
docker-compose logs --tail=10 backend
echo ""
echo -e "${CYAN}Frontend Logs:${RESET}"
docker-compose logs --tail=10 frontend
}
# Main execution
main() {
show_banner
# Check prerequisites
check_prerequisites
# Clean up if requested
if [ "$CLEAN" = true ]; then
cleanup
fi
# Build if requested
if [ "$BUILD" = true ]; then
build_images
fi
# Start services
start_services
# Wait for services to be healthy
status "Waiting for services to become healthy..."
sleep 15
# Check health
check_health
# Show status
show_status
# Show access info
show_access_info
# Show recent logs
show_logs
# Final message
echo ""
echo -e "${BOLD}${GREEN}βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${RESET}"
echo -e "${BOLD}${GREEN}β β${RESET}"
echo -e "${BOLD}${GREEN}β π AUDIOFORGE IS NOW RUNNING! π β${RESET}"
echo -e "${BOLD}${GREEN}β β${RESET}"
echo -e "${BOLD}${GREEN}β Visit http://localhost:3000 to get started β${RESET}"
echo -e "${BOLD}${GREEN}β β${RESET}"
echo -e "${BOLD}${GREEN}βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${RESET}"
echo ""
echo -e "${YELLOW}Tip: Use 'docker-compose logs -f' to follow logs${RESET}"
echo -e "${YELLOW}Tip: Use 'docker-compose down' to stop all services${RESET}"
echo ""
}
# Run main function
main
|