Updated Nov 23, 20267 min read

How to Migrate from DigitalOcean App Platform to Google Cloud

A step-by-step move from DigitalOcean App Platform to GCP: reading the app spec, mapping services, workers, jobs, Managed PostgreSQL, Valkey and Spaces to Cloud Run, Cloud SQL, Pub/Sub, Memorystore and Cloud Storage, moving the data with pg_dump and rclone, importing the database into an app that declares its infrastructure in code, and cutting over DNS.

Illustration for How to Migrate from DigitalOcean App Platform to Google Cloud

App Platform is a good place to start a backend, and teams usually leave for GCP when a customer asks for it, when they want Pub/Sub or BigQuery next to the data, or when one app spec stops being enough. The move is mostly mapping components and moving two kinds of data.

This guide walks through the app spec, the data and the cutover.

Step 1: read the app spec

Everything App Platform runs is described in the app spec, so export it with doctl apps spec get and list each component:

~
$ doctl apps list --format ID,Spec.Name$ doctl apps spec get <app-id> > app.yaml

Look for services, workers, jobs (with kind: PRE_DEPLOY, POST_DEPLOY or a cron schedule), static_sites, databases, the environment variables marked as secrets, and the domains. Each one needs a destination before anything moves.

Step 2: map each component

App PlatformGoogle Cloud
ServiceCloud Run service
WorkerCloud Run service with CPU always allocated and a minimum of one instance, or a Pub/Sub subscription
Pre-deploy job (migrations)Cloud Run job run by the deploy pipeline
Scheduled jobCloud Run job triggered on a schedule
Static siteCloud Storage bucket behind Cloud CDN
Managed PostgreSQLCloud SQL for PostgreSQL
Managed ValkeyMemorystore
SpacesCloud Storage
Encrypted environment variablesSecret Manager
VPCVPC with Direct VPC egress from Cloud Run
DomainsCloud Run domain mapping or a load balancer

A worker that polls Valkey for jobs is the component most worth redesigning. On GCP, a Pub/Sub subscription that pushes messages with retries and a dead-letter topic replaces both the queue and the always-on poller.

Step 3: move the database

DigitalOcean Managed PostgreSQL requires TLS and only accepts connections from trusted sources, so add the machine running the dump to the database's trusted sources first. For most databases, a dump and restore during a short write freeze is the simplest path:

~
$ pg_dump "postgresql://doadmin:...@db-host:25060/defaultdb?sslmode=require" \ --format=custom --no-owner --no-privileges --file=app.dump$ pg_restore --no-owner --no-privileges --jobs=4 \ --dbname="postgresql://postgres:...@CLOUD_SQL_IP:5432/app" app.dump

pg_restore with --jobs restores tables in parallel, which shortens the freeze. Time a dry run against a copy before cutover day. For large databases or a downtime budget of minutes, Database Migration Service can replicate continuously from the source into Cloud SQL and promote at cutover, provided the source meets its requirements for extensions and replication.

Step 4: move Spaces to Cloud storage

Spaces speaks the S3 API, so rclone can copy a Space to a Cloud Storage bucket with an S3 remote for DigitalOcean and a Google Cloud Storage remote for the destination:

~
$ rclone sync spaces:acme-uploads gcs:acme-uploads --checksum --transfers=32 --progress$ rclone check spaces:acme-uploads gcs:acme-uploads --one-way

Run the sync once in bulk, then again right before cutover to pick up recent uploads. Public objects served from the Spaces CDN need new URLs, and presigned Spaces URLs stop working once readers switch.

Step 5: declare the GCP side in code

Encore

Encore brings infrastructure from code, and the components from the app spec become declarations in the code that uses them. Encore provisions them in your own GCP project as Cloud Run, Cloud SQL, Pub/Sub and Cloud Storage, as the GCP infrastructure docs describe, and the worker and scheduled job become a subscription and a cron job.

Application code passes through Encore and infrastructure guardrails to resources provisioned in your own AWS or GCP account.

Set up the app

Get started
brew install encoredev/tap/encore &&
encore app create
Copy

Run in your terminal to get started locally.

~
$ encore app create acme --example=ts/hello-world$ cd acme && mkdir -p app/migrations

One service that holds the API, the former worker and the former scheduled job, with the database, the uploads bucket and the queue declared next to them:

