Google Cloud Run
Run Rivet workers on Google Cloud Run.
Cloud Run is request-driven, so workers run in serverless mode: the control plane calls your /api/rivet endpoint to start actors, and the service URL has to be public and registered.
Requirements
- A Google Cloud project with Cloud Run and Artifact Registry enabled
gcloudauthenticated (gcloud auth login) with the project set- A control plane, either Rivet Cloud or your own
Steps
Package your app
FROM node:24-slim
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
COPY . .
ENV RIVET_PORT=8080
CMD ["node", "server.js"]
RIVET_PORT is the port RivetKit’s listener binds. Cloud Run routes to 8080 by default, and RivetKit does not read Cloud Run’s PORT variable.
Build and push
gcloud builds submit --tag us-central1-docker.pkg.dev/YOUR_PROJECT/rivet-worker/rivet-worker:latest
Deploy
RIVETKIT_RUNTIME_MODE=serverless is required. Without it the app defaults to runner mode, which does not fit Cloud Run’s request-driven model.
gcloud run deploy rivet-worker \
--image us-central1-docker.pkg.dev/YOUR_PROJECT/rivet-worker/rivet-worker:latest \
--region us-central1 \
--allow-unauthenticated \
--min-instances 1 \
--set-env-vars RIVET_ENDPOINT=<your-rivet-endpoint>,RIVET_PUBLIC_ENDPOINT=<your-rivet-public-endpoint>,RIVETKIT_RUNTIME_MODE=serverless
Both endpoint values are described in Workers.
Register the URL
Take the service URL from the deploy output, append /api/rivet, and set it as the serverless runner URL in the dashboard:
https://rivet-worker-xxxxx-uc.a.run.app/api/rivet
Verify
gcloud run services describe rivet-worker --region us-central1 \
--format 'value(status.conditions[?type="Ready"].status)'
Expect True. The service then appears as connected in the dashboard.
Scaling and timeouts
Three Cloud Run settings interact with how many actors you can host:
--concurrencycaps in-flight requests per instance, and each in-flight/api/rivet/starthosts one actor. It is therefore your actors-per-instance limit. Size it from per-actor memory and CPU; Cloud Run scales out more instances once instances hit the cap.--max-instancescaps how far Cloud Run scales out. Together with--concurrencyit bounds the whole service atconcurrency × max-instancesactors. The deploy command above sets--min-instances 1, which is only the floor, so set the ceiling deliberately rather than inheriting the default.--timeoutcaps request duration at 60 minutes. SetrequestLifespanjust under it, around840for a 15-minute timeout, so actors migrate on your schedule rather than being cut off. LowerdrainGracePeriodto match: it defaults to1800and must be strictly less thanrequestLifespan. See the production checklist.
Actor start requests all originate from your control plane’s IPs, so any per-IP rate limit throttles the control plane long before real user traffic.