Skip to content

Commit eba66d3

Browse files
committed
feat: Add deployment script for backend with enforced Vertex AI configuration
1 parent dd3415d commit eba66d3

1 file changed

Lines changed: 72 additions & 0 deletions

File tree

deploy-backend-vertex-ai-fix.ps1

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/usr/bin/env pwsh
2+
# =============================================================================
3+
# Deploy Backend with Vertex AI Configuration
4+
# =============================================================================
5+
6+
Write-Host ""
7+
Write-Host "=" * 80 -ForegroundColor Cyan
8+
Write-Host "DEPLOYING BACKEND WITH VERTEX AI FIX" -ForegroundColor Cyan
9+
Write-Host "=" * 80 -ForegroundColor Cyan
10+
Write-Host ""
11+
12+
Write-Host "🔧 Configuration:" -ForegroundColor Yellow
13+
Write-Host " - USE_VERTEX_AI=true (enforced)" -ForegroundColor Green
14+
Write-Host " - Default in settings.py changed to True" -ForegroundColor Green
15+
Write-Host " - Dockerfile sets USE_VERTEX_AI=true" -ForegroundColor Green
16+
Write-Host ""
17+
18+
Write-Host "🚀 Starting deployment..." -ForegroundColor Yellow
19+
Write-Host ""
20+
21+
try {
22+
$deployCmd = "gcloud run deploy legalmind-backend " +
23+
"--source=backend " +
24+
"--project=legalmind-486106 " +
25+
"--region=us-central1 " +
26+
"--allow-unauthenticated " +
27+
"--set-env-vars=USE_VERTEX_AI=true " +
28+
"--platform=managed " +
29+
"--quiet"
30+
31+
Write-Host "Command: $deployCmd" -ForegroundColor Gray
32+
Write-Host ""
33+
34+
Invoke-Expression $deployCmd
35+
36+
if ($LASTEXITCODE -eq 0) {
37+
Write-Host ""
38+
Write-Host "=" * 80 -ForegroundColor Green
39+
Write-Host "✅ DEPLOYMENT SUCCESSFUL!" -ForegroundColor Green
40+
Write-Host "=" * 80 -ForegroundColor Green
41+
Write-Host ""
42+
Write-Host "🧪 Test the fix:" -ForegroundColor Yellow
43+
Write-Host ""
44+
Write-Host " curl https://legalmind-backend-677928716377.us-central1.run.app/health" -ForegroundColor Cyan
45+
Write-Host ""
46+
Write-Host "Expected: HTTP 200 with Vertex AI configured" -ForegroundColor Gray
47+
Write-Host "No more 403 errors about 'generativelanguage.googleapis.com'" -ForegroundColor Gray
48+
Write-Host ""
49+
} else {
50+
Write-Host ""
51+
Write-Host "❌ Deployment failed with exit code: $LASTEXITCODE" -ForegroundColor Red
52+
Write-Host ""
53+
}
54+
}
55+
catch {
56+
Write-Host ""
57+
Write-Host "❌ Error during deployment:" -ForegroundColor Red
58+
Write-Host $_.Exception.Message -ForegroundColor Red
59+
Write-Host ""
60+
}
61+
62+
Write-Host ""
63+
Write-Host "📋 What Was Fixed:" -ForegroundColor Cyan
64+
Write-Host ""
65+
Write-Host "1. Changed default use_vertex_ai from False → True" -ForegroundColor White
66+
Write-Host "2. Changed USE_VERTEX_AI env var default from 'false' → 'true'" -ForegroundColor White
67+
Write-Host "3. Added USE_VERTEX_AI=true to Dockerfile" -ForegroundColor White
68+
Write-Host "4. Explicitly set USE_VERTEX_AI=true in Cloud Run deployment" -ForegroundColor White
69+
Write-Host ""
70+
Write-Host "This ensures the backend ALWAYS uses Vertex AI (aiplatform.googleapis.com)" -ForegroundColor White
71+
Write-Host "instead of the public Gemini API (generativelanguage.googleapis.com)" -ForegroundColor White
72+
Write-Host ""

0 commit comments

Comments
 (0)