#!/bin/bash # LLM Fusion MCP - Production Deployment Script set -e echo "🚀 LLM Fusion MCP - Production Deployment" echo "==========================================" # Configuration DEPLOY_ENV=${1:-production} DOCKER_IMAGE="llm-fusion-mcp:latest" CONTAINER_NAME="llm-fusion-mcp-${DEPLOY_ENV}" # 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_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 prerequisites print_status "Checking prerequisites..." if ! command -v docker &> /dev/null; then print_error "Docker is not installed. Please install Docker first." exit 1 fi if ! command -v docker-compose &> /dev/null; then print_error "Docker Compose is not installed. Please install Docker Compose first." exit 1 fi # Check environment file if [ ! -f ".env" ]; then if [ -f ".env.${DEPLOY_ENV}" ]; then print_status "Copying .env.${DEPLOY_ENV} to .env" cp ".env.${DEPLOY_ENV}" .env else print_warning "No .env file found. Copying .env.production template." cp .env.production .env print_warning "Please edit .env with your API keys before running!" read -p "Press enter to continue once you've configured .env..." fi fi # Validate API keys print_status "Validating configuration..." source .env if [ -z "$GOOGLE_API_KEY" ] || [ "$GOOGLE_API_KEY" = "your_google_api_key_here" ]; then print_error "GOOGLE_API_KEY is required but not configured in .env" exit 1 fi print_success "Configuration validated!" # Stop existing container print_status "Stopping existing containers..." docker-compose down --remove-orphans || true # Build new image print_status "Building Docker image..." docker-compose build --no-cache # Start services print_status "Starting services..." docker-compose up -d # Wait for services to be ready print_status "Waiting for services to start..." sleep 10 # Health check print_status "Performing health check..." if docker-compose ps | grep -q "Up"; then print_success "✅ LLM Fusion MCP deployed successfully!" print_success "Container: $(docker-compose ps --services)" print_success "Logs: docker-compose logs -f" else print_error "❌ Deployment failed. Check logs: docker-compose logs" exit 1 fi # Show status echo "" echo "🎉 Deployment Complete!" echo "======================" echo "Environment: $DEPLOY_ENV" echo "Container: $CONTAINER_NAME" echo "Image: $DOCKER_IMAGE" echo "" echo "Useful commands:" echo " View logs: docker-compose logs -f" echo " Stop services: docker-compose down" echo " Restart: docker-compose restart" echo " Shell access: docker-compose exec llm-fusion-mcp bash" echo "" print_success "LLM Fusion MCP is now running! 🚀"