Files
vip-coordinator/deploy.sh
kyle 36cb8e8886 Backup: 2025-06-08 00:29 - User and admin online ready for dockerhub
[Restore from backup: vip-coordinator-backup-2025-06-08-00-29-user and admin online ready for dockerhub]
2026-01-24 09:34:43 +01:00

139 lines
4.1 KiB
Bash

#!/bin/bash
# VIP Coordinator Quick Deploy Script
# This script helps you deploy the VIP Coordinator application using Docker
set -e
echo "🚀 VIP Coordinator Deployment Script"
echo "===================================="
# Check if Docker is installed
if ! command -v docker &> /dev/null; then
echo "❌ Docker is not installed. Please install Docker first."
exit 1
fi
# Check if Docker Compose is installed
if ! command -v docker-compose &> /dev/null; then
echo "❌ Docker Compose is not installed. Please install Docker Compose first."
exit 1
fi
# Check if .env file exists
if [ ! -f ".env" ]; then
echo "⚠️ No .env file found. Creating one from .env.example..."
if [ -f ".env.example" ]; then
cp .env.example .env
echo "✅ Created .env file from .env.example"
echo ""
echo "🔧 IMPORTANT: Please edit the .env file and update the following:"
echo " - POSTGRES_PASSWORD (set a secure password)"
echo " - GOOGLE_CLIENT_ID (from Google Cloud Console)"
echo " - GOOGLE_CLIENT_SECRET (from Google Cloud Console)"
echo " - VITE_API_URL (your backend URL)"
echo " - VITE_FRONTEND_URL (your frontend URL)"
echo ""
echo "📖 For Google OAuth setup instructions, see:"
echo " https://console.cloud.google.com/"
echo ""
read -p "Press Enter after updating the .env file to continue..."
else
echo "❌ .env.example file not found. Please create a .env file manually."
exit 1
fi
fi
# Validate required environment variables
echo "🔍 Validating environment configuration..."
# Source the .env file
set -a
source .env
set +a
# Check required variables
REQUIRED_VARS=("POSTGRES_PASSWORD" "GOOGLE_CLIENT_ID" "GOOGLE_CLIENT_SECRET")
MISSING_VARS=()
for var in "${REQUIRED_VARS[@]}"; do
if [ -z "${!var}" ] || [ "${!var}" = "your_secure_password_here" ] || [ "${!var}" = "your_google_client_id_here" ] || [ "${!var}" = "your_google_client_secret_here" ]; then
MISSING_VARS+=("$var")
fi
done
if [ ${#MISSING_VARS[@]} -ne 0 ]; then
echo "❌ The following required environment variables are missing or have default values:"
for var in "${MISSING_VARS[@]}"; do
echo " - $var"
done
echo ""
echo "Please update your .env file with the correct values."
exit 1
fi
echo "✅ Environment configuration looks good!"
# Pull the latest images
echo ""
echo "📥 Pulling latest Docker images..."
docker pull t72chevy/vip-coordinator:backend-latest
docker pull t72chevy/vip-coordinator:frontend-latest
# Stop existing containers if running
echo ""
echo "🛑 Stopping existing containers (if any)..."
docker-compose down --remove-orphans || true
# Start the application
echo ""
echo "🚀 Starting VIP Coordinator application..."
docker-compose up -d
# Wait for services to be healthy
echo ""
echo "⏳ Waiting for services to start..."
sleep 10
# Check service status
echo ""
echo "📊 Service Status:"
docker-compose ps
# Check if services are healthy
echo ""
echo "🏥 Health Checks:"
# Check backend health
if curl -f -s http://localhost:3000/health > /dev/null 2>&1; then
echo "✅ Backend is healthy"
else
echo "⚠️ Backend health check failed (may still be starting up)"
fi
# Check frontend
if curl -f -s http://localhost > /dev/null 2>&1; then
echo "✅ Frontend is accessible"
else
echo "⚠️ Frontend health check failed (may still be starting up)"
fi
echo ""
echo "🎉 Deployment complete!"
echo ""
echo "📱 Access your application:"
echo " Frontend: http://localhost"
echo " Backend API: http://localhost:3000"
echo " Health Check: http://localhost:3000/health"
echo ""
echo "📋 Useful commands:"
echo " View logs: docker-compose logs -f"
echo " Stop app: docker-compose down"
echo " Restart: docker-compose restart"
echo " Update: docker-compose pull && docker-compose up -d"
echo ""
echo "🆘 If you encounter issues:"
echo " 1. Check logs: docker-compose logs"
echo " 2. Verify .env configuration"
echo " 3. Ensure Google OAuth is properly configured"
echo " 4. Check that ports 80 and 3000 are available"