Dev.to WebDev πŸ›  Dev πŸ‘ 2 πŸ“– 8 min read

Migrating a Production Next.js + Prisma + Supabase Monorepo to Dodil Cloud (Free Tier Walkthrough & Honest Friction Log)

When evaluating a newer cloud platform, "Hello World" tutorials rarely tell you what happens when you bring a real production codebase with a monorepo structure, Prisma ORM, NextAuth v5, and live users. Over the past fe

Migrating a Production Next.js + Prisma + Supabase Monorepo to Dodil Cloud (Free Tier Walkthrough & Honest Friction Log)

When evaluating a newer cloud platform, "Hello World" tutorials rarely tell you what happens when you bring a real production codebase with a monorepo structure, Prisma ORM, NextAuth v5, and live users.

Over the past few days, I migrated a client's bilingual (VI/EN) legal publishing platformβ€”a Next.js 15 + React 19 + TypeScript + Yarn 3.6.1 Workspaces monorepo (app, admin, and packages/database) running on GitHub + Vercel + Supabaseβ€”onto Dodil Cloud (Free Tier).

The core constraint: zero downtime and zero destructive changes to the live production stack. We worked strictly on an isolated branch (feat/dodil-migration), kept the client's repository private, migrated the database and auth layer, and wired up automated CI/CD to Dodil Ignite alongside a one-way sync pipeline from Supabase.

Here is the complete, honest walkthroughβ€”including what worked surprisingly well and every real friction point we ran into.

Architecture Overview

To keep the existing production deployment untouched while running a full mirror on Dodil Cloud, we built the following setup:

  • Source Control: Private repo on Dodil Git (feat/dodil-migration), completely isolated from origin/main on GitHub.
  • Database: Dodil KΒ³ Postgres (14 tables: 11 Prisma models + 3 implicit M–N join tables), synced one-way from Supabase.
  • Authentication: Dodil AppId (OIDC + official REST APIs) integrated at the backend of NextAuth v5 with 0% UI changes to the existing admin login modal.
  • Hosting & CI/CD: Multi-target Docker builds via Dodil Git Actions deploying both law-blog-web and law-blog-admin to Dodil Ignite, plus a scheduled 6-hour sync workflow.

Milestone 1: Dodil CLI & Private Repo Setup on Windows

Environment: Windows 10, PowerShell 5.1, Git 2.50.

Friction #1: Windows install.ps1 fails on PowerShell 5.1

