- ✅ Google Cloud Project created
- ✅
gcloudCLI installed - ✅ Docker installed
- ✅ GitHub repository connected
On Windows (PowerShell):
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
.\setup-gcp.ps1On macOS/Linux (Bash):
chmod +x setup-gcp.sh
./setup-gcp.shThis script will:
- ✅ Enable all required Google Cloud APIs
- ✅ Create service accounts with proper permissions
- ✅ Set up Workload Identity Federation for GitHub Actions
- ✅ Create Cloud Storage buckets
- ✅ Display your Project ID and service account emails
Save the output - you'll need it for GitHub secrets!
Go to: Settings > Secrets and variables > Actions
Add these secrets from the script output:
GCP_PROJECT_ID = your-project-id-123
WIF_PROVIDER = projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/github-pool/providers/github-provider
WIF_SERVICE_ACCOUNT = github-actions@your-project-id-123.iam.gserviceaccount.com
CLOUD_RUN_SERVICE_ACCOUNT = legalmind-backend@your-project-id-123.iam.gserviceaccount.com
API_URL = (leave empty for now, update after first deploy)
To create FIREBASE_SERVICE_ACCOUNT:
# Run this command locally
gcloud iam service-accounts keys create firebase-key.json \
--iam-account=legalmind-backend@YOUR_PROJECT_ID.iam.gserviceaccount.com
# View the file content and base64 encode it
cat firebase-key.json | base64 -w 0
# Copy the output and add it as FIREBASE_SERVICE_ACCOUNT secretCreate .env.local in the backend/ directory:
GOOGLE_CLOUD_PROJECT=your-project-id-123
DEBUG=falseThe frontend environment variables are automatically set by GitHub Actions.
Just push to main:
git add .
git commit -m "Deploy to Google Cloud"
git push origin mainGitHub Actions will automatically:
- Build and push Docker image to Container Registry
- Deploy to Cloud Run
- Build and deploy frontend to Firebase Hosting
Watch the deployment:
- GitHub:
Actionstab - Cloud Run:
gcloud run services list --region us-central1 - Firebase:
firebase hosting:channel:list
# Backend URL
gcloud run services describe legalmind-backend \
--region us-central1 \
--format='value(status.url)'
# Frontend URL (automatically deployed)
# https://YOUR_PROJECT_ID.web.appAfter first deploy, add the backend URL to GitHub secrets:
API_URL = https://legalmind-backend-YOUR_PROJECT_ID.cloudfunctions.net
# Test backend
curl https://legalmind-backend-YOUR_PROJECT_ID.cloudfunctions.net/docs
# Frontend should be live at
# https://YOUR_PROJECT_ID.web.app# Backend logs
gcloud run logs read legalmind-backend --region us-central1 --follow
# Firebase hosting logs
firebase hosting:sites list# Check Cloud Run deployment status
gcloud run services describe legalmind-backend --region us-central1
# View detailed error logs
gcloud run logs read legalmind-backend --region us-central1 --limit 100
# Check GitHub Actions logs
# Go to Settings > Secrets and variables > Actions to see what failed# Make sure Cloud Run is allowing unauthenticated access
gcloud run services update legalmind-backend \
--allow-unauthenticated \
--region us-central1# Check Firebase project is initialized
firebase projects:list
# Reinitialize if needed
firebase init hosting- Cloud Run: ~$0.40/million requests + compute
- Firebase Hosting: Free tier: 10 GB/month storage, 360 MB/day transfer
- Firestore: Free tier: 25k reads, 25k writes, 1 GB storage/day
- Cloud Storage: Free tier: 5 GB/month
Total estimated cost: ~$5-15/month for moderate usage
- ✅ Monitor your deployment in Cloud Run
- ✅ Set up custom domain (optional)
- ✅ Enable HTTPS (automatic with Cloud Run)
- ✅ Configure auto-scaling limits
- ✅ Set up monitoring and alerts
For full deployment guide, see DEPLOYMENT_GUIDE.md