Deployment Guide
A production Streamix deployment has up to four parts:
- The web app (Next.js): storefront, admin, API. Vercel or any Node host.
- PostgreSQL (Neon recommended).
- An S3-compatible bucket for artwork, video, subtitles and HLS output, ideally behind a CDN (Cloudflare R2 public bucket or custom domain).
- Optional workers: an hourly scheduler for
/api/v1/cron, and the HLS transcode worker on a VM or container.
For choosing a host see the Hosting Guide.
Build and start
npm install
npm run build # next build
npm run start # next start (port 3000 by default)
Do not ship .env files with development values. Set production variables in your host.
Environment
Minimum for production:
DATABASE_URL=postgresql://...-pooler...neon.tech/db?sslmode=require&channel_binding=require
JWT_SECRET=<long random>
SECRET_KEY=<long random, never change after launch>
CRON_SECRET=<random>
NEXT_PUBLIC_SITE_URL=https://watch.example.com
Once the database is provisioned, DB_SCHEMA_READY=1 skips the idempotent schema checks on cold starts. Remove it temporarily after an upgrade that adds tables or columns, or run the app once without it. The full list is in the Installation Guide.
Deploying to Vercel
The repo includes vercel.json:
{
"framework": "nextjs",
"buildCommand": "npm run build",
"regions": ["iad1"],
"crons": [{ "path": "/api/v1/cron", "schedule": "0 * * * *" }]
}
- Import the project, set the environment variables above and deploy.
- Pick a region close to your database (change
regions). - Vercel Cron sends
Authorization: Bearer <CRON_SECRET>automatically whenCRON_SECRETis set. - The filesystem is read-only: every upload goes to the bucket, and the installer cannot write
.env. Set variables in the dashboard and run the wizard for the remaining steps. - The cron route declares
maxDuration = 60; each task is bounded to stay under it.
Deploying to a Node server or container
- Run
npm run build && npm run startbehind a reverse proxy (nginx, Caddy) with HTTPS. - Use a process manager (systemd, pm2) or a container orchestrator to restart on failure.
- Pass through
X-Forwarded-*headers. For country-based availability, put the app behind Cloudflare (cf-ipcountry) or Vercel (x-vercel-ip-country); without either header the member's saved country is used, and if that is empty the catalogue is not restricted by country. - The in-memory rate limiter is per process. With several instances, limits apply per instance.
Storage and CDN
- In admin → Settings → Add-ons → Storage, add the production bucket and mark it Active and Default. Use a public URL on your own domain or CDN where possible.
- Run the CORS script with your production origins:
npx tsx scripts/setup-r2-cors.ts https://watch.example.com https://www.example.com
- Video files are fetched by the browser straight from the bucket's public URL. Cache headers are whatever your bucket/CDN sets; HLS segments are immutable per version folder (
ott/hls/<asset>/<version>/), so long cache lifetimes are safe.
Scheduler
If you are not on Vercel, call the cron endpoint about once an hour:
curl -fsS -H "Authorization: Bearer $CRON_SECRET" https://watch.example.com/api/v1/cron
It returns a JSON summary per task. All tasks are idempotent, so an extra run does no harm. Without a scheduler there is no Top 10 refresh, no renewal reminders, no on-hold/expiry handling and no reminder notifications.
Transcode worker
The worker turns uploaded MP4s into adaptive HLS with seek-bar thumbnails. It cannot run on serverless: it needs ffmpeg (bundled via npm), scratch disk of about 2-3× the source, and minutes of CPU per film.
npm run worker:transcode # poll the queue every 10 s
npm run worker:transcode -- --once # drain the queue, then exit
npm run worker:transcode -- --queue 247,251 --once
TRANSCODE_POLL_SECONDS=30 npm run worker:transcode
- It needs only
DATABASE_URL(storage credentials come from the database). - Run it on a small VM, a Fly/Render/Railway worker, a Docker container or a Kubernetes Deployment near the database. Several workers can share the queue.
- SIGINT/SIGTERM stop gracefully and requeue the running job. A crashed worker's job is reclaimed after 10 minutes; each job gets up to 3 attempts.
- Jobs are queued from admin → Titles ("Convert to HLS"), or automatically when a new MP4 is uploaded.
Without the worker, videos play as uploaded MP4 (or whatever HLS URL you entered).
Database
- Use the Neon pooler URL for the app and the direct (unpooled) URL for
pg_dump,pg_restoreand large imports. - Moving a local database to Neon:
pg_dump "$LOCAL_URL" --no-owner --no-privileges --no-comments -f dump.sql
psql "$DIRECT_NEON_URL" -v ON_ERROR_STOP=1 --single-transaction -f dump.sql
Integration credentials travel with the dump; the target must use the same SECRET_KEY.
Go-live checklist
-
JWT_SECRET,SECRET_KEY,CRON_SECRETset;SECRET_KEYbacked up - License activated for the production domain
- Storage connected, CORS set for the production origin
- A payment gateway active and a test purchase completed end to end
- Email provider connected; verification and sign-in codes arrive
- Plans reviewed (price, currency) and their streaming limits checked in the database (screens, max resolution)
- Cron running hourly
- Transcode worker running, if you use HLS conversion
- Branding, landing copy, legal pages and Help Centre reviewed
- Default admin password changed; extra admins given the least permissions they need
- Backups scheduled (see Backup & Restore)
© CreativeCape Solutions · creative-cape.com · support@creative-cape.com