Open Sky Commerce / Documentation

Deploy to DigitalOcean

DigitalOcean App Platform is the recommended deployment target for Open Sky Commerce. It handles building, running, and scaling your Next.js app without server administration, and pairs naturally with DigitalOcean Managed Databases and Spaces.

Option A — Bootstrap Script (Recommended)

The included script automates the entire DigitalOcean setup: it creates (or reuses) a managed database, runs migrations, optionally seeds demo data, creates the App Platform app from the spec in .do/app.yaml, injects generated secrets, and triggers the first deployment.

Prerequisites

  • doctl installed and authenticated (doctl auth init)
  • gh CLI installed and authenticated (gh auth login) — used to create your private GitHub repository
  • Your code extracted from the ZIP archive (no .git directory yet)

Run the Script

bash scripts/bootstrap-do-app.sh

The script will interactively:

  1. Verify doctl and gh are authenticated
  2. Initialize a git repo and push to a new private GitHub repository
  3. Create (or reuse) a DigitalOcean Managed PostgreSQL database and wait until it is online
  4. Run prisma migrate deploy against the production database
  5. Optionally seed demo data into the production database
  6. Create the App Platform app using .do/app.yaml, injecting the database URL and generated secrets (NEXTAUTH_SECRET, APP_ENCRYPTION_KEY)
  7. Patch the app spec with your site URL and trigger the first deployment

After the script completes, open the DigitalOcean dashboard, find your new app, and add any remaining environment variables (SendGrid, Spaces, etc.) under Settings → Environment Variables.


Option B — Manual Setup

Follow these steps if you prefer to configure everything manually, or if you are deploying to an existing app.

Prerequisites

Step 1 — Create a Managed PostgreSQL Database

  1. In the DigitalOcean dashboard, click Create → Database.
  2. Select PostgreSQL 16. The smallest plan (1 vCPU / 1 GB) is sufficient to start.
  3. Choose the datacenter region you plan to use for the app (e.g. NYC3, SFO3).
  4. Click Create Database Cluster and wait for provisioning.
  5. Once running, copy the Connection String (URI format) from the Connection Details tab. Append &connection_limit=5 to cap the Prisma pool per instance:
    postgresql://doadmin:xxx@host:25060/defaultdb?sslmode=require&connection_limit=5

Step 2 — Run Database Migrations

From your local machine with DATABASE_URL set to the production connection string:

npx prisma migrate deploy

This applies all migrations to the production database. Do this before the first deployment so the schema is ready when the app starts.

Step 3 — Create an App Platform App

The recommended approach is to apply the included app spec rather than configuring through the dashboard UI:

# Edit .do/app.yaml first: update repo, branch, region, and placeholder URLs
doctl apps create --spec .do/app.yaml

Or create through the dashboard and set these exact values:

  • Build Command: NPM_CONFIG_PRODUCTION=false npm ci --include=dev && NODE_OPTIONS="--max-old-space-size=2048" npm run build
  • Run Command: node scripts/do/wait-for-db.js && { (sleep 75 && node scripts/do/warmup.js) & exec npm start; }
  • HTTP Port: 8080

Step 4 — Add Environment Variables

Set all required variables in App Platform → Settings → Environment Variables. At minimum:

DATABASE_URL=postgresql://...?sslmode=require&connection_limit=5
NEXTAUTH_URL=https://your-app.ondigitalocean.app
NEXTAUTH_SECRET=<openssl rand -base64 32>
NEXT_PUBLIC_SITE_URL=https://your-app.ondigitalocean.app
APP_ENCRYPTION_KEY=<node -e "console.log(require('crypto').randomBytes(32).toString('hex'))">
[email protected]
WARMUP_CONCURRENCY=1

Mark DATABASE_URL, NEXTAUTH_SECRET, and APP_ENCRYPTION_KEY as Encrypted. See Environment Variables for the full list.

Step 5 — Trigger a Deployment

Click Deploy in the App Platform dashboard, or push a commit to your connected branch. The build will take a few minutes. Once running, the warmup script automatically pre-renders 20+ high-value routes to populate the ISR cache before the first visitor arrives.

Step 6 — Configure Payment & Shipping

After deployment, log into the admin panel and complete setup:

  1. Go to Admin → Business Info and fill in your company address. This is required as the shipping origin for live shipping rate quotes.
  2. Go to Admin → Settings → Payment Settings and enter your payment processor credentials.
  3. Go to Admin → Settings → Shipping Settings and configure a shipping provider or flat rate.

The Setup Assistant dialog on the admin dashboard will automatically highlight any remaining required configuration items.


Custom Domain

Add your domain in App Platform → Settings → Domains. Once the domain is active, update NEXTAUTH_URL, NEXT_PUBLIC_SITE_URL, and SITE_URL in your environment variables to use the custom domain instead of the .ondigitalocean.app URL.

Scaling

The default spec deploys 1 instance. To run multiple instances for redundancy, increase instance_count in your app spec or in the dashboard. With 2 instances on a DigitalOcean Managed DB (25-connection limit), keep connection_limit=5 in DATABASE_URLso the total pool stays well under the limit.