Deployment Summary - Combined V5 + theia
🎯 What Problem Did We Solve?
Your Question: "How are we deploying the theia component too?"
Answer: We're deploying both V5 Frontend and theia Backend in a single Docker container with NGINX routing.
📦 What We Created
5 New Deployment Files
- dockerfile.combined - Multi-stage build (V5 + theia + NGINX)
- nginx-combined.conf - Routes
/→ V5,/theia→ theia - start-combined.sh - Starts both NGINX and theia processes
- cloudbuild-combined.yaml - Cloud Build configuration
- k8s-combined-deployment.yaml - Kubernetes deployment manifest
2 Documentation Files
- deploy-combined.md - Step-by-step deployment guide
- DEPLOYMENT-architecture.md - Architecture diagrams and debugging
🏗️ How It Works
Single Container Architecture
┌────────────────────────────────────┐
│ Docker Container (Port 80) │
├────────────────────────────────────┤
│ │
│ NGINX │
│ ├─→ / → V5 Frontend (dist/) │
│ └─→ /theia → theia (localhost:3000)│
│ │
│ Node.js (Port 3000) │
│ └─→ Eclipse theia IDE │
│ │
└────────────────────────────────────┘
User Access Flow
User visits: https://coditect.ai/
↓
NGINX serves: V5 Frontend (React SPA)
↓
User clicks "workspace" tab
↓
React loads: <iframe src="/theia">
↓
NGINX proxies: /theia → localhost:3000
↓
theia IDE loads: Monaco editor, terminal, File Explorer
↓
WebSocket connects: /theia/services (terminal I/O)
🚀 How to Deploy
One Command Deployment
# From project root: /home/hal/v4/PROJECTS/t2/
gcloud builds submit --config cloudbuild-combined.yaml
What Happens:
- ✅ Builds V5 Frontend (3 min)
- ✅ Builds theia Backend (25 min)
- ✅ Creates Docker image (5 min)
- ✅ Pushes to Artifact Registry (5 min)
- ✅ Deploys to GKE cluster (10 min)
Total Time: ~60 minutes
Access Your App
After deployment:
- Frontend: https://coditect.ai/
- theia IDE: https://coditect.ai/theia
- Health Check: https://coditect.ai/health
📊 What You Get
Infrastructure
- 3 pods running combined service
- Auto-scaling (3-10 pods based on load)
- Load balancer (Google Cloud Load Balancer)
- SSL certificate (Google-managed for coditect.ai)
- Health checks (liveness + readiness probes)
- Session affinity (WebSocket support)
Cost
- Compute: ~$130/month (3 pods × 1GB RAM × 0.5 CPU)
- Load Balancer: ~$20/month
- Storage: ~$10/month
- Total: ~$160/month
🔍 Verification Steps
1. Check Build Status
# Watch Cloud Build progress
gcloud builds list --limit=1
# Stream logs
gcloud builds log $(gcloud builds list --limit=1 --format='value(id)')
2. Check Deployment Status
# Check pods
kubectl get pods | grep coditect-combined
# Expected output:
# coditect-combined-xxxxx-yyy 1/1 Running 0 5m
# coditect-combined-xxxxx-zzz 1/1 Running 0 5m
# coditect-combined-xxxxx-www 1/1 Running 0 5m
3. Check Application Health
# Health endpoint
curl https://coditect.ai/health
# Expected: "healthy"
# Frontend
curl -I https://coditect.ai/
# Expected: HTTP/2 200
# theia
curl -I https://coditect.ai/theia/
# Expected: HTTP/2 200
4. Browser Testing
- Open https://coditect.ai/ → See V5 UI ✅
- Click "workspace" tab → theia loads ✅
- Type in terminal → See output ✅
- Edit file in Monaco → See changes ✅
- Browse files → See file tree ✅
🐛 Common Issues & Fixes
Issue 1: Build Timeout
Error: Build timeout (60 minutes exceeded)
Fix: Increase timeout in cloudbuild-combined.yaml:
timeout: '7200s' # 2 hours
Issue 2: Out of Memory
Error: Pod OOMKilled
Fix: Increase memory in k8s-combined-deployment.yaml:
resources:
limits:
memory: "4Gi" # Up from 2Gi
Issue 3: theia Won't Start
Error: Cannot find module '@theia/core'
Fix: Rebuild with fresh dependencies:
docker build --no-cache -f dockerfile.combined .
Issue 4: WebSocket Fails
Error: WebSocket connection failed
Fix: Check session affinity in service:
sessionAffinity: ClientIP
sessionAffinityConfig:
clientIP:
timeoutSeconds: 10800 # 3 hours
📚 Documentation Reference
| File | Purpose |
|---|---|
DEPLOYMENT-architecture.md | Detailed architecture diagrams, debugging |
deploy-combined.md | Step-by-step deployment guide |
dockerfile.combined | Docker build configuration |
nginx-combined.conf | NGINX routing configuration |
cloudbuild-combined.yaml | Google Cloud Build pipeline |
k8s-combined-deployment.yaml | Kubernetes manifests |
✅ Success Checklist
Before considering deployment complete:
- Cloud Build succeeds (no errors)
- All 3 pods are Running
- Health check returns "healthy"
- V5 frontend loads at https://coditect.ai/
- theia IDE loads at https://coditect.ai/theia
- Monaco editor works (can edit files)
- terminal works (can type commands)
- File explorer works (can browse files)
- WebSocket stable (terminal doesn't disconnect)
- No errors in browser console
- No errors in pod logs
🎯 Key Takeaways
What Changed From Original Plan
Before: Two separate deployments
- V5 Frontend (nginx + dist/)
- theia Backend (separate service)
After: Single combined deployment
- One Docker image
- One Kubernetes deployment
- One service endpoint
- Simpler architecture
- Lower cost
- Easier to manage
Why This Approach
✅ Simpler: One build, one deployment ✅ Faster: Shared network (no external calls) ✅ Cheaper: One load balancer, fewer resources ✅ Reliable: No cross-service dependencies ✅ Secure: theia not exposed to internet
Trade-offs
❌ Slower builds: Must rebuild both on any change ❌ Larger image: ~1.5 GB (vs ~200 MB for V5 only) ❌ Less flexible: Can't scale V5 and theia independently
Recommendation: Start with combined, split later if needed.
🚀 Ready to Deploy?
# 1. Verify you're in the right project
gcloud config get-value project
# Expected: serene-voltage-464305-n2
# 2. Verify cluster exists
gcloud container clusters list
# Expected: codi-poc-e2-cluster (us-central1-a)
# 3. Deploy!
gcloud builds submit --config cloudbuild-combined.yaml
# 4. Wait ~60 minutes
# 5. Test
curl https://coditect.ai/health
That's it! Your V5 Frontend + theia IDE are now deployed to production! 🎉
📞 Support
Need Help?
- Check logs:
kubectl logs -f deployment/coditect-combined - Check events:
kubectl get events --sort-by='.lastTimestamp' - Check resources:
kubectl top pods
Still Stuck?
- Review:
DEPLOYMENT-architecture.md(debugging section) - Review:
deploy-combined.md(troubleshooting section)