deploy-to-vercel.ps1โข5.3 kB
# ODIADEV MCP Server - Production Deployment Script (PowerShell)
# This script handles the complete deployment process with error checking
Write-Host "๐ ODIADEV MCP SERVER - PRODUCTION DEPLOYMENT" -ForegroundColor Green
Write-Host "=" * 50
# Function to check if command exists
function Test-Command($cmdname) {
return [bool](Get-Command -Name $cmdname -ErrorAction SilentlyContinue)
}
# Check prerequisites
Write-Host "`n๐ Checking prerequisites..." -ForegroundColor Blue
if (-not (Test-Command "git")) {
Write-Host "โ Git is not installed or not in PATH" -ForegroundColor Red
exit 1
}
Write-Host "โ
Git found" -ForegroundColor Green
if (-not (Test-Command "vercel")) {
Write-Host "โ Vercel CLI is not installed. Install with: npm install -g vercel" -ForegroundColor Red
exit 1
}
Write-Host "โ
Vercel CLI found" -ForegroundColor Green
# Validate vercel.json
Write-Host "`n๐ Validating vercel.json..." -ForegroundColor Blue
try {
$vercelConfig = Get-Content "vercel.json" -Raw | ConvertFrom-Json
Write-Host "โ
vercel.json is valid JSON" -ForegroundColor Green
} catch {
Write-Host "โ vercel.json is not valid JSON: $($_.Exception.Message)" -ForegroundColor Red
exit 1
}
# Test local compilation
Write-Host "`n๐งช Testing local compilation..." -ForegroundColor Blue
$testResult = & node test-fixes.js 2>&1
if ($LASTEXITCODE -eq 0) {
Write-Host "โ
All local tests passed" -ForegroundColor Green
} else {
Write-Host "โ Local tests failed:" -ForegroundColor Red
Write-Host $testResult
Read-Host "Press Enter to continue anyway or Ctrl+C to abort"
}
# Commit and push changes
Write-Host "`n๐ค Step 1: Committing and pushing changes..." -ForegroundColor Blue
try {
git add .
git commit -m "Fix vercel.json and healthcheck syntax - Production ready"
git push origin main
Write-Host "โ
Changes pushed successfully" -ForegroundColor Green
} catch {
Write-Host "โ ๏ธ Git operations failed - continuing with deployment" -ForegroundColor Yellow
}
# Set environment variables
Write-Host "`n๐ง Step 2: Setting up production environment variables..." -ForegroundColor Blue
$envVars = @{
"CORS_ALLOW_ORIGIN" = "https://mcp.odia.dev"
"NODE_ENV" = "production"
"VALID_API_KEYS" = "odiadev_production_key_2024,agent_lexi_production_key"
"ODIA_TTS_BASE_URL" = "https://odiadev-tts-plug-n-play.onrender.com/speak"
"ODIA_TTS_DEFAULT_VOICE" = "nigerian-female"
"ODIA_TTS_TIMEOUT_MS" = "30000"
"ODIA_TTS_MAX_TEXT_LENGTH" = "500"
"RATE_LIMIT_MAX" = "100"
"RATE_LIMIT_WINDOW" = "60000"
}
foreach ($var in $envVars.GetEnumerator()) {
Write-Host " โ๏ธ Setting $($var.Key)..." -ForegroundColor Cyan
try {
$var.Value | vercel env add $var.Key production 2>$null
Write-Host " โ
$($var.Key) set successfully" -ForegroundColor Green
} catch {
Write-Host " โ ๏ธ Failed to set $($var.Key) - may already exist" -ForegroundColor Yellow
}
}
# Display manual setup instructions
Write-Host "`nโ ๏ธ IMPORTANT: Manual Setup Required" -ForegroundColor Yellow
Write-Host "You need to manually set these sensitive variables in Vercel dashboard:" -ForegroundColor Yellow
Write-Host " - FLW_SECRET_KEY (Flutterwave Secret Key)" -ForegroundColor White
Write-Host " - FLW_PUBLIC_KEY (Flutterwave Public Key)" -ForegroundColor White
Write-Host " - FLW_ENCRYPTION_KEY (Flutterwave Encryption Key)" -ForegroundColor White
Write-Host " - FLW_WEBHOOK_SECRET_HASH (Flutterwave Webhook Hash)" -ForegroundColor White
Write-Host "`n๐ Visit: https://vercel.com/dashboard/[your-project]/settings/environment-variables" -ForegroundColor Cyan
Read-Host "`nPress Enter after setting up the Flutterwave credentials to continue"
# Deploy to production
Write-Host "`n๐ Step 3: Deploying to production..." -ForegroundColor Blue
try {
$deployResult = vercel --prod 2>&1
if ($LASTEXITCODE -eq 0) {
Write-Host "โ
Deployment successful!" -ForegroundColor Green
Write-Host $deployResult
# Extract deployment URL
$deployUrl = ($deployResult | Select-String "https://.*\.vercel\.app").Matches.Value
if ($deployUrl) {
Write-Host "`n๐ Testing deployment..." -ForegroundColor Blue
Write-Host "Testing URL: $deployUrl" -ForegroundColor Cyan
# Test the deployment
& node verify-production.js $deployUrl
}
} else {
Write-Host "โ Deployment failed:" -ForegroundColor Red
Write-Host $deployResult
exit 1
}
} catch {
Write-Host "โ Deployment error: $($_.Exception.Message)" -ForegroundColor Red
exit 1
}
Write-Host "`n๐ DEPLOYMENT COMPLETE!" -ForegroundColor Green
Write-Host "๐ณ๐ฌ Your ODIADEV MCP Server is now live and ready to power Nigeria's AI infrastructure!" -ForegroundColor Green
Write-Host "`n๐ Next Steps:" -ForegroundColor Blue
Write-Host "1. Test all endpoints with real data" -ForegroundColor White
Write-Host "2. Set up monitoring and alerts" -ForegroundColor White
Write-Host "3. Configure custom domain: mcp.odia.dev" -ForegroundColor White
Write-Host "4. Update documentation with production URLs" -ForegroundColor White
Read-Host "`nPress Enter to exit"