Cloud Run Deployment
Deploy textrawl to Google Cloud Run
Deploy textrawl as a serverless container on Google Cloud Run.
Prerequisites
- Google Cloud account with billing enabled
gcloudCLI installed and authenticated- Docker installed
- Artifact Registry API enabled
Quick Deploy (Recommended)
Use the provided deployment script:
Manual Deployment
1. Set Up Artifact Registry
2. Build and Push
3. Deploy
Tip: For production, pin secrets to specific versions instead of
:latestfor stability (e.g.,textrawl-api-token:1).
Secret Manager
Store secrets in Google Secret Manager:
Grant Cloud Run Access to Secrets
Cloud Run needs permission to read each secret. First, get your project number (not project ID):
Then grant the default Compute Engine service account access to each secret:
Note: PROJECT_NUMBER is a numeric ID (e.g.,
123456789012), different from PROJECT_ID (e.g.,my-project). You can also find it in the Cloud Console under IAM & Admin > Settings.
Configuration
Cloud Run settings:
- Memory: 512MB minimum
- CPU: 1 vCPU
- Max instances: 10 (adjust for traffic)
- Min instances: 0 (scale to zero)
- Timeout: 60s
Large uploads (GCS)
Uploads above MAX_SINGLE_FILE_SIZE_MB use a resumable workflow: the browser
PUTs bytes directly to a GCS bucket (never through Cloud Run or Vercel), then
the server verifies and processes the object. Storage is selected at runtime —
set GCS_UPLOAD_BUCKET to enable GCS; leave it unset to fall back to the
in-memory fake (local dev only).
The bucket itself (creation, IAM, CORS for the dashboard origin, and the
abandoned-upload lifecycle rule) is provisioned and version-controlled under
infra/gcs/ —
see its README.md for the exact commands. Key points:
- The Cloud Run runtime service account needs
roles/storage.objectAdminon the bucket (granted via ADC — no keys). - Bucket CORS must allow the dashboard origin with methods
PUT/POST/GET/HEADand headersContent-Type, Content-Range, x-goog-*. - A lifecycle rule deletes abandoned objects after 1 day; soft-delete is disabled so deleted upload bytes are not retained/billed.
Custom Domain
Monitoring
View metrics in Cloud Console:
- Request count
- Latency
- Error rate
- Instance count