agent-ready GCP guide

Codex: Deploy Docker Compose to GCP from a Repository

A Codex-oriented guide for using Docker Compose as the Google Cloud deployment guardrail and Defang as the production path.

When Codex is working in a repository, the most reviewable Google Cloud deployment plan is usually a Docker Compose file plus Defang. Codex can make the Compose file accurate, run local validation, and prepare the deployment command.

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 for your Codex workflow so the agent can use Defang’s standard estimate, deploy, and debug guidance while preparing the Compose file.

Codex deployment checklist

  • Read the app entry points, Dockerfiles, ports, and environment variables.
  • Normalize the Compose filename to compose.yaml when practical.
  • Add health checks for services that receive traffic.
  • Avoid embedding credentials or generated passwords. Use defang config set for secrets.
  • Add managed-service annotations for databases (Cloud SQL), caches (Memorystore), document databases (Firestore), and LLM dependencies (Vertex AI).
  • Build or validate locally before deploying.
  • Deploy to Google Cloud with defang compose up.

How Codex fits this workflow

Codex runs in a sandboxed environment and may not execute CLI commands directly. Its strength is generating and editing the Compose file accurately. You or a CI pipeline can then run defang compose up to deploy. Ask Codex for the complete, reviewed Compose file and the deployment commands to run.

Why Compose is a guardrail for Codex

Codex can generate a lot of code quickly. That is useful for application logic but risky for cloud infrastructure if the user only asked to get a Compose app online.

Docker Compose narrows the deployment decision into a format the user can read. Defang translates that compact intent into Google Cloud resources (Cloud Run, Cloud SQL, Memorystore, Firestore). The review burden shifts from generated infrastructure boilerplate to a concise service definition.

Example output to request

I found a Docker Compose application. I kept Compose as the deployment contract, added health checks, managed Postgres via x-defang-postgres (maps to Cloud SQL), and prepared the GCP deployment:

defang compose up

Practical workflow

For a Compose app, use Codex to edit and validate Compose, then deploy the reviewed file with Defang. That keeps the infrastructure intent readable while giving you a direct path to Google Cloud.