Skip to main content

Deployment

Self-Hosting

VulnRadar is GPL-3.0 and can be self-hosted with Docker. This guide walks through a production deployment end to end.

Overview

The fastest path to running VulnRadar yourself. Assumes a single Linux server with Docker. For Kubernetes, multi-region, or bare-metal setups, adapt accordingly.

Hardware Requirements

WorkloadCPURAMDisk
Demo / personal use1 vCPU1 GB20 GB
Small team (10 users)2 vCPU2 GB50 GB
Public SaaS (100s of users)4+ vCPU8+ GB200+ GB

Prerequisites

  • Linux server (Ubuntu 22.04+ recommended) or any host with Docker
  • Docker 24+ and Docker Compose v2
  • A domain name with DNS pointing to the server
  • (Production) A reverse proxy (Caddy, Traefik, or nginx) for TLS termination

Clone and Configure

bash
git clone https://github.com/VulnRadar/vulnradar.dev.git
cd vulnradar.dev

# Generate a 32-byte API encryption key (64 hex chars)
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
# → paste into API_KEY_ENCRYPTION_KEY

Edit lib/config/config-values.ts to set:

TypeScript
export const CONFIG_APP_NAME = "YourBrand Scanner";
export const CONFIG_APP_URL = "https://scanner.yourdomain.com";
export const CONFIG_APP_REPO = "yourname/your-repo";
export const CONFIG_DISCORD_INVITE_URL = ""; // optional

export const CONFIG_SUPPORT_EMAIL = "[email protected]";
export const CONFIG_LEGAL_EMAIL = "[email protected]";
export const CONFIG_SECURITY_EMAIL = "[email protected]";
export const CONFIG_ENTERPRISE_EMAIL = "[email protected]";
export const CONFIG_NOREPLY_EMAIL = "[email protected]";

If you don't want billing features, set:

TypeScript
export const CONFIG_BILLING_ENABLED = false;

Full reference on the Configuration page.

Create .env

bash
cp .env.example .env

Fill in real values:

bash
# Required
DATABASE_URL=postgresql://vulnradar:STRONG_PASSWORD@postgres:5432/vulnradar
DATABASE_SSL=false
API_KEY_ENCRYPTION_KEY=<paste your 64-char hex>
NEXT_PUBLIC_APP_URL=https://scanner.yourdomain.com

# Optional: SMTP for transactional email
SMTP_HOST=smtp.yourdomain.com
SMTP_PORT=587
SMTP_USER=...
SMTP_PASS=...
[email protected]

# Optional: Discord OAuth
DISCORD_CLIENT_ID=...
DISCORD_CLIENT_SECRET=...
DISCORD_BOT_TOKEN=...
DISCORD_GUILD_ID=...

# Optional: Cloudflare Turnstile
NEXT_PUBLIC_TURNSTILE_SITE_KEY=...
TURNSTILE_SECRET_KEY=...

# Optional: Stripe (only if CONFIG_BILLING_ENABLED=true)
STRIPE_SECRET_KEY=sk_live_...
STRIPE_PUBLISHABLE_KEY=pk_live_...
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_live_...
STRIPE_WEBHOOK_SECRET=whsec_...

AI Features (Optional)

Chat, finding verification, and audit summaries are off unless you point them at an AI endpoint. Add to .env: AI_BASE_URL (or the AI_PROVIDER shorthand), AI_MODEL, and AI_API_KEY. Full variable reference and a real per-model context-window / max-output-token table are on Configuration → AI Providers & Models.

docker-compose

The default docker-compose.yml provisions Postgres and the app container, each with a healthcheck, and the app waits for Postgres to report healthy before it starts. The app reads .env via env_file, so every variable in that file reaches the container; the values compose derives itself, such as the in-network database URL, are set on the service and take precedence.

Start the Stack

bash
docker compose up -d
docker compose logs -f app   # watch startup

On boot, instrumentation.ts runs CREATE TABLE IF NOT EXISTS for every table. The meta row in vulnradar_schema_meta is written on the first successful migration. Look for Database schema verified successfully in the logs.

First Admin User

  1. Visit https://scanner.yourdomain.com/signup and create an account. (Running without Docker, e.g. for local development? Create the schema first with npm run db:create.)
  2. Nothing to run. The first account created on a fresh instance is given the super_admin role automatically, so signing up is all that is needed. Do not run an UPDATE users SET role = 'admin' against it: admin is a lower level than super_admin, so that demotes the account, and no screen in the product can put it back.
    SQL
    -- Only for promoting a LATER account, never the first one:
    UPDATE users
    SET role = 'admin'
    WHERE email = '[email protected]';
  3. Sign out and back in. The /admin route is now accessible.
  4. Open /admin, go to Settings, and set your rate limits, feature flags, billing limits, and retention windows there instead of editing lib/config/config-values.ts for anything that page covers. Those changes take effect for every running instance within about 30 seconds, no rebuild or restart needed.config-values.ts is still where you edit the app name, branding, and SEO metadata, since those are baked into the build.

TLS (Reverse Proxy)

VulnRadar does not terminate TLS itself. Put a reverse proxy in front. Minimal Caddy config:

CADDYFILE
scanner.yourdomain.com {
    reverse_proxy localhost:3000
    encode zstd gzip
}

Caddy auto-provisions a Let's Encrypt certificate.

For nginx, see the official nginx + Next.js guide.

Configure Stripe Webhook (If Billing)

Option A: Stripe dashboard

  1. In the Stripe dashboard, create a webhook:
    • URL: https://scanner.yourdomain.com/api/v3/webhooks/stripe
    • Events, rendered from REQUIRED_EVENTS in lib/billing/stripe-webhook-events.ts rather than restated, because an event the handler acts on but that you did not subscribe to simply never arrives: checkout.session.completed, customer.subscription.created, customer.subscription.updated, customer.subscription.deleted, invoice.payment_succeeded, invoice.payment_failed, payment_intent.succeeded, charge.refunded, charge.dispute.created
  2. Copy the signing secret into STRIPE_WEBHOOK_SECRET in .env.
  3. docker compose restart app

Option B: auto-setup endpoint

GET /api/v3/stripe/setup-webhook registers the webhook in Stripe and returns the signing secret, but only when the secret is not yet stored. After first run it returns { success: true, configured: true } with no secret. The endpoint requires an admin session unless the webhook is already configured.

bash
# Log in via the web UI as an admin user, then export the cookie:
curl -b cookies.txt https://scanner.yourdomain.com/api/v3/stripe/setup-webhook
# First call: returns { success: true, webhookSecret: "whsec_..." }
# Paste the secret into STRIPE_WEBHOOK_SECRET in .env and restart.

Backups

VulnRadar ships a built-in backup script: SQL dump to gzip to AES-256-GCM encryption to a local file, with optional pruning and offsite upload. Run it from the shell, from cron, or with the Backup button in /admin (which streams the same log to the panel).

bash
# Create a backup (writes to BACKUP_DIR, default ./backups)
npm run db:backup

# Restore. Prints what it would do without --yes; --yes actually applies it.
npm run db:restore -- --file=./backups/vulnradar-backup-<timestamp>.sql.gz.enc --yes

Backup environment variables

All optional; set them in .env. Full reference on the Configuration page.

VariableDefaultPurpose
BACKUP_DIR./backupsDirectory backups are written to (relative to the app root).
BACKUP_RETENTION_DAYS14Prune local backups older than this after a successful run. 0 keeps everything.
BACKUP_ENCRYPTION_KEYAPI_KEY_ENCRYPTION_KEY64-hex-char AES-256 key. Unset falls back to the app base key, so backups are encrypted by default.
BACKUP_OFFSITE_UPLOAD_URL(none)Presigned PUT URL (S3/R2/B2 or any receiver). Backup is uploaded there after the local write.

Prefer to manage backups outside the app? A managed Postgres (Neon, Supabase, RDS) with built-in automated backups, or a plain cron job, both work:

bash
# Manual dump/restore straight through docker compose
docker compose exec postgres pg_dump -U vulnradar vulnradar > backup-$(date +%F).sql
cat backup-2026-06-18.sql | docker compose exec -T postgres psql -U vulnradar vulnradar

Updates

There is no deploy pipeline that does this for you, and no automatic rollback. Upgrading is five steps, in this order, and the first one is not optional.

bash
cd vulnradar.dev

# 1. Back up, and write down where you are. This is your way back.
docker compose exec app npm run db:backup
git rev-parse --short HEAD          # or: git describe --tags

# 2. Fetch the new code
git pull

# 3. Build the new image. This does NOT swap the running container yet.
docker compose build app

# 4. Run the NEW image's migrator against the database, with the old
#    container still serving traffic. 'run --rm' starts a throwaway
#    container from the image you just built and never touches the
#    'app' service, so the schema advances while the old code is live.
docker compose run --rm app npm run db:migrate:dry-run   # read the plan
docker compose run --rm app npm run db:migrate

# 5. Now swap in the new version
docker compose up -d
docker compose logs -f app

Rolling back

Reverting the image alone is only safe when the new version made no schema change. If it did, the old code will not tolerate the new schema, so the database has to go back too.

bash
# Schema unchanged: pin the previous tag and restart
git checkout <previous-tag>
docker compose build app && docker compose up -d

# Schema changed: put the database back first, then the code.
# Stop only the app so Postgres stays up for the restore.
# db:restore does nothing without --file and --yes, and refuses a
# database that still has tables unless you add --force.
docker compose stop app
docker compose run --rm app npm run db:restore -- \
  --file=./backups/<the dump from step 1> --yes --force
git checkout <previous-tag>
docker compose build app && docker compose up -d

The migrator does ship reversible transitions (every version file exports both an upgrade and a downgrade plan, and npm run db:migrate lets you pick an older target), but a downgrade drops tables and columns and makes you type yes-delete-data to confirm. Restoring the backup you took in step 1 is the safer route and is the one to reach for unless you know exactly what the downgrade removes.

Renaming a fork

GPL-3.0 makes a rebranded fork an expected use, so this is a real question rather than a discouraged one. Here is the honest scope of the work.

What one setting covers

CONFIG_APP_NAME in lib/config/config-values.ts is exported as APP_NAME, and that one value already drives the application chrome, page titles and social cards, every email the app sends, all four report exporters (PDF, Markdown, SARIF and the compliance crosswalk), the scanner’s own User-Agent on every outbound request, the comparison pages, and this documentation. Change it and rebuild, and those all follow. CONFIG_APP_SLUG, CONFIG_APP_URL, CONFIG_LOGO_URL and the support email constants sit alongside it and want the same treatment.

What it does not cover

Roughly two hundred further occurrences of the name are literal strings, of which maybe sixty are visible to a user of a renamed instance. The clusters worth doing, in order: the browser extension (which has its own constants file and its own store listing), the OAuth error strings in the sign-in callbacks, and the SDK sample code in the API reference. Everything else is either a comment or somewhere nobody looks.

Troubleshooting

SymptomLikely causeFix
App crashes after schema verifyDATABASE_URL unreachableCheck DATABASE_URL and DATABASE_SSL; confirm Postgres accepts the connection.
Schema version mismatch on startupvulnradar_schema_meta.schema_version < CONFIG_MIN_SCHEMA_VERSIONRun npm run db:migrate (or upgrade CONFIG_MIN_SCHEMA_VERSION to match if you just want to skip).
API_KEY_ENCRYPTION_KEY invalidNot 64 hex chars, or unsetGenerate one: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
Build fails: TypeScript errors in lib/configRenamed or removed a CONFIG_* constant that registry.ts or constants.ts still imports by nameRun npm run typecheck; the error points at the exact import site.
502 from reverse proxyApp not listening on the expected portCheck APP_PORT (default 3000); confirm the app container is up via docker compose ps.
Stripe webhook 400sWrong signing secret or missing STRIPE_WEBHOOK_SECRETRe-copy from Stripe dashboard, restart app.
Login succeeds but 2FA code never arrivesSMTP not configuredSet SMTP_HOST/PORT/USER/PASS/FROM in .env and restart. If you are already locked out, clear 2FA from the database (see Locked out of your own instance below): /api/v3/auth/2fa/disable needs a completed login and cannot help here.

Locked out of your own instance

The app has no self-service escape from a second factor you cannot receive. POST /api/v3/auth/2fa/disable calls getSession() and 401s without one, and an account stopped at the 2FA prompt has no session yet: the interim state is a separate signed token, not a session cookie. The only recovery is from outside the app, against the database.

bash
# Clear the second factor for one account. Run against your database,
# e.g. docker compose exec postgres psql -U vulnradar -d vulnradar
UPDATE users
   SET totp_enabled = false,
       two_factor_method = NULL,
       totp_secret = NULL,
       backup_codes = NULL
 WHERE email = '[email protected]';

The user can sign in with their password afterwards and re-enrol. Nothing else about the account changes.

Database diagnostics and repair

Every one of these reports before it writes. Run the diagnose command first and read the output; the repair commands only act on what the matching diagnostic flagged.

CommandWhat it does
npm run db:diagnoseIntrospects the live schema and reports data corruption: foreign-key orphans, encrypted columns that will not decrypt, out-of-range enum values, impossible timestamps.
npm run db:repairApplies the fixes db:diagnose found. Dry run by default; a real write needs --apply --admin-id=<id> and is recorded in admin_audit_log.
npm run db:diagnose-2faReports accounts whose 2FA columns are internally inconsistent.
npm run db:repair-2faFixes only the rows db:diagnose-2fa proved corrupt. It cannot unlock a healthy account.
npm run db:repair-sequencesResets the Postgres identity sequences, which is what causes duplicate-key errors on insert after a restore.
npm run db:backupWrites a full dump. Run this before any upgrade or repair.
npm run db:restoreRestores a dump written by db:backup.

Security Checklist

  • TLS via reverse proxy (Caddy / Traefik / nginx)
  • Strong API_KEY_ENCRYPTION_KEY (32 random bytes, base16)
  • Strong POSTGRES_PASSWORD
  • SMTP credentials use an app-specific password
  • Stripe uses restricted keys (only required permissions)
  • Discord OAuth redirect URI is HTTPS
  • Backups automated daily with off-host retention
  • CONFIG_BILLING_ENABLED = false if you do not need paid tiers
  • https://yourdomain.com/.well-known/security.txt is reachable
  • Cloudflare Turnstile enabled to prevent signup abuse
  • For a high-security deployment, consider enabling session and/or API key IP binding in Admin -> Settings -> Authentication (off by default)
Self-Hosting Guide: Deploy Your Own Instance | VulnRadar