Deploy to Google Cloud Run
✓Works with OpenClaudeYou 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 listto verify you're authenticated to GCP - Run
gcloud config get-value projectto confirm the active GCP project - Verify Docker is installed:
docker --version - Ensure your application has a
Dockerfilein the root directory
Steps
- Build and tag your Docker image with the GCP Container Registry format:
docker build -t gcr.io/PROJECT_ID/IMAGE_NAME:TAG . - Push the image to Google Container Registry:
docker push gcr.io/PROJECT_ID/IMAGE_NAME:TAG - Enable the Cloud Run API:
gcloud services enable run.googleapis.com - Deploy to Cloud Run with
gcloud run deploy SERVICE_NAME --image gcr.io/PROJECT_ID/IMAGE_NAME:TAG --region REGION --platform managed - Set authentication policy with
--allow-unauthenticatedflag if your service should be public - Configure memory and CPU with
--memory(e.g.,512Mi,1Gi) and--cpu(e.g.,1,2) flags - Set environment variables during deployment:
--set-env-vars KEY=VALUE,KEY2=VALUE2 - 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
Related Cloud (AWS/GCP/Azure) Skills
Other Claude Code skills in the same category — free to download.
Lambda Function
Create AWS Lambda function with handler
S3 Operations
Set up S3 bucket operations (upload, download, presigned URLs)
DynamoDB CRUD
Create DynamoDB CRUD operations
SQS Setup
Set up SQS queue producer and consumer
SNS Notifications
Configure SNS for push notifications
CloudFront Setup
Set up CloudFront CDN distribution
Cognito Auth
Implement AWS Cognito authentication
RDS Setup
Configure RDS database connection
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.