// app/app.ts import { api, APIError } from "encore.dev/api"; import { getAuthData } from "~encore/auth"; import { SQLDatabase } from "encore.dev/storage/sqldb"; import { Bucket } from "encore.dev/storage/objects"; import { Topic, Subscription } from "encore.dev/pubsub"; import { CronJob } from "encore.dev/cron"; import log from "encore.dev/log"; // The name matches the database restored in step 3. const db = new SQLDatabase("app", { migrations: "./migrations" }); const uploads = new Bucket("acme-uploads", { versioned: false }); interface OrderPlaced { orderID: number; } const orderPlaced = new Topic<OrderPlaced>("order-placed", { deliveryGuarantee: "at-least-once" }); export const placeOrder = api( { expose: true, method: "POST", path: "/orders" }, async (p: { customerID: number; totalCents: number }): Promise<{ orderID: number }> => { if (p.totalCents <= 0) throw APIError.invalidArgument("total must be positive"); const row = await db.queryRow<{ id: number }>` INSERT INTO orders (customer_id, total_cents) VALUES (${p.customerID}, ${p.totalCents}) RETURNING id `; await orderPlaced.publish({ orderID: row!.id }); return { orderID: row!.id }; }, ); // Order IDs are sequential, so the caller must be signed in and own the order. export const invoiceURL = api( { expose: true, auth: true, method: "GET", path: "/orders/:id/invoice" }, async ({ id }: { id: number }): Promise<{ url: string }> => { const owned = await db.queryRow` SELECT 1 FROM orders WHERE id = ${id} AND customer_id = ${Number(getAuthData()!.userID)} `; if (!owned) throw APIError.notFound("order not found"); const key = `invoices/${id}.pdf`; if (!(await uploads.exists(key))) throw APIError.notFound("invoice not ready"); const { url } = await uploads.signedDownloadUrl(key, { ttl: 600 }); return { url }; }, ); // The former App Platform worker. const _ = new Subscription(orderPlaced, "render-invoice", { retryPolicy: { maxRetries: 5 }, handler: async ({ orderID }) => { const order = await db.queryRow<{ total_cents: number }>` SELECT total_cents FROM orders WHERE id = ${orderID} `; if (!order) return; // Rendering the same key again on a retry overwrites the earlier attempt. const body = Buffer.from(`Invoice ${orderID}: ${order.total_cents} cents\n`); await uploads.upload(`invoices/${orderID}.pdf`, body, { contentType: "application/pdf" }); log.info("invoice rendered", { orderID }); }, }); // The former scheduled job. export const purgeAbandoned = api({ expose: false }, async (): Promise<void> => { await db.exec`DELETE FROM carts WHERE updated_at < now() - interval '30 days'`; }); const _purge = new CronJob("purge-abandoned-carts", { title: "Delete carts untouched for 30 days", schedule: "0 2 * * *", endpoint: purgeAbandoned, });

The invoice body is a placeholder for your PDF renderer. The migration directory starts with a bootstrap migration made from the schema of the DigitalOcean database, so new environments get the same tables:

~/acme
$ pg_dump "postgresql://doadmin:...@db-host:25060/defaultdb?sslmode=require" \ --schema-only --no-owner --no-privileges > app/migrations/1_bootstrap.up.sql

Import the restored database

For production, the Cloud SQL import guide covers creating the environment with the Cloud SQL instance from step 3 instead of a new one. Encore tracks applied migrations in a schema_migrations table, so in the imported database mark the bootstrap as already applied, and only later migrations run against it:

CREATE TABLE IF NOT EXISTS schema_migrations (version bigint NOT NULL, dirty boolean NOT NULL); INSERT INTO schema_migrations (version, dirty) VALUES (1, false);

encore run starts Postgres with the bootstrap schema, stores bucket objects on the local filesystem and runs the subscription, so an order can be placed and its invoice fetched on a laptop before the GCP environment exists. The purge is an Encore platform Managed cron job that runs in deployed environments, not locally or in preview environments, so call purgeAbandoned from the local dashboard to test it.

A coding agent porting the remaining App Platform components adds each one as a declaration in the same change as the code that uses it and runs it locally.

Best fit: Teams leaving App Platform for GCP that want the worker, schedules, database and bucket declared in the application instead of rebuilding them as separate Cloud Run jobs, schedules and IAM configuration.

Step 6: cut over

  1. Lower the DNS TTL for the app's domains a day ahead.
  2. Deploy the GCP environment and test it against a restored copy of the data.
  3. Freeze writes on both App Platform and GCP, take the final dump and restore it, and run the last rclone sync before allowing writes on GCP, since rclone sync deletes objects that exist only in the destination.
  4. Point DNS at the GCP endpoint and watch error rates and latency.
  5. Keep the App Platform app and database read-only for a week before deleting them.

App platform to GCP migration checklist

  • Export the app spec and map every component.
  • Redesign Valkey-polling workers as Pub/Sub subscriptions.
  • Rehearse the database dump and restore, and time it.
  • Sync Spaces to Cloud Storage twice: bulk, then at cutover.
  • Move secrets to the new environment, never into the repository.
  • Lower DNS TTLs early and keep the old app read-only for a while.

Frequently asked questions

What is the GCP equivalent of DigitalOcean App Platform?

Cloud Run is the closest match, and App Platform services become Cloud Run services, workers become Cloud Run services that keep CPU allocated, and deploy-time and scheduled jobs become Cloud Run jobs. Managed PostgreSQL maps to Cloud SQL, Managed Valkey to Memorystore and Spaces to Cloud Storage.

How do I move a DigitalOcean Managed PostgreSQL database to Cloud SQL?

For small and medium databases, take a pg_dump in custom format from DigitalOcean during a write freeze and restore it into Cloud SQL with pg_restore. For large databases or tight downtime windows, use Database Migration Service with continuous replication if your source meets its requirements.

How do I copy DigitalOcean Spaces to Google Cloud Storage?

Spaces is S3-compatible, so rclone can sync a Space to a Cloud Storage bucket with an S3 remote for Spaces and a Google Cloud Storage remote for the destination. Run it once in bulk and again right before cutover to pick up new objects.

Can I declare the GCP infrastructure in application code instead of an app spec?

Yes. With Encore, services, the database, Pub/Sub topics, buckets and cron jobs are declared in application code and provisioned in your own GCP project, and an existing Cloud SQL instance can be imported when the environment is created.

Deploy to your cloud on AWS and Google Cloud
without managing infrastructure

Encore lets developers and agents define application infrastructure directly in code, then automatically provisions it from local development to production in your AWS or GCP account.

~/orders — claude
Claude Code
Claude Code v2.1.180Opus 5.5~/orders