Free 40-page Claude guide — setup, 120 prompt codes, MCP servers, AI agents. Download free →
CLSkills
Cloud (AWS/GCP/Azure)intermediate

GCP Cloud Run

Share

Deploy to Google Cloud Run

Works with OpenClaude

You are a Google Cloud Platform DevOps engineer. The user wants to deploy a containerized application to Google Cloud Run using the gcloud CLI and understand the deployment workflow.

What to check first

  • Run gcloud auth list to verify you're authenticated to GCP
  • Run gcloud config get-value project to confirm the active GCP project
  • Verify Docker is installed: docker --version
  • Ensure your application has a Dockerfile in the root directory

Steps

  1. Build and tag your Docker image with the GCP Container Registry format: docker build -t gcr.io/PROJECT_ID/IMAGE_NAME:TAG .
  2. Push the image to Google Container Registry: docker push gcr.io/PROJECT_ID/IMAGE_NAME:TAG
  3. Enable the Cloud Run API: gcloud services enable run.googleapis.com
  4. Deploy to Cloud Run with gcloud run deploy SERVICE_NAME --image gcr.io/PROJECT_ID/IMAGE_NAME:TAG --region REGION --platform managed
  5. Set authentication policy with --allow-unauthenticated flag if your service should be public
  6. Configure memory and CPU with --memory (e.g., 512Mi, 1Gi) and --cpu (e.g., 1, 2) flags
  7. Set environment variables during deployment: --set-env-vars KEY=VALUE,KEY2=VALUE2
  8. After deployment completes, the output will show your service URL—test it with curl https://SERVICE_URL

Code

#!/bin/bash

# Configuration
PROJECT_ID="your-gcp-project"
IMAGE_NAME="my-app"
SERVICE_NAME="my-app-service"
REGION="us-central1"
TAG="latest"

# Set active project
gcloud config set project $PROJECT_ID

# Build Docker image with GCR naming convention
echo "Building Docker image..."
docker build -t gcr.io/$PROJECT_ID/$IMAGE_NAME:$TAG .

# Push to Google Container Registry
echo "Pushing image to GCR..."
docker push gcr.io/$PROJECT_ID/$IMAGE_NAME:$TAG

# Enable Cloud Run API if not already enabled
gcloud services enable run.googleapis.com

# Deploy to Cloud Run
echo "Deploying to Cloud Run..."
gcloud run deploy $SERVICE_NAME \
  --image gcr.io/$PROJECT_ID/$IMAGE_NAME:$TAG \
  --region $REGION \
  --platform managed \
  --allow-unauthenticated \
  --memory 512Mi \
  --cpu 1 \
  --timeout 3600 \
  --set-env-vars PORT=8080,NODE_ENV=production \
  --max-instances 100 \
  --min-instances 1

# Retrieve the service URL
SERVICE_URL=$(gcloud run services describe $SERVICE_NAME \
  --region $REGION \
  --format 'value(status.url

Note: this example was truncated in the source. See the GitHub repo for the latest full version.

Common Pitfalls

  • Treating this skill as a one-shot solution — most workflows need iteration and verification
  • Skipping the verification steps — you don't know it worked until you measure
  • Applying this skill without understanding the underlying problem — read the related docs first

When NOT to Use This Skill

  • When a simpler manual approach would take less than 10 minutes
  • On critical production systems without testing in staging first
  • When you don't have permission or authorization to make these changes

How to Verify It Worked

  • Run the verification steps documented above
  • Compare the output against your expected baseline
  • Check logs for any warnings or errors — silent failures are the worst kind

Production Considerations

  • Test in staging before deploying to production
  • Have a rollback plan — every change should be reversible
  • Monitor the affected systems for at least 24 hours after the change

Quick Info

Difficultyintermediate
Version1.0.0
AuthorClaude Skills Hub
cloudgcpcloud-run

Install command:

curl -o ~/.claude/skills/gcp-cloud-run.md https://claude-skills-hub.vercel.app/skills/cloud/gcp-cloud-run.md

Related Cloud (AWS/GCP/Azure) Skills

Other Claude Code skills in the same category — free to download.

Want a Cloud (AWS/GCP/Azure) skill personalized to YOUR project?

This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.