From a clean clone to a running dev server.
Prerequisites
Node 22 (the production image uses node:22-bookworm-slim), npm, and Docker for a local
Postgres.
Steps
-
Install.
npm installpostinstallrunsprisma generate. It reads the datasource URL throughprocess.envrather than Prisma'senv(), so this step does not need a database. -
Start a local Postgres. Production runs
postgres:17; match it.docker run -d --name mun-db -e POSTGRES_PASSWORD=postgres -p 5432:5432 postgres:17 -
Configure the environment.
cp .env.example .envSet
DATABASE_URLandDIRECT_URLtopostgresql://postgres:postgres@localhost:5432/postgres, andAUTH_SECRETto any long random string. Everything else is optional locally. See environment variables. -
Apply migrations.
npm run db:deploy -
Seed. See below for which one.
npm run db:seed -
Run.
npm run dev
Which seed to use
prisma/seed.ts creates settings, five committees, six fees and one admin, and zero
portfolios and zero delegates, so allotment, payment and check-in cannot be exercised.
prisma/seed-staging.ts builds a usable world: portfolios, delegates in every state,
payments, posts, a quiz and a recruitment cycle. It truncates tables, so it is guarded:
ALLOW_DESTRUCTIVE_SEED=1 npx tsx prisma/seed-staging.ts
Do not do this
Check what DATABASE_URL points at before running it. It wipes the delegate, allotment,
payment, blog and quiz tables of whatever database that is.
Signing in locally
Magic links need a working email transport. Locally it is easier to give yourself a password:
npx tsx scripts/set-password.ts you@example.com 'a-long-password' ADMIN
Working against staging
Staging's database listens on its box's loopback interface only, so there is no connection
string you can paste. npm run staging:migrate and npm run staging:refresh read
.env.staging.local, which must point at an SSH tunnel you have opened to the staging box.
Most of the time, use the Staging seed workflow in GitHub Actions instead. See
CI and deployment.
The scripts
| Command | Does |
|---|---|
npm run dev | Dev server on port 3000 |
npm run build | Production build. Also the TypeScript check. |
npm run check | Every assertion script plus the strings gate |
npm run db:deploy | Apply existing migrations |
npm run db:migrate | Create a migration in development (interactive) |
npm run db:status | Show migration state |
npm run db:seed | Minimal seed |
npm run staging:migrate | Migrate staging through a tunnel, reads .env.staging.local |
npm run staging:refresh | Reseed staging through a tunnel, destructive |
Before you push
npm run check && npm run build
Both run in CI on every pull request.