Sign In
Deploy

Deploying to Google Cloud Run

Run your backend on Cloud Run with a lightweight container image and one command deploy.

Guide

Prerequisites

  • Google Cloud project with Cloud Run and Artifact Registry enabled
  • gcloud CLI authenticated (gcloud auth login) and project set (gcloud config set project YOUR_PROJECT)
  • Artifact Registry repository or Container Registry enabled
  • Your backend application repository

Generate Environment Variables

Navigate to Rivet and click Connect > Manual. Copy the environment variables provided, they will be used when deploying. They should look something like this:

RIVET_API_ENDPOINT=https://api-us-west-1.rivet.dev
RIVET_NAMESPACE=your-namespace-id
RIVET_TOKEN=your-token
Command Line

Package Your App

Create a Dockerfile in your project root:

FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
COPY . .
ENV PORT=8080
CMD ["node", "server.js"]
Dockerfile

Build and Push the Image

Use Cloud Build to build and push the image. Replace the region and repository with your own.

gcloud builds submit --tag us-central1-docker.pkg.dev/YOUR_PROJECT/backend/backend:latest
Command Line

Deploy to Cloud Run

Deploy the service to Cloud Run, passing the Rivet environment variables. Adjust the region, image, and VPC connector settings as needed.

gcloud run deploy backend \
  --image us-central1-docker.pkg.dev/YOUR_PROJECT/backend/backend:latest \
  --region us-central1 \
  --allow-unauthenticated \
  --min-instances 1 \
  --set-env-vars RIVET_API_ENDPOINT=https://api-us-west-1.rivet.dev,RIVET_NAMESPACE=your-namespace-id,RIVET_TOKEN=your-token
Command Line
You do not need to expose a container port. Rivet tunnels traffic directly to your backend.

Verify the Runner

Confirm the service is running:

gcloud run services describe backend --region us-central1 --format 'value(status.conditions[?type="Ready"].status)'
Command Line

Your runner should appear as connected on the Rivet dashboard once the service reports ready.

Suggest changes to this page