- New services/cost_tracker.py: sync httpx preflight()/record() + async wrappers; BudgetExceeded exception; no-op when COST_TRACKER_BASE_URL is empty - Preflight budget check added before ingestion (Gemini), per-language translation (video-native + traditional), and per-language TTS dispatch - _record_gemini_usage and _record_tts_cost now call cost_tracker directly; removes broken asyncio.get_event_loop() hack from sync Celery worker - Fix: _cost_ctx now threaded into extract_accessibility_targeted (video-native path) - Fix: user_id/cost_project_id now propagated through dispatch_language_tts → synthesize_cue_task.s() and the rerender_accessible_video.py re-render path - Remove oliver-cost-tracker SDK dependency (was commented-out/never installed) - Drop cost_tracker_outbox_path setting and get_cost_tracker() factory - Update COST_TRACKER_BASE_URL default to optical-dev.oliver.solutions in .env.prod.example, docker-compose.yml, and all Cloud Run service yamls - Cloud Run yamls use Secret Manager ref (cost-tracker-api-key) for the API key Co-Authored-By: Claude Sonnet 4.6 <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