Deployment
Deployment
Environments
| Environment | URL | Branch | Database | Storage |
|---|---|---|---|---|
| Production | datahub.io | production | datahub-cloud (Neon) | datahub-cloud (R2) |
| Staging | staging-cloud.datahub.io | staging | datahub-cloud-staging (Neon) | datahub-cloud-staging (R2) |
| Preview | *.vercel.app | PR branches | staging DB | staging storage |
Deployment Pipeline
Deployments are managed by Vercel:
- PR Preview: Every PR gets an automatic Vercel preview deployment using the staging database/storage.
- Staging: Merging to
stagingdeploys to the staging environment. - Production: Rebasing
stagingontoproductiondeploys to production.
The build command (pnpm build) runs Prisma migrations automatically, then downloads the ASN database:
prisma migrate deploy && prisma generate && node scripts/fetch-asn-db.mjs && next build
scripts/fetch-asn-db.mjs fetches DB-IP's monthly "IP to ASN Lite" release (CC BY 4.0) from download.db-ip.com into data/asn.mmdb, which next.config.js bundles with the raw-file routes (/api/raw/..., /api/raw-old/...) for asn/org on file_accessed and legacy_raw_requested. No credentials needed. The build log shows an ASN database: line on success; a failed or timed-out download (60 s per attempt) only logs a warning and the build continues, with asn/org null until the next deploy.
After each production deploy, smoke.yml loads a few real pages on https://datahub.io (scripts/smoke-test.sh: home, /blog, a blog post, a core dataset, and a missing post that must 404). It retries for about 2 minutes, then fails and opens a GitHub issue. It tests datahub.io rather than the deployment's own URL, which Vercel's SSO protection redirects to a login. Preview E2E can't catch a production-only failure such as stale database connections, since preview builds start fresh. Run it by hand with scripts/smoke-test.sh [base-url] or the workflow's "Run workflow" button. If a checked page is moved or deleted, update the list in the script.
Infrastructure
Databases
PostgreSQL hosted on Neon (via Vercel integration):
- Production:
datahub-cloud - Staging:
datahub-cloud-staging - Development: Local PostgreSQL via Docker (see DEVELOP.md)
The app connects through Neon's pooler (PgBouncer). POSTGRES_PRISMA_URL (the -pooler host) must include pgbouncer=true, which stops Prisma from saving prepared queries on the connection. Without it, PgBouncer keeps those saved queries on its long-lived connections. A migration that changes a column's type then makes them fail with cached plan must not change result type until the connections close, and every page that reads the table breaks. This took down all post pages after the User.email citext migration. Migrations use POSTGRES_URL_NON_POOLING (the direct host) and need no flag.
Content Storage
Cloudflare R2 buckets:
- Production:
datahub-cloud - Staging:
datahub-cloud-staging - Development: Local MinIO via Docker (see DEVELOP.md)
Redis (rate limits)
Upstash Redis (via Vercel integration), one database per environment:
- Production:
datahub-cloud-kv(Free plan: 500K commands a month) - Staging and previews:
datahub-cloud-kv-staging(Pay As You Go, $20 monthly budget) - Development: none; without
KV_REST_API_*the rate limits are off
A Pay As You Go budget is set per database in the Upstash console (open it with vercel integration open upstash <database>); $20 is the lowest it allows. When a database reaches its budget, Upstash throttles it for the rest of the month instead of billing more, and the rate limits (lib/rate-limit.ts) let every request through until it resets.
Authentication
GitHub OAuth applications (under Datopian account):
- Production:
DataHub Cloud - Staging:
DataHub Cloud - Staging - Development:
DataHub Cloud - Dev
Google OAuth client: one Web application client in Google Cloud, with an authorized redirect URI per domain (https://datahub.io/api/auth/callback/google, the staging domain, http://localhost:3000/api/auth/callback/google). Google doesn't accept wildcard redirect URIs, so Google sign-in doesn't work on Vercel preview URLs. Set both NEXT_PUBLIC_AUTH_GOOGLE_ID and AUTH_GOOGLE_SECRET, or neither (the Google button is hidden); env validation fails the build if only one is set.
Magic-link emails are sent through Resend (RESEND_API_KEY, same sender as the other transactional email).
Domain Configuration
Root Domain (datahub.io)
All routes are served by this single Next.js app. The middleware (middleware.ts) handles routing:
- Landing pages (
/,/collections,/solutions,/publications) are rewritten toapp/home/*;/pricingredirects to/solutions /@usernamepaths are rewritten toapp/user/*/<publication>/<post>paths route toapp/[publication]/[post]/*/dashboardand/loginhave auth guards- Custom domains are rewritten to
/_domain={hostname}/*
Subdomains
- Production:
datahub.io - Staging:
staging-datahub.io(orstaging-cloud.datahub.io)
Background Jobs (Inngest)
- Production/Staging: Inngest Cloud (https://app.inngest.com, invite required)
- Development: Local Inngest dev server via
make dev
Cloudflare Worker (content processing)
A separate Cloudflare Worker processes markdown uploads:
- Repo:
datahub-cloudflare-workers - Deployed independently to Cloudflare
- Consumes R2 queue events (prod/staging) or MinIO webhooks (dev)
- See ARCHITECTURE.md for details
Environment Variables
Production and staging environment variables are configured in Vercel project settings.
Required variables (see .env.example for full list):
POSTGRES_PRISMA_URL/POSTGRES_URL_NON_POOLING- Database connections, pooled (must includepgbouncer=true, see Databases) and directNEXTAUTH_SECRET- Session encryption keyNEXT_PUBLIC_AUTH_GITHUB_ID/AUTH_GITHUB_SECRET- GitHub OAuthNEXT_PUBLIC_AUTH_GOOGLE_ID/AUTH_GOOGLE_SECRET- Google OAuth (optional)S3_*variables - R2 storage configurationGH_ACCESS_TOKEN/GH_WEBHOOK_SECRET- GitHub integrationINNGEST_APP_ID- Inngest configurationNEXT_PUBLIC_ROOT_DOMAIN/NEXT_PUBLIC_CLOUD_DOMAIN- Domain configuration
CI/CD
GitHub Actions workflows (.github/workflows/). Every job runs on Datopian's own runner (runs-on: self-hosted, Linux arm64, datopian/self-hosted-runner-hetzner) except sync-ga-views.yml, which keeps production database credentials off that shared box and stays on ubuntu-latest. GitHub-hosted minutes count against the org's $5 Actions budget; when it runs out, hosted jobs in every Datopian repo stop. The runner cannot sudo, so steps like playwright install --with-deps fail there.
| Workflow | Trigger | Description |
|---|---|---|
e2e.yml | PR to main/staging, push to staging | E2E tests against Vercel preview deployment |
lint.yml | PR to main/staging, push to staging | ESLint checks |
unit.yml | PR to main/staging, push to main | Jest unit tests |
sync-ga-views.yml | Scheduled (daily) | Sync Google Analytics view counts |
smoke.yml | Vercel production deploy succeeds (deployment_status), manual | Checks pages on datahub.io; opens an issue on failure |