Running the official Windows installer failed at line 89 because [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture returns $null on Windows PowerShell 5.1, breaking architecture detection.

Workaround: Patching install.ps1 locally to use [Environment]::Is64BitOperatingSystem got dodil CLI installed cleanly, followed by dodil auth login --web.

Friction #2: Repo visibility flag & non-TTY dodil git setup

  • dodil git repo create rejects --private; the actual flag is --visibility private.
  • Running dodil git setup inside VS Code's integrated terminal failed because it tries to generate an SSH key interactively when ~/.ssh is empty, which errors out in non-TTY shells.

Workaround: Skip SSH and use the built-in HTTPS credential helper instead:

dodil git credential-helper install
git -c core.askPass="" push -u dodil feat/dodil-migration

Passing -c core.askPass="" prevents Windows Git Credential Manager from popping up and conflicting with Dodil's credential helper.

Milestone 2: Migrating Supabase Postgres β†’ Dodil KΒ³ Postgres

Because pg_dump and psql weren't installed on this Windows machine, we avoided heavy local tooling by generating DDL via Prisma and exporting data with a read-only Node/Prisma script:

yarn workspace @law-blog/database prisma migrate diff `
  --from-empty `
  --to-schema-datamodel prisma/schema.prisma `
  --script > ..\Backup\schema.sql

Then we provisioned a KΒ³ bucket (dodil data bucket create law-blog) and pushed the schema via dodil data pg -b law-blog -f schema.sql --continue-on-error --report report.tsv.

This immediately surfaced three important SQL compatibility differences on Dodil KΒ³:

Friction #3: CREATE TYPE ... AS ENUM is not permitted (SQLSTATE 42501)

ERROR: permission denied: CREATE TYPE is not permitted (SQLSTATE 42501)

Because our User model used Postgres Role and Status ENUMs, table creation failed for User.

Fix: Converted role and status to String columns with defaults (@default("AUTHOR"), @default("PENDING")) in schema.prisma, and exported TypeScript Role / Status constants and union types from @law-blog/database so type safety stayed 100% intact across the monorepo.

Friction #4: ON DELETE CASCADE is not supported (SQLSTATE 0A000)

ERROR: FOREIGN KEY "_PostToTag_A_fkey": ON DELETE CASCADE is not supported.
This engine enforces referential integrity as NO ACTION / RESTRICT...

Fix: Removed onDelete: Cascade from schema.prisma (keeping standard RESTRICT foreign keys) and audited every .delete() call in admin/. In deletePost, we explicitly disconnected join relations (categories, tags, legalDocs) and deleted PostViewStat records before deleting the parent Post.

Friction #5: Statement-by-statement RTT latency in dodil data pg -f

Running a 45-statement SQL file via dodil data pg -f executes each statement sequentially over network RTT (~1s/statement). For bulk data import, connecting directly over pgwire with a scoped dk_ API key (k3.editor) and Prisma createMany (batched in chunks of 100) was dramatically faster.

Because KΒ³ limits concurrent readers per bucket, we appended &connection_limit=8 to both DATABASE_URL and DIRECT_URL:

postgresql://dodil:<REDACTED>@pg.uk-lon-1.dodil.io:5432/law-blog?sslmode=require&connection_limit=8

Result: 14/14 tables (including _CategoryToPost, _PostToTag, _LegalDocumentToPost) achieved 100% row-count parity, and both app and admin passed tsc --noEmit and local read/write smoke tests.

Milestone 3: Integrating Dodil AppId (With 0% Login UI Changes)

The client wanted to keep their existing AuthModal UI and bcrypt password hashes from Supabase intactβ€”no extra login buttons or forced password resetsβ€”while backing authentication and account revocation with Dodil AppId.

Provisioning & CLI Gotcha

We created a User Pool (law-blog, --with-local, --allow-signup=false) and registered a first-party PKCE OAuth client (law-blog-admin).

Friction #6: Issuing an API key with --role appid.admin failed with role appid.admin does not exist until we explicitly passed --service appid-authorization-service (the CLI defaults to KΒ³'s authorization service).

Backend Integration

  • Added an official REST client (admin/src/lib/dodilAppId.ts) talking directly to https://api.dodil.io/v1/appid/pools/... (zero HTML scraping).
  • Registered the OIDC provider dodil-appid (PKCE + state) alongside Credentials in admin/src/auth.ts.
  • On login, the server validates the user against KΒ³ Postgres (SUPERADMIN / AUTHOR roles, hard-blocking PENDING / LOCKED / BANNED), resolves/syncs their appidSub on Dodil AppId, and attaches it to the NextAuth JWT session.
  • Hooked our existing /lock-account emergency lock flow (EmergencyLockToken) into AppId's POST .../users/{id}/ban and POST .../users/{id}/sessions/revoke endpoints so locking an account immediately bans and revokes sessions in AppId as well.

One-Way Sync Script (scripts/sync-from-supabase.mjs)

To keep Dodil automatically up to date while Supabase remains the primary write source, we wrote a read-only sync script (yarn sync:dodil) that:

  • Reads Supabase User rows using "role"::text and "status"::text to bridge the Supabase ENUM ↔ KΒ³ String difference cleanly.
  • Avoids raw UPSERT (respecting KΒ³'s pgwire constraints) and syncs all 10 entity tables, 3 M–N join tables, 14-day incremental PostViewStat rows, and AppId user/ban states.

Milestone 4: CI/CD from Dodil Git β†’ Dodil Ignite

Dodil Git runs GitHub Actions-compatible workflows from .github/workflows/*.yml and deploys containers declaratively via .dodil/deploy.yamlβ€”and supports deploying multiple apps from a single monorepo.

Preparing the Monorepo for Ignite Containers

  1. Prisma binary targets: Added binaryTargets = ["native", "debian-openssl-3.0.x"] in schema.prisma.
  2. Conditional standalone mode: Enabled output: "standalone" (with outputFileTracingRoot) only when STANDALONE=true so Docker images stay lean (~129MB, <400ms startup) without affecting Vercel builds.
  3. Health endpoints: Added /api/health routes on both app and admin (Ignite pods crash-loop if the configured readiness probe returns 404).
  4. Numeric non-root user: Ignite enforces runAsNonRoot on Kubernetes and rejects string usernames like USER nextjsβ€”your Dockerfile must use a numeric UID (USER 1001).
  5. Secrets hygiene: Uploaded all runtime secrets via dodil git secret set law-blog <NAME> over stdin. Crucially, SUPABASE_DATABASE_URL is only exposed to the sync workflowβ€”never to the live Web/Admin containers.

.dodil/deploy.yaml Highlights

  • Declared both law-blog-web and law-blog-admin under a shared group (create_if_missing: true).
  • Set public_invoke: true on both apps (by default, Ignite blocks anonymous traffic with 401).
  • Set AUTH_TRUST_HOST: "true" and AUTH_URL on law-blog-admin so NextAuth v5 works cleanly behind Ignite's reverse proxy without UntrustedHost errors.
  • Did a two-pass deploy: Pass 1 provisioned the Ignite apps and generated their public hostnames; Pass 2 updated AppId's redirect URIs and NEXT_PUBLIC_* secrets, then rebuilt the client bundles so sitemap.xml, feed.xml, and OAuth callbacks pointed to the live Ignite URLs.

Four Real CI/CD & Runtime Frictions We Solved

  1. Local proxy TLS error (x509): If http_proxy / https_proxy are present in your local shell, dodil.exe fails with x509: certificate signed by unknown authority. Clearing those env vars in the shell fixes it immediately.
  2. Runner missing global yarn: On catthehacker/ubuntu:act-latest after actions/setup-node@v4, global yarn wasn't on PATH, failing our sync job. Fix: invoke the committed Yarn 3 binary directly via node .yarn/releases/yarn-3.6.1.cjs.
  3. Cron schedules only run on the default branch: dodil git run schedules ignores on: schedule workflows until the branch containing them is set as the repository's default branch in Dodil Git settings (manual workflow_dispatch works on any branch).
  4. DuckDB Boolean Subquery Bug on KΒ³ (SQLSTATE 42601): After deploying law-blog-web, post and category lists came back empty. The logs revealed:
   Conversion Error: Could not convert string '\u{1}' to BOOL

Prisma's post.count({ where: { published: true } }) and _count subqueries triggered a boolean typing mismatch in KΒ³'s DuckDB pgwire layer.
Fix: Replaced count / _count with findMany({ where, select: { id: true } }).length and include: { posts: { select: { published: true } } }, and replaced postViewStat.upsert with findUnique + update/create (avoiding a KΒ³ upsert quirk). Redeployed v4 and all live pages, categories, RSS feed, sitemap, and view counters worked cleanly with zero Prisma errors.

Honest Verdict: What Worked Great vs. What Needs Polish

What I Liked

  • Unified developer experience: Having Git, Container Registry, Postgres (KΒ³), OIDC Auth (AppId), and Serverless Containers (Ignite) under one CLI and one deploy.yaml is genuinely refreshing.
  • dodil git ci verify: Catching misconfigured secrets, branch names, and deploy.yaml schema issues before pushing saved multiple wasted CI cycles.
  • Multi-app monorepo support: Deploying both web and admin from a single multi-target Dockerfile worked cleanly out of the box.
  • Fast cold/warm starts: Next.js standalone containers booted in under 400ms on Ignite.

Rough Edges for the Dodil Team

  • Windows PowerShell 5.1 installer: install.ps1 should fall back gracefully when RuntimeInformation::OSArchitecture is $null.
  • KΒ³ Postgres compatibility docs & DuckDB boolean bug: The ENUM (42501) and ON DELETE CASCADE (0A000) error messages are actually very clear, which helped a lotβ€”fixing the DuckDB boolean subquery conversion ('\u{1}' to BOOL) would make Prisma apps work out of the box without query rewrites.
  • CLI ergonomics: Making dodil auth apikey issue --role appid.admin infer --service appid-authorization-service automatically (or printing the exact flag in the error message) would save debugging time.

Overall, migrating a full Next.js 15 + Prisma + NextAuth monorepo to Dodil Cloud's Free Tier is completely viable todayβ€”as long as you know about KΒ³'s SQL differences and Ignite's container rules ahead of time. Hopefully this log saves you a few hours if you're trying it yourself!

πŸ“° Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.