# VPS Preflight Checklist

Date: 2026-07-22

Run this checklist before `pnpm build` on a VPS.

## Environment

- `.env` exists on the VPS.
- `DATABASE_URL` points to PostgreSQL, not MongoDB.
- `NEXT_PUBLIC_SERVER_URL` is defined once only.
- `PAYLOAD_PUBLIC_SERVER_URL` is defined once only.
- `NEXT_PUBLIC_SERVER_URL` points to the current VPS IP/domain.
- `PAYLOAD_PUBLIC_SERVER_URL` matches the current VPS IP/domain.
- `NEXT_ALLOWED_DEV_ORIGINS` contains the current VPS IP/domain when using temporary dev mode over IP.
- SMTP credentials are complete, or `EMAIL_SKIP_VERIFY=true` is temporarily set for bootstrap.

Helpful commands:

```bash
grep -n "DATABASE_URL\|NEXT_PUBLIC_SERVER_URL\|PAYLOAD_PUBLIC_SERVER_URL\|NEXT_ALLOWED_DEV_ORIGINS\|EMAIL_SKIP_VERIFY" .env
```

## Database

- The database exists.
- The database user can connect.
- For a real localhost-to-VPS migration, the local database dump has been restored.
- Clone-ready dump available in repo: `backups/db/bungamekarsari-data-20260724-091637.sql`.
- On an empty VPS database, `pnpm bootstrap:schema` has been run before restoring the data-only dump.
- For an intentional fresh bootstrap, `pnpm dev` has been run once before `pnpm build`.
- Required Payload tables exist, especially `pages`.

Helpful commands:

```bash
psql "$DATABASE_URL" -c "\dt"
psql "$DATABASE_URL" -c "select count(*) from pages;"
```

If `pages` does not exist, do not run `pnpm build` yet.

## Media

- `public/media` exists.
- Local uploaded media has been synced to VPS.
- Clone-ready media archive available in repo: `backups/media/public-media-20260722-091316.zip`.
- Database media records and disk files are from the same backup/export.

Helpful command:

```bash
ls -la public/media | head
```

## Build Sequence

For restored local state:

```bash
pnpm install --frozen-lockfile
pnpm bootstrap:schema
node scripts/restore-postgres-data.mjs backups/db/bungamekarsari-data-20260724-091637.sql
rm -rf public/media
unzip -o backups/media/public-media-20260722-091316.zip -d .
pnpm generate:types
pnpm generate:importmap
pnpm build
pnpm start
```

For fresh empty bootstrap:

```bash
pnpm install --frozen-lockfile
pnpm dev:vps
```

Create/seed CMS content, then:

```bash
pnpm generate:types
pnpm generate:importmap
pnpm build
pnpm start
```

## Temporary VPS Dev Mode

Use this only while debugging or creating the first admin user:

```bash
rm -rf .next
pnpm dev:vps
```

If `/admin` returns `200` but the browser shows a blank page, inspect browser devtools for failed `/_next/...` JavaScript chunks. That usually means the dev client bundle is blocked, stale, or still compiling. For final VPS verification, stop dev mode and use `pnpm build && pnpm start`.
