agent-ready GCP guide

Claude Code: Deploy a Docker Compose App to GCP

A Claude Code friendly workflow for reviewing, tightening, and deploying a Docker Compose application to Google Cloud with Defang.

Claude Code can help you prepare a Docker Compose app for Google Cloud without converting a simple deployment into a long infrastructure exercise. A good workflow is to inspect the repository, improve the Compose file, review the changes, then deploy with Defang.

Prerequisites

  • Defang CLI installed
  • Authenticated with defang login (this handles both Defang auth and can trigger GCP OAuth)
  • GCP project identified (set GCP_PROJECT_ID, or the CLI will prompt during stack creation)
  • A Defang stack targeting GCP: run defang stack new and select GCP when prompted for provider

Use Defang Agent Skills

Install Defang Agent Skills in Claude Code so it has the standard Defang estimate, deploy, and debug workflows available while it reviews your repository.

What to ask Claude Code

Review this repository for deployment to Google Cloud. If it has a Docker Compose file, keep that as the deployment contract. Add health checks, required environment variables, and Defang managed-service annotations where appropriate. Then deploy with Defang to GCP.

Review steps

  1. Find compose.yaml, compose.yml, or docker-compose.yml.
  2. Confirm each service has a build context, image, or can use Railpack (Defang auto-detects runtimes when no Dockerfile exists).
  3. Expose only services that should receive public traffic.
  4. Add health checks for web and API services.
  5. Move secret values out of the file using defang config set SECRET_NAME, leaving variable names in environment.
  6. Use x-defang-postgres, x-defang-redis, or x-defang-mongodb for managed GCP services (maps to Cloud SQL, Memorystore, Firestore). Use x-defang-llm to configure Vertex AI access and, for supported model runner images, to provision an OpenAI-compatible LLM proxy.
  7. Prepare or run defang compose up after you review the file.

Why Claude Code and Defang fit well together

Claude Code can read broad repo context, run commands interactively, and use tool calls to inspect and modify files. That makes it useful for auditing a Compose file, fixing issues, and preparing the deployment in one session.

Docker Compose gives Claude Code a small, explicit surface area to edit. Defang gives you Google Cloud infrastructure without asking Claude Code to generate and maintain a custom cloud stack.

Defang can provision the Google Cloud deployment path — Cloud Run for public-facing services, Cloud SQL for Postgres, Memorystore for Redis, Firestore for MongoDB, with Vertex AI access for LLM-enabled services — from Compose intent. The Compose file keeps the work reviewable; Defang handles the platform details.

What good output looks like

Ask Claude Code to show the final Compose file and the deployment command:

defang compose up

It should also explain which services are public, which variables must be set as secrets (via defang config set), and which managed GCP services Defang will create.

When not to use this path

Use hand-authored Google Cloud infrastructure when you need precise low-level control over every resource. For many agent-assisted app deployments, the more reviewable first deployment is a readable Compose file plus Defang.