Migrate CPU-intensive workloads to Cloud Run for autoscaling: - Add Whisper HTTP service (FastAPI) with /transcribe endpoint - Add FFmpeg HTTP service (FastAPI) with /encode, /probe, /extract-frame, etc. - Add Dockerfiles for both services (8 vCPU, 32GB RAM, Gen2) - Add Cloud Build config for CI/CD deployment - Add Cloud Run service YAML configs with scale-to-zero - Update whisper_transcribe.py to call Cloud Run when WHISPER_SERVICE_URL set - Update video_renderer.py to call Cloud Run when FFMPEG_SERVICE_URL set - Update whisper_service.py for Cloud Run compatibility (no settings dependency) - Add ffmpeg_service_url and whisper_service_url to config.py Services scale 0→N based on request load, falling back to local execution when service URLs are not configured (hybrid mode). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| api-service.yaml | ||
| cloudbuild-http-services.yaml | ||
| cloudbuild.yaml | ||
| deploy.sh | ||
| ffmpeg-http-service.yaml | ||
| main.tf | ||
| README.md | ||
| terraform.tfvars.example | ||
| tts-worker-service.yaml | ||
| whisper-http-service.yaml | ||
| whisper-worker-service.yaml | ||
| worker-service.yaml | ||
Cloud Run Deployment
This directory contains deployment configurations for running the Accessible Video Platform on Google Cloud Run.
Files
cloudbuild.yaml- Cloud Build configuration for CI/CDapi-service.yaml- Cloud Run service definition for APIworker-service.yaml- Cloud Run service definition for Celery workersmain.tf- Terraform infrastructure as codeterraform.tfvars.example- Example Terraform variablesdeploy.sh- Manual deployment scriptREADME.md- This file
Prerequisites
-
Google Cloud Project with billing enabled
-
Required APIs enabled (script will enable them):
- Cloud Build API
- Cloud Run API
- Container Registry API
- Secret Manager API
- Cloud Trace API
- Cloud Monitoring API
- Translate API
- Text-to-Speech API
- Cloud Storage API
- AI Platform API
-
Secrets created in Secret Manager:
mongodb-url- MongoDB Atlas connection stringredis-url- Redis connection string (Cloud Memorystore)jwt-secret- JWT signing secretjwt-refresh-secret- JWT refresh token secretgemini-api-key- Google Gemini API keysendgrid-api-key- SendGrid API key for emailselevenlabs-api-key- ElevenLabs API key for TTSsentry-dsn- Sentry error tracking DSN
Deployment Options
Option 1: Terraform (Recommended)
# Initialize Terraform
cd infra/cloud-run
terraform init
# Copy and configure variables
cp terraform.tfvars.example terraform.tfvars
# Edit terraform.tfvars with your project details
# Plan deployment
terraform plan
# Deploy infrastructure
terraform apply
Option 2: Manual Script
# Set environment variables
export PROJECT_ID="your-gcp-project-id"
export REGION="us-central1"
# Run deployment script
./infra/cloud-run/deploy.sh
Option 3: Cloud Build Trigger
Set up a Cloud Build trigger connected to your Git repository that uses cloudbuild.yaml for automatic deployments on code changes.
Local Development
Use the provided docker-compose.yml in the project root:
# Copy environment file
cp .env.example .env
# Edit .env with your development credentials
# Start all services
docker-compose up -d
# View logs
docker-compose logs -f api
docker-compose logs -f worker
Service Architecture
-
API Service: Handles HTTP requests, authentication, job management
- Memory: 2Gi, CPU: 2000m
- Autoscaling: 1-10 instances
- Public access via HTTPS
-
Worker Service: Processes video files with AI models
- Memory: 4Gi, CPU: 4000m
- Autoscaling: 0-5 instances
- Internal access only
Monitoring
Both services include:
- OpenTelemetry tracing exported to Cloud Trace
- Prometheus metrics for monitoring
- Sentry error tracking for error reporting
- Health checks for service reliability
Security
- Services run with least-privilege service accounts
- Secrets managed via Secret Manager
- No hardcoded credentials in containers
- Network isolation for worker service