Cloud Run runs a container for you: it scales from zero to many instances, gives you an HTTPS endpoint, and charges only while requests are in flight. There are no clusters or servers to manage. Here is the whole path from code to a live URL.
Step 1: Containerize the App
Cloud Run runs any container that listens on the port given by the PORT environment variable. A minimal web app:
FROM node:20-slim WORKDIR /app COPY package*.json ./ RUN npm ci --omit=dev COPY . . # Cloud Run injects PORT โ listen on it CMD ["node", "server.js"]
Make sure your server reads process.env.PORT, not a hardcoded port.
Step 2: Deploy Straight from Source
You don't even need to build the image yourself โ Cloud Run can build from source with Cloud Build:
gcloud run deploy my-api \ --source . \ --region us-central1 \ --allow-unauthenticated
That single command builds the container, pushes it to Artifact Registry, and deploys it. In a minute or two you get an HTTPS URL.
Step 3: Tune Scaling and Resources
Cloud Run scales to zero by default (no cost when idle) and up automatically under load. Set sensible bounds and per-instance resources:
gcloud run services update my-api \ --min-instances 0 \ --max-instances 20 \ --memory 512Mi \ --concurrency 80 # requests served per instance
Set --min-instances 1 if you want to avoid cold starts on a low-traffic service.
Step 4: Wire Up Secrets and Env
Don't bake secrets into the image. Reference Secret Manager and set config as environment variables:
gcloud run services update my-api \ --set-env-vars "LOG_LEVEL=info" \ --set-secrets "API_KEY=my-api-key:latest"
Summary
Cloud Run turns a container into a scalable HTTPS service without any infrastructure to run. Containerize your app so it listens on PORT, deploy straight from source with one gcloud run deploy, tune scaling and resources to your traffic, and pull secrets from Secret Manager. Ten minutes from Dockerfile to a production-grade URL โ and it scales to zero when nobody's using it.