Deployment Workflow
Step-by-step workflow for deploying services from local development to production, with testing and verification at each stage.
π Complete Workflow
π¦ Phase 1: Backend Deployment
Local Testing
cd apps/backend
./deploy-local-docker.shWait for deployment, then verify:
# Health check
curl http://localhost:8090/health | jq
# API docs
open http://localhost:8090/docs
# Test endpoint
curl http://localhost:8090/v1/leagues | jqDo not proceed to Cloud Run until local tests pass!
Stop local Docker:
docker compose downDeploy to Cloud Run
cd /path/to/project/root
./deploy-all.shSelect: Option 2 (Backend only)
Monitor: Terminal shows progress:
Building image...
Pushing to GCR...
Deploying to Cloud Run...
β
Deployment successful!Save the URL:
cat .backend-url
# https://altsportsleagues-backend-xxx-uc.a.run.appMap Custom Domain
Google Cloud Console:
- Navigate to Cloud Run (opens in a new tab)
- Click
altsportsleagues-backend - Tab: "Manage Custom Domains"
- Click "Add Mapping"
- Domain:
api.altsportsleagues.ai - Region:
us-central1 - Continue
- Note CNAME:
ghs.googlehosted.com
Cloudflare DNS:
- Cloudflare Dashboard (opens in a new tab)
- Domain:
altsportsleagues.ai - DNS β Add Record
- Configure:
- Type: CNAME
- Name:
api - Target:
ghs.googlehosted.com - Proxy: βοΈ ON
- Save
Wait: 5-30 minutes for SSL verification
Verify Backend
# Test custom domain
curl https://api.altsportsleagues.ai/health | jq
# Test API
curl https://api.altsportsleagues.ai/v1/leagues | jq
# Open docs
open https://api.altsportsleagues.ai/docsβ Backend is live when all tests return 200 OK!
π¨ Phase 2: Frontend Deployment
Update Configuration
Edit clients/frontend/vercel.json:
{
"rewrites": [
{
"source": "/api/v1/:path*",
"destination": "https://api.altsportsleagues.ai/v1/:path*"
}
]
}Key change: Use custom domain, remove /api/ from backend path
Set Environment Variables
Vercel Dashboard:
- Go to project β Settings β Environment Variables
- Add for Production:
NEXT_PUBLIC_API_URL=https://api.altsportsleagues.ai BACKEND_API_URL=https://api.altsportsleagues.ai
Deploy to Vercel
cd clients/frontend
vercel --prodWait: 2-5 minutes
Map Custom Domain
Vercel Dashboard:
- Project β Settings β Domains
- Add:
altsportsleagues.ai - Note CNAME from Vercel
Cloudflare:
- DNS β Add Record
- Configure:
- Type: CNAME
- Name:
@ - Target:
cname.vercel-dns.com - Proxy: βοΈ ON
Verify Frontend
# Open site
open https://altsportsleagues.ai
# Test API proxy
curl https://altsportsleagues.ai/api/v1/leagues | jqBrowser DevTools Check:
- No CORS errors β
- API calls return 200 β
- No mixed content warnings β
π Phase 3: Documentation Site
β Phase 4: Final Verification
Complete System Test
# Backend direct
curl https://api.altsportsleagues.ai/health
# Frontend (should load)
open https://altsportsleagues.ai
# Frontend API proxy (should work)
curl https://altsportsleagues.ai/api/v1/leagues
# Docs site
open https://docs.altsportsleagues.ai
# n8n (if configured)
open https://n8n.altsportsleagues.aiBrowser Integration Test
- Visit
https://altsportsleagues.ai - Open DevTools (F12)
- Navigate to pages that make API calls
- Console: No errors
- Network: All API calls return 200
- Application: Firebase auth works
All systems go! If all tests pass, your production deployment is complete. π
π Continuous Deployment
Git-Based Deployment
Frontend & Docs: Auto-deploy on Git push to main
Backend: Manual deploy via script (controlled releases)
π Deployment Metrics
Typical Deployment Times
| Service | Local Test | Deploy | Domain Map | Total |
|---|---|---|---|---|
| Backend | 2 min | 8 min | 20 min | ~30 min |
| Frontend | 1 min | 5 min | 10 min | ~16 min |
| Docs | 1 min | 5 min | 10 min | ~16 min |
| Total | ~60 min |
Parallel Deployment: Can reduce to ~35 minutes if backend and frontend deployed simultaneously
π― Next Steps
Now that you understand the deployment workflow, review the specific implementation steps for the clean URL migration:
- β URL Strategy - Understand the clean URL pattern
- β Service Map - See detailed service configurations
- β Security Architecture - Review security best practices