checkoutOs
Guides

Deployment

Deploying checkoutOs and this documentation site to Google Cloud Run, and mapping checkoutos.in.

Two services, one project:

ServiceServesDomain
checkoutos-webThis site — landing page and docscheckoutos.in, www.checkoutos.in
checkoutos-apiThe payment APIapi.checkoutos.in

Both scale to zero, so there is nothing running between requests.

Prerequisites

gcloud auth login
gcloud config set project YOUR_PROJECT_ID

gcloud services enable \
  run.googleapis.com \
  cloudbuild.googleapis.com \
  artifactregistry.googleapis.com \
  secretmanager.googleapis.com

Create an Artifact Registry repository once:

gcloud artifacts repositories create checkoutos \
  --repository-format=docker \
  --location=asia-south1 \
  --description="checkoutOs images"

asia-south1 (Mumbai) keeps latency low for Indian rails and users.

Deploying the website

The site builds to a Next.js standalone server, which Cloud Run runs directly.

gcloud run deploy checkoutos-web \
  --source . \
  --region asia-south1 \
  --allow-unauthenticated \
  --port 8080 \
  --cpu 1 \
  --memory 512Mi \
  --min-instances 0 \
  --max-instances 10

--source . hands the directory to Cloud Build, which uses the Dockerfile in the repo root. There is no separate build step to run first.

Why PORT 8080

Cloud Run injects PORT and expects the container to listen on it. The Dockerfile sets PORT=8080 and HOSTNAME=0.0.0.0 — binding to localhost instead would make the container unreachable and the revision would fail health checks.

Deploying the API

The API needs Redis and secrets, so it gets a little more configuration.

Store the credentials as secrets

Never pass gateway credentials as plain environment variables.

printf 'rzp_live_xxxxxxxxxxxx' | \
  gcloud secrets create razorpay-key-id --data-file=-

printf 'xxxxxxxxxxxxxxxxxxxxxxxx' | \
  gcloud secrets create razorpay-key-secret --data-file=-

printf 'xxxxxxxxxxxxxxxx' | \
  gcloud secrets create razorpay-webhook-secret --data-file=-

Provision Redis

Memorystore lives in a VPC, so Cloud Run reaches it through a connector:

gcloud redis instances create checkoutos-redis \
  --size=1 --region=asia-south1 --redis-version=redis_7_0

gcloud compute networks vpc-access connectors create checkoutos-connector \
  --region=asia-south1 --range=10.8.0.0/28

A managed provider such as Upstash over TLS also works and skips the connector entirely — reasonable for a prototype.

Deploy

gcloud run deploy checkoutos-api \
  --source . \
  --region asia-south1 \
  --allow-unauthenticated \
  --port 3000 \
  --vpc-connector checkoutos-connector \
  --set-env-vars NODE_ENV=production \
  --set-env-vars ACTIVE_GATEWAY=razorpay \
  --set-env-vars BASE_URL=https://api.checkoutos.in \
  --set-env-vars REDIS_URL=redis://10.0.0.3:6379 \
  --set-env-vars WEBHOOK_RELAY_URL=https://your-app.example.com/webhook \
  --set-secrets RAZORPAY_KEY_ID=razorpay-key-id:latest \
  --set-secrets RAZORPAY_KEY_SECRET=razorpay-key-secret:latest \
  --set-secrets RAZORPAY_WEBHOOK_SECRET=razorpay-webhook-secret:latest

Set BASE_URL explicitly

It is the one variable Zod does not validate, and it defaults to http://localhost:3000. Forget it in production and every paymentUrl you hand a customer points at localhost — with no startup error to warn you. See Configuration.

Mapping checkoutos.in

Verify the domain, then map it:

gcloud domains verify checkoutos.in

gcloud beta run domain-mappings create \
  --service checkoutos-web --domain checkoutos.in --region asia-south1

gcloud beta run domain-mappings create \
  --service checkoutos-web --domain www.checkoutos.in --region asia-south1

gcloud beta run domain-mappings create \
  --service checkoutos-api --domain api.checkoutos.in --region asia-south1

Each command prints the DNS records to add at your registrar — typically four A records and four AAAA records for the apex, and a CNAME to ghs.googlehosted.com for the subdomains.

Google provisions a managed TLS certificate automatically once DNS resolves. Propagation plus issuance usually takes 15–60 minutes, and the domain serves a certificate error until it completes.

Load balancer alternative

Cloud Run domain mappings are not available in every region. If asia-south1 refuses the mapping, put a global external Application Load Balancer in front with a serverless NEG backend — more setup, but it also gets you Cloud CDN and Cloud Armor.

Health checks

Point the probe at /health on the API:

curl -s https://api.checkoutos.in/health | jq

It returns 200 when Redis and the gateway are both reachable and 503 when degraded, so it works as a liveness probe without any extra wiring.

Continuous deployment

gcloud builds triggers create github \
  --repo-name=website \
  --repo-owner=checkoutOs \
  --branch-pattern='^main$' \
  --build-config=cloudbuild.yaml

The cloudbuild.yaml in this repository builds the image, pushes it to Artifact Registry and deploys the new revision. Cloud Run keeps the previous revision, so a bad deploy is one gcloud run services update-traffic --to-revisions away from being undone.

Configure the gateway dashboards last

Once api.checkoutos.in serves traffic, set the webhook endpoint in each gateway dashboard:

https://api.checkoutos.in/webhooks/razorpay
https://api.checkoutos.in/webhooks/paytm

Until that is done, payments will be created and the user will complete them, but nothing will ever reach SUCCESS — the webhook is the only path there. See Webhooks.

On this page