Pagebee Academy
Step 9 of 17

Part 3, Launch · Step 9

Deploy to Cloud Run and Cloud SQL, on your own domain

Your app runs on Cloud Run, your data lives in a Cloud SQL Postgres database, and your domain points at both with HTTPS. Your agent does most of the typing.

Time
An afternoon
Cost
About $12 a month for the database; the app is usually free at launch

Pagebee Builder, a free Mac app, hands this step to your agent: plan it, build it on a branch, or ship it.Get Pagebee Builder

Why it matters

This is the step the app builders hide from you, and the reason they can charge what they like later. It's also less work than it sounds: three commands, which your agent will run.

Cloud Run builds your code into a container and runs it. When nobody's visiting, it scales to zero and costs nothing. Each month the first 2 million requests and a generous amount of compute are free, so a new product usually pays nothing for its app at all.

Cloud SQL is Postgres, managed by Google: backups, updates and a machine that doesn't go away. The smallest machine, db-f1-micro, costs about $12 a month. That will be your biggest bill for a while, and it's a fair one.

Your app and your database talk privately, and your passwords live in Secret Manager, never in the code.

Do this

  1. 1

    Pick one region for everything and stick to it. europe-west1 (Belgium) or us-central1 (Iowa) are both cheap and both support custom domains on Cloud Run.

  2. 2

    Create the database. In the console, choose SQL, Create instance, PostgreSQL, and switch the edition to Enterprise (not Enterprise Plus, which is the default and costs far more). Or let your agent do it with this command:

    Terminal
    gcloud sql instances create tally-db \
      --database-version=POSTGRES_18 --edition=enterprise \
      --tier=db-f1-micro --region=europe-west1 \
      --backup-start-time=02:00 --deletion-protection
  3. 3

    Paste the prompt below. It creates the database user, stores the connection string in Secret Manager, and deploys.

  4. 4

    The deploy it runs looks like this. --max-instances 3 is your real spending cap: Cloud Run will never run more than three copies, however much traffic arrives.

    Terminal
    gcloud run deploy tally --source . --region=europe-west1 \
      --allow-unauthenticated --max-instances=3 \
      --add-cloudsql-instances=PROJECT_ID:europe-west1:tally-db \
      --set-secrets=DATABASE_URL=database-url:1
  5. 5

    Open the run.app address it prints and check the app works. Then prove you own the domain to Google (it opens Search Console; Cloudflare can add the record for you):

    Terminal
    gcloud domains verify tally.app
  6. 6

    Map your domain to the service, then ask Google which DNS records it wants:

    Terminal
    gcloud beta run domain-mappings create --service=tally --domain=tally.app --region=europe-west1
    gcloud beta run domain-mappings describe --domain=tally.app --region=europe-west1
  7. 7

    Add those records in Cloudflare (your agent can, through the Cloudflare MCP) and set each one to DNS only, the grey cloud. Google issues the HTTPS certificate within about 15 minutes, sometimes up to a day.

Paste into Claude Code

Deploy this app to Google Cloud in europe-west1. The Cloud SQL instance tally-db exists. Create a database and a user with a strong generated password, store the full DATABASE_URL (using the /cloudsql unix socket) in Secret Manager as database-url, give the Cloud Run service account the Cloud SQL Client and Secret Manager Secret Accessor roles, and deploy with gcloud run deploy --source, --max-instances=3 and the secret mounted. Run the database migrations. Explain each command before you run it. Then write a short docs/deploy.md that records exactly how to deploy again, and commit it.

Once this works, ask your agent to make every push to main deploy automatically with a Cloud Build trigger. Then deploying is just pushing.

When to move off domain mapping

Cloud Run's domain mapping is still labelled Preview by Google. It's fine for launching and for a long while after. When you need the extra speed, or more than one service on one domain, Google's recommended route is a global load balancer in front of Cloud Run. Ask your agent to set one up when that day comes; your app doesn't change.

Using something else

Fly.io, Railway and Render all run containers with a Postgres database next to them, with fewer steps. AWS (App Runner and RDS) is the same shape as this step. What matters is that your app is a container and your database is plain Postgres, so you can move either one.