#!/bin/bash # Tournament Application Production Deployment Script set -e echo "🚀 Deploying Tournament Application to Production..." # Check if we're in the docker directory if [ ! -f "docker-compose.prod.yml" ]; then echo "❌ Error: Please run this script from the docker directory" exit 1 fi # Check if .env file exists if [ ! -f ".env" ]; then echo "⚠️ Warning: No .env file found. Using default values." echo " Create a .env file with production values for security." fi # Stop existing containers echo "🛑 Stopping existing containers..." docker-compose -f docker-compose.prod.yml down # Build and start the application echo "🏗️ Building and starting application..." docker-compose -f docker-compose.prod.yml up -d --build # Wait for services to be healthy echo "⏳ Waiting for services to be ready..." sleep 10 # Check if services are running echo "🔍 Checking service status..." docker-compose -f docker-compose.prod.yml ps # Check application health echo "🏥 Checking application health..." if curl -f http://localhost/health > /dev/null 2>&1; then echo "✅ Application is healthy!" else echo "⚠️ Application health check failed, but it might still be starting up..." fi echo "" echo "🎉 Deployment completed!" echo "" echo "Application URLs:" echo " Frontend: http://localhost" echo " API: http://localhost:4000" echo "" echo "Useful commands:" echo " View logs: docker-compose -f docker-compose.prod.yml logs -f" echo " Stop app: docker-compose -f docker-compose.prod.yml down" echo " Restart: docker-compose -f docker-compose.prod.yml restart"