Complete guide for deploying Ciousten backend on Render.com
- GitHub repository with Ciousten code
- Render.com account (free tier works)
- OpenRouter API key (for AI features)
- Go to Render Dashboard
- Click "New +" → "Blueprint"
- Connect your GitHub repository
- Select
Ciousten---Video-Insights---Reports
In Render dashboard, set these environment variables:
OPENROUTER_API_KEY=sk-or-v1-your-key-here
PORT=8000
PYTHONUNBUFFERED=1
ENVIRONMENT=production
DATA_DIR=/app/data
REPORTS_DIR=/app/reports
LOG_LEVEL=INFO
- Click "Apply" to deploy from blueprint
- Wait 5-10 minutes for initial build
- Check deployment logs for any errors
curl https://your-app.onrender.com/healthExpected response:
{
"status": "healthy",
"version": "1.3.0",
"system": {
"cpu_percent": 5.2,
"memory_percent": 45.3,
...
}
}Visit: https://your-app.onrender.com/docs
curl https://your-app.onrender.com/disk:
name: ciousten-data
mountPath: /app/data
sizeGB: 1 # Free tier limitWhat's stored:
- Uploaded videos
- Processed frames
- Segmentation results
- Generated reports
Note: Free tier disk is ephemeral and resets on redeploy
healthCheckPath: /healthInterval: Every 30 seconds
Timeout: 10 seconds
Start Period: 40 seconds
Retries: 3
autoDeploy: true
buildFilter:
paths:
- backend/**
- render.yamlTriggers: Only deploys when backend code or render.yaml changes
# Builder stage - compile dependencies
FROM python:3.10-slim as builder
RUN pip install --user -r requirements.txt
# Production stage - minimal image
FROM python:3.10-slim
COPY --from=builder /root/.local /root/.localBenefits:
- Smaller image size (~500MB vs ~1GB)
- Faster deployments
- Better caching
uvicorn app.main:app \
--host 0.0.0.0 \
--port ${PORT} \
--workers 1 \
--log-level infoSettings:
workers 1: Free tier has limited resourceslog-level info: Balanced logging- Dynamic port binding
- ✅ API keys not in code
- ✅ Secrets synced from dashboard
- ✅ Production environment flag
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # Configured for public API
allow_methods=["*"],
allow_headers=["*"],
)- Upload: 5 requests/hour
- Sample: 10 requests/hour
- Analysis: 10 requests/hour
- General: 100 requests/hour
- CPU usage
- Memory usage
- Request count
- Response times
- Error rates
# View logs in Render dashboard
# Or use Render CLI
render logs -fMonitor at: /health
Returns:
- System metrics (CPU, memory, disk)
- Service status
- Active sessions
- Version info
Monitor at: /api/stats
Returns:
- Total requests
- Requests per endpoint
- Error counts
- Response times
- Top endpoints
Issue: Docker build fails
Solution: Check Dockerfile syntax and paths
Issue: Dependency installation fails
Solution: Verify requirements.txt versions
Issue: Health check fails
Solution: Check logs for startup errors
Issue: CORS errors
Solution: Verify CORSMiddleware is first
Issue: Sample video not found
Solution: Auto-download feature will handle this
Issue: Slow responses
Solution: Check CPU/memory usage in dashboard
Issue: Timeouts
Solution: Increase timeout in render.yaml
- Memory: 512 MB
- CPU: Shared
- Disk: 1 GB (ephemeral)
- Bandwidth: 100 GB/month
- Build Minutes: 500/month
Starter Plan ($7/month):
- 512 MB RAM
- Persistent disk
- No sleep on inactivity
Standard Plan ($25/month):
- 2 GB RAM
- More CPU
- Better performance
1. Push to GitHub main branch
2. Render detects changes
3. Builds Docker image
4. Runs health checks
5. Deploys to production
6. Verifies deployment
# Trigger manual deploy
render deploy# Rollback to previous version
render rollback| Variable | Description | Example |
|---|---|---|
OPENROUTER_API_KEY |
AI analysis API key | sk-or-v1-... |
| Variable | Description | Default |
|---|---|---|
PORT |
Server port | 8000 |
ENVIRONMENT |
Environment name | production |
DATA_DIR |
Data storage path | /app/data |
REPORTS_DIR |
Reports path | /app/reports |
LOG_LEVEL |
Logging level | INFO |
- ✅ Use Render dashboard for secrets
- ✅ Never commit API keys
- ✅ Use environment-specific configs
- ✅ Use structured logging
- ✅ Log important events
- ✅ Monitor error rates
- ✅ Implement comprehensive health endpoint
- ✅ Check all critical services
- ✅ Return detailed status
- ✅ Graceful degradation
- ✅ User-friendly error messages
- ✅ Automatic retry for transient errors
- ✅ Use multi-stage builds
- ✅ Minimize image size
- ✅ Cache dependencies
- ✅ Optimize database queries
- Code pushed to GitHub
- render.yaml configured
- Dockerfile optimized
- Environment variables set
- API keys added to Render
- Blueprint applied
- Build successful
- Health check passing
- Logs reviewed
- No errors in console
- Test health endpoint
- Test API endpoints
- Verify CORS working
- Check sample video
- Monitor performance
- Set up monitoring
- Configure alerts
- Document deployment
- Train team
- Plan for scaling
- ✅ Build time: < 5 minutes
- ✅ Deploy time: < 2 minutes
- ✅ Health check: Passing
- ✅ Uptime: > 99%
- ✅ Response time: < 200ms
- ✅ Error rate: < 1%
- ✅ CPU usage: < 50%
- ✅ Memory usage: < 80%
Status: ✅ Production Ready
Version: 1.3.0
Platform: Render.com
Made by: Aditya Shenvi @2025