gcp-cloud-run
БесплатноБез исполняемых скриптовНе проверенDeploy serverless containers on Google Cloud Run — services for HTTP traffic, jobs for batch and scheduled tasks, and worker pools for always-on pull-based…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
GCP Cloud Run
Overview
Google Cloud Run is a fully managed serverless platform for running containers. It automatically scales from zero to thousands of instances, charges only for actual usage, and supports any language or binary that can run in a container.
Instructions
Core Concepts
- Service — a long-running container that auto-scales based on HTTP traffic
- Revision — an immutable snapshot of a service's configuration and code
- Traffic splitting — route percentages of traffic to different revisions
- Job — run a container to completion (batch, cron, one-off tasks)
- Worker pool — always-on container for pull-based background work (Pub/Sub pull, Kafka consumer, RabbitMQ)
- Concurrency — max simultaneous requests per container instance
CRITICAL: Code MUST listen on
0.0.0.0(not127.0.0.1) and use the injected$PORTenv var (defaults to8080), or the container will crash on boot.
Deploying a Service
# Deploy from source code (Cloud Build + Cloud Run)
gcloud run deploy web-app \
--source . \
--region us-central1 \
--allow-unauthenticated \
--port 8080 \
--memory 512Mi \
--cpu 1 \
--min-instances 0 \
--max-instances 100 \
--concurrency 80 \
--set-env-vars "NODE_ENV=production,LOG_LEVEL=info"
# Deploy from a pre-built container image
gcloud run deploy web-app \
--image us-central1-docker.pkg.dev/my-project/repo/web-app:v1.2.0 \
--region us-central1 \
--allow-unauthenticated \
--port 8080 \
--memory 1Gi \
--cpu 2 \
--timeout 300 \
--set-secrets "DATABASE_URL=db-url:latest,API_KEY=api-key:latest"
Building and Pushing Images
# Build with Cloud Build and push to Artifact Registry
gcloud builds submit \
--tag us-central1-docker.pkg.dev/my-project/repo/web-app:v1.2.0
# Dockerfile — optimized multi-stage build for Cloud Run
FROM node:24-slim AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM node:24-slim
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
COPY package*.json ./
ENV PORT=8080
EXPOSE 8080
CMD ["node", "dist/server.js"]
Traffic Splitting
# Deploy a new revision without sending traffic
gcloud run deploy web-app \
--image us-central1-docker.pkg.dev/my-project/repo/web-app:v1.3.0 \
--region us-central1 \
--no-traffic
# Split traffic: 90% to current, 10% to new revision (canary)
gcloud run services update-traffic web-app \
--region us-central1 \
--to-revisions web-app-00002=10,web-app-00001=90
# Promote canary to 100%
gcloud run services update-traffic web-app \
--region us-central1 \
--to-latest
# Rollback by routing all traffic to a previous revision
gcloud run services update-traffic web-app \
--region us-central1 \
--to-revisions web-app-00001=100
Cloud Run Jobs
# Create a batch job
gcloud run jobs create data-export \
--image us-central1-docker.pkg.dev/my-project/repo/data-export:latest \
--region us-central1 \
--memory 2Gi \
--cpu 2 \
--task-timeout 3600 \
--max-retries 3 \
--set-env-vars "EXPORT_FORMAT=csv"
# Execute the job
gcloud run jobs execute data-export --region us-central1
# Schedule a job with Cloud Scheduler
gcloud scheduler jobs create http data-export-daily \
--location us-central1 \
--schedule "0 2 * * *" \
--uri "https://run.googleapis.com/v2/projects/my-project/locations/us-central1/jobs/data-export:run" \
--http-method POST \
--oauth-service-account-email [email protected]
The scheduler's service account needs roles/run.invoker on the job. Use --oauth-service-account-email here (the Admin API is a Google API); --oidc-* flags are for calling a Cloud Run service URL.
Worker Pools (Pull-Based Workloads)
Worker pools handle long-running background work that pulls from a queue — Pub/Sub pull subscriptions, Kafka consumers, RabbitMQ. Unlike services, they have no HTTP endpoint and are not driven by request traffic. They do not autoscale on their own: you set a fixed instance count with --instances (manual scaling), and every requested instance is billed as active even when idle. --instances 0 disables the pool. To scale on queue depth, drive the count from an external system (Google documents autoscaling with external metrics and Pub/Sub pull).
# Deploy a Pub/Sub worker pool
gcloud run worker-pools deploy events-consumer \
--image us-central1-docker.pkg.dev/my-project/repo/consumer:v1.0.0 \
--region us-central1 \
--memory 1Gi --cpu 1 \
--instances 3 \
--set-env-vars "SUBSCRIPTION=projects/my-project/subscriptions/events-pull"
# Deploy from source (Cloud Build)
gcloud run worker-pools deploy events-consumer \
--source . --region us-central1
Use worker pools instead of:
- Services when there's no HTTP traffic to sc
Установить gcp-cloud-run в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл gcp-cloud-run?
Deploy serverless containers on Google Cloud Run — services for HTTP traffic, jobs for batch and scheduled tasks, and worker pools for always-on pull-based background processing. Build and push container images, configure auto-scaling from zero, split traffic for canary deploys, and set up custom domains with managed TLS.
Как установить скилл gcp-cloud-run?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл gcp-cloud-run запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
ci-review
The scan that the plugin's GitHub Action runs.
от Anthropicazure-static-web-apps
Helps create, configure, and deploy Azure Static Web Apps using the SWA CLI. Use when deploying static sites to Azure, setting up SWA local development…
от GitHubai-ready
Make any repo AI-ready — analyzes your codebase and generates AGENTS.md, copilot-instructions.md, CI workflows, issue templates, and more. Mines your PR…
от GitHubaws-cdk-python-setup
Setup and initialization guide for developing AWS CDK (Cloud Development Kit) applications in Python. This skill enables users to configure environment…
от GitHub