Cloud · · 3 min read

Serverless Deployment: Host Your Website on Google Cloud Run

Step-by-step guide to deploying your website to Google Cloud Run using Docker, Artifact Registry, and Cloud Build — with zero downtime.

Host Your Website on Google Cloud Run
Photo by Tanner Boriack / Unsplash

TL;DR: Learn how to take your own Node.js app (like this one) and deploy it to Google Cloud Run using Docker, Cloud Build, and Artifact Registry — fully managed, zero maintenance, and highly scalable.

Why Cloud Run?

Deploying applications typically requires setting up virtual machines or managing Kubernetes clusters. While this works for complex infrastructures, it introduces overhead for simple web apps.

Cloud Run solves this by allowing you to:

It's ideal for small services, APIs, microservices, and experiments.

What You’ll Do

In this hands-on guide, you will:

Step 1: Activate Cloud Shell and Set Region/Zone

Activate Cloud Shell

Cloud Shell is a VM provided by Google Cloud with the gcloud CLI, Docker, and other dev tools pre-installed. It comes with a 5GB persistent home directory and is ready to go.

  1. Go to Google Cloud Console
  2. Click the Activate Cloud Shell icon (top-right corner)
  3. Continue through the setup prompts
  4. Click Authorize when asked

Once ready, you'll see a message like:

Your Cloud Platform project in this session is set to "PROJECT_ID"

To confirm settings:

gcloud auth list
gcloud config list project

Set Region and Zone

Some resources (e.g., VMs, Artifact Registry) are regional. Set your default region and zone:

gcloud config set compute/zone "us-central1-a"
export ZONE=$(gcloud config get-value compute/zone)

gcloud config set compute/region "us-central1"
export REGION=$(gcloud config get-value compute/region)

Step 2: Clone the GitHub Repository

We’ll use a minimal Node.js app hosted at https://github.com/niiiixd/sampla-app.

Clone the repo:

git clone https://github.com/niiiixd/sampla-app.git
cd sampla-app

This app uses Express to serve a simple homepage message from app.js.

Step 3: Build the Docker Image with Cloud Build

Enable Required Services

gcloud services enable artifactregistry.googleapis.com \
    cloudbuild.googleapis.com \
    run.googleapis.com

Create a Docker Repository in Artifact Registry

gcloud artifacts repositories create sample-app-repo \
  --repository-format=docker \
  --location=$REGION \
  --description="Docker repo for sample Node app"

Configure Docker Authentication

gcloud auth configure-docker $REGION-docker.pkg.dev

Build and Push Docker Image

gcloud builds submit --tag $REGION-docker.pkg.dev/$PROJECT_ID/sample-app-repo/sample-app:1.0.0

This command builds your Docker image and pushes it directly to your private Docker repository.

Step 4: Deploy to Cloud Run

Use the following command to deploy your app:

gcloud run deploy sample-app \
  --image $REGION-docker.pkg.dev/$PROJECT_ID/sample-app-repo/sample-app:1.0.0 \
  --platform managed \
  --region $REGION \
  --allow-unauthenticated

Once deployed, the terminal will return a live URL like:

https://sample-app-xyz-uc.a.run.app

Open the URL in your browser. You should see:

Hello, world! This is Sample app version 3🚀

Step 5: Modify & Redeploy (Zero Downtime)

Let's simulate an update to your app (e.g., a marketing text change).

Update the Message in app.js

sed -i 's/This is Sample app version 3🚀/This is Sample app version 4🔥/' app.js

This command updates the welcome message inside your Express app.

Rebuild and Push the Updated Image

gcloud builds submit --tag $REGION-docker.pkg.dev/$PROJECT_ID/sample-app-repo/sample-app:2.0.0

Redeploy to Cloud Run

gcloud run deploy sample-app \
  --image $REGION-docker.pkg.dev/$PROJECT_ID/sample-app-repo/sample-app:2.0.0 \
  --platform managed \
  --region $REGION \
  --allow-unauthenticated

Cloud Run will automatically create a new revision and switch traffic to it with zero downtime.

Refresh your app’s URL — your updated message should now appear:

Hello, world! This is Sample app version 4🔥

Optional: Adjust Concurrency

To simulate function-like concurrency limits, you can set it to 1:

gcloud run deploy sample-app \
  --image $REGION-docker.pkg.dev/$PROJECT_ID/sample-app-repo/sample-app:2.0.0 \
  --platform managed \
  --region $REGION \
  --concurrency 1 \
  --allow-unauthenticated

This limits each container to handling 1 request at a time. You can later restore it by setting:

--concurrency 80

Learn More

Final Thoughts

In this guide, you:

This workflow scales beautifully from MVPs to microservices and production workloads.


Stay Connected

Want more tutorials on DevOps, cloud, and serverless technologies? Subscribe to the blog for hands-on walkthroughs, cheat sheets, and more!

Read next