mcpField
G
gcp-deploy

gcp-deploy

github.com/fwfuturesCloud & DevOps060 installsUpdated 7w ago
Repository

About gcp-deploy

gcp-deploy is a deployment skill for developers who want to publish a Dockerfile-based application on Google Cloud Run. It covers the build, Artifact Registry push, deployment, and configuration through gcloud commands or a reusable script.

Key features

  1. 01Deploy source to Cloud Run
  2. 02Build with Cloud Build
  3. 03Push images to Artifact Registry
  4. 04Configure resources and environment
  5. 05Tail logs and inspect services

Use cases

  1. 01Deploy a containerized application
  2. 02Set environment variables or secrets
  3. 03Adjust region, port, memory, or scaling
  4. 04Troubleshoot builds and service startup

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/fwfutures/skills --skill gcp-deploy

After installing, type/gcp-deployin Claude Code to confirm it loaded.

Bundled filesscripts/deploy.sh

Details

From the project README

GCP Cloud Run Deploy

Deploy from source to Cloud Run in a single command. Requires: a GCP project, a Dockerfile in the repo root, and an app that listens on a port (default 8080 / PORT env var).

Quick Deploy

# 1. Auth (skip if already logged in)
gcloud auth login
gcloud config set project PROJECT_ID

# 2. Enable APIs (first time only)
gcloud services enable run.googleapis.com cloudbuild.googleapis.com artifactregistry.googleapis.com

# 3. Deploy
gcloud run deploy SERVICE_NAME \
  --source . \
  --region australia-southeast1 \
  --allow-unauthenticated

This builds the container remotely via Cloud Build, pushes to Artifact Registry, deploys to Cloud Run, and returns a public HTTPS URL. Redeploy by re-running the same command.

Deploy Script

Copy scripts/deploy.sh into the project root for one-command deploys:

chmod +x deploy.sh
./deploy.sh my-service

Env vars: GCP_REGION (default australia-southeast1), GCP_PROJECT (default: current gcloud project).

Common Flags

FlagPurposeExample
--regionDeployment regionaustralia-southeast1
--allow-unauthenticatedPublic access
--portContainer port (if not 8080)--port 3000
--set-env-varsEnv vars--set-env-vars KEY=val,FOO=bar
--set-secretsSecret Manager secrets--set-secrets ENV=SECRET:latest
--memoryMemory--memory 512Mi
--cpuCPU--cpu 1
--min-instancesMin instances (0 = scale to zero)--min-instances 0
--max-instancesMax instances--max-instances 3
--timeoutRequest timeout (max 3600)--timeout 300

Environment Variables and Secrets

Inline env vars:

gcloud run deploy SERVICE --source . --region REGION --allow-unauthenticated \
  --set-env-vars "DATABASE_URL=postgres://...,API_KEY=abc123"

Secret Manager (recommended for sensitive values):

# Create secret
echo -n "secret-value" | gcloud secrets create MY_SECRET --data-file=-

# Grant access to default compute SA
gcloud secrets add-iam-policy-binding MY_SECRET \
  --member="serviceAccount:$(gcloud iam service-accounts list --format='value(email)' --filter='displayName:Compute Engine default')" \
  --role="roles/secretmanager.secretAccessor"

# Deploy with secret
gcloud run deploy SERVICE --source . --region REGION --allow-unauthenticated \
  --set-secrets "MY_SECRET=MY_SECRET:latest"

Useful Commands

# Stream logs
gcloud run services logs tail SERVICE --region REGION

# List services
gcloud run services list --region REGION

# Get service URL
gcloud run services describe SERVICE --region REGION --format "value(status.url)"

# Delete service
gcloud run services delete SERVICE --region REGION

CI/Headless Auth

gcloud auth activate-service-account --key-file=key.json
gcloud config set project PROJECT_ID

Troubleshooting

IssueFix
Build failsCheck Dockerfile locally: docker build .
403 on deployNeed roles/run.admin and roles/cloudbuild.builds.editor
App crashes on startCheck logs: gcloud run services logs tail SERVICE --region REGION
Port mismatchSet --port to match app, or have app read PORT env var
Cold start slowSet --min-instances 1 (stays warm, costs more)
Timeout on long requestsIncrease with --timeout 300 (max 3600s)

Comments

Markdown supported