#!/bin/bash # GT 2.0 Unified Deployment Script # Platform-agnostic deployment and update system # Supports: ARM64 (Mac M2+), x86_64 (Ubuntu), DGX (Grace ARM + Blackwell GPU) set -e # Script directory for sourcing libraries SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # Source library functions source "$SCRIPT_DIR/lib/common.sh" source "$SCRIPT_DIR/lib/platform.sh" source "$SCRIPT_DIR/lib/docker.sh" source "$SCRIPT_DIR/lib/migrations.sh" source "$SCRIPT_DIR/lib/health.sh" source "$SCRIPT_DIR/lib/secrets.sh" # Default options DRY_RUN=false DEV_MODE=false SKIP_MIGRATIONS=false SKIP_PULL=false SKIP_CLEANUP=false FORCE=false PLATFORM="" # Display help show_help() { cat < gt-20 or vice versa) cleanup_conflicting_containers # Database services must start first (migrations depend on them) DB_SERVICES=( "postgres" "tenant-postgres-primary" ) # Application services (uses pulled images in prod, rebuilds in dev) APP_SERVICES=( "control-panel-backend" "control-panel-frontend" "tenant-backend" "tenant-app" "resource-cluster" ) # Other infrastructure services INFRA_SERVICES=( "vllm-embeddings" ) # Start database services first and wait for them to be healthy log_info "Starting database services..." for service in "${DB_SERVICES[@]}"; do restart_service "$service" done # Wait for databases to be healthy before running migrations log_info "Waiting for databases to be healthy..." wait_for_stability 15 # Run database migrations (now that databases are confirmed running) if [ "$SKIP_MIGRATIONS" != "true" ]; then if ! run_all_migrations; then log_error "Migrations failed - aborting deployment" exit 1 fi echo "" fi # Restart/rebuild application services based on mode for service in "${APP_SERVICES[@]}"; do restart_app_service "$service" done # Restart other infrastructure services for service in "${INFRA_SERVICES[@]}"; do restart_service "$service" done # Wait for stability wait_for_stability 10 # Health check if ! check_all_services_healthy; then log_error "Health check failed" exit 1 fi # Clean up unused Docker resources if [ "$SKIP_CLEANUP" != "true" ]; then cleanup_docker_resources fi # Show final status show_access_points } # Run main function main "$@"