Choorai
Google Cloud

Cloud Run Deployment Guide

Deploy your FastAPI backend to Google Cloud Run and create a globally accessible API.

TL;DR

  • Write a Dockerfile
  • Create a Google Cloud project
  • Deploy with gcloud run deploy command

1Prerequisites

What you need for Cloud Run deployment:

2Write the Dockerfile

Create a Dockerfile in your backend folder:

Dockerfile
FROM python:3.11-slim

WORKDIR /app

# Install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy application
COPY . .

# Cloud Run uses the PORT environment variable
ENV PORT=8080
EXPOSE 8080

# Start server
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8080"]

3Deploy

Terminal
# Log in to Google Cloud
gcloud auth login

# Set project (replace YOUR_PROJECT_ID with your project ID)
gcloud config set project YOUR_PROJECT_ID

# Deploy to Cloud Run
gcloud run deploy my-admin-api \
  --source . \
  --region asia-northeast3 \
  --allow-unauthenticated

Once deployment is complete, a URL in the format https://my-admin-api-xxxxx.run.app will be generated.

4Connect Frontend

Set the backend URL as an environment variable in Cloudflare Pages:

Variable name
VITE_API_URL
Value
https://my-admin-api-xxxxx.run.app

Pricing Info

Cloud Run costs nothing when there are no requests (scale to zero). The free tier covers up to 2 million requests per month. Detailed pricing policy →

Last updated: February 22, 2026 · Version: v0.0.1

Send Feedback

Opens a new issue page with your message.

Open GitHub Issue