Skip to main content

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

  1. dockerfile.combined - Multi-stage build (V5 + theia + NGINX)
  2. nginx-combined.conf - Routes / → V5, /theia → theia
  3. start-combined.sh - Starts both NGINX and theia processes
  4. cloudbuild-combined.yaml - Cloud Build configuration
  5. k8s-combined-deployment.yaml - Kubernetes deployment manifest

2 Documentation Files

  1. deploy-combined.md - Step-by-step deployment guide
  2. 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:

  1. ✅ Builds V5 Frontend (3 min)
  2. ✅ Builds theia Backend (25 min)
  3. ✅ Creates Docker image (5 min)
  4. ✅ Pushes to Artifact Registry (5 min)
  5. ✅ Deploys to GKE cluster (10 min)

Total Time: ~60 minutes

Access Your App

After deployment:


📊 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

  1. Open https://coditect.ai/ → See V5 UI ✅
  2. Click "workspace" tab → theia loads ✅
  3. Type in terminal → See output ✅
  4. Edit file in Monaco → See changes ✅
  5. 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

FilePurpose
DEPLOYMENT-architecture.mdDetailed architecture diagrams, debugging
deploy-combined.mdStep-by-step deployment guide
dockerfile.combinedDocker build configuration
nginx-combined.confNGINX routing configuration
cloudbuild-combined.yamlGoogle Cloud Build pipeline
k8s-combined-deployment.yamlKubernetes 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)