Getting started
SurgeMedia ships as one npm package (@surge-media/core) and one Docker image (ghcr.io/mahmoud-nb/surge-media, amd64 and arm64). Both contain the admin interface, the REST API, media delivery and image processing.
Requirements
Section titled “Requirements”| Requirement | Minimum | Notes |
|---|---|---|
| Runtime | Node.js 24 or Docker | The Docker image bundles Node.js. |
| Database | SQLite (built in), PostgreSQL, MySQL or MariaDB | One image for all of them. |
| Storage | Local disk or an S3-compatible bucket | AWS S3, MinIO, Cloudflare R2, Scaleway, OVHcloud… |
| Video processing (optional) | FFmpeg 6 or later | Included in the default Docker image; absent from the slim variant. |
Choose your database
Section titled “Choose your database”You can start on SQLite and move to PostgreSQL later: the database is selected by configuration (DATABASE_URL), not at build time.
Install
Section titled “Install”-
Create the folder that will hold your configuration (
.env) and your data, then install the package:Terminal window mkdir media-server && cd media-servernpm install @surge-media/core -
With npm 12 or later, approve the install scripts of the native modules (npm 11 and earlier run them automatically):
Terminal window npm install-scripts approve better-sqlite3 @prisma/engines prismanpm rebuild better-sqlite3 @prisma/engines -
Run the interactive setup. It asks for the database (SQLite, PostgreSQL or MySQL / MariaDB), the web server port (3000, or the next free port if another application already uses it) and the public URL, applies the migrations and generates the secrets in
.env. It then asks how the instance will be used (evaluation, Community production or production under a commercial license). This is only a statement: nothing is sent, and “Later” skips the question.Terminal window npx surge-media init -
Start the server:
Terminal window npx surge-media startThe admin, the API and media delivery answer on
http://localhost:3000(or on the port you chose). If that port is taken at startup,startstops with a clear message instead of failing silently.
-
Start the container with a named volume for the database, media and generated secrets:
Terminal window docker run -d --name surge-media -p 127.0.0.1:3000:3000 \-v surge-media-data:/app/data \-e NUXT_SITE_URL=https://media.example.com \-e NUXT_BOOTSTRAP_ADMIN_EMAIL=you@example.com \-e NUXT_BOOTSTRAP_ADMIN_PASSWORD='a-long-passphrase' \ghcr.io/mahmoud-nb/surge-mediaMigrations are applied at startup. Use
DATABASE_URL=postgresql://…ormysql://…to switch databases. Port 3000 already taken on the host? Publish another one, for example-p 127.0.0.1:8080:3000(the container always listens on 3000). -
For a smaller image without video processing, use the
-slimtags (for exampleghcr.io/mahmoud-nb/surge-media:latest-slim).
The repository ships Compose files in docker/: a web server, a video worker and PostgreSQL 17.
POSTGRES_PASSWORD='change-me' \NUXT_SITE_URL=https://media.example.com \docker compose -f docker/compose.postgres.yaml up -dFor MySQL or MariaDB, replace the postgres service and set DATABASE_URL to mysql://…. To publish a host port other than 3000, add SURGE_MEDIA_PORT=8080.
First sign-in
Section titled “First sign-in”- Open the admin at your site URL and sign in with the bootstrap account (
NUXT_BOOTSTRAP_ADMIN_EMAIL/NUXT_BOOTSTRAP_ADMIN_PASSWORD). It becomes the first Admin. - Remove the bootstrap variables once the account exists, and invite your team from Users.
- Turn on two-factor authentication from My account (any authenticator app), then require it at least for administrators in Settings › Security. In Settings › License, check the declared use of the instance (on a Docker installation, this is where you declare it).
- Create a project for your application, add its allowed origins (
https://www.acme.com) and create its API keys: a publishable key for the browser, a secret key for your server. - Upload a few media files and copy their URLs, or call the API from your application.
Connect your application
Section titled “Connect your application”// SURGE_MEDIA_API_URL = https://media.example.com/api/v1const { SURGE_MEDIA_API_URL, SURGE_MEDIA_PROJECT_ID, SURGE_MEDIA_SECRET_KEY } = process.env;
const res = await fetch(`${SURGE_MEDIA_API_URL}/projects/${SURGE_MEDIA_PROJECT_ID}/media`, { headers: { Authorization: `Bearer ${SURGE_MEDIA_SECRET_KEY}` },});const { items, nextCursor } = await res.json();The admin’s API documentation page generates this .env snippet for your project (API URL, project ID and publishable key; paste the secret key yourself).
Going to production
Section titled “Going to production”- Your domain and TLS: put SurgeMedia behind your reverse proxy (Nginx, Caddy, Traefik…) on a domain such as
media.your-company.com, and setNUXT_SITE_URLto it. Behind a proxy, setNUXT_TRUST_PROXYso rate limits and audit logs see real client IPs. - A CDN in front of
/m/(optional): public media are served with immutable cache headers. - Backups: back up the database and the media storage together (with Docker, the
/app/datavolume holds both for SQLite and local storage). - Updates:
npm install @surge-media/core@latestthennpx surge-media db migrate, or pull the new Docker image (migrations run at startup).