Docker Compose
The repo has three Compose files at its root:
| File | Services | For |
|---|---|---|
docker-compose.single.yml | postgres (16), virvi | One server. No Redis. |
docker-compose.scalable.yml | postgres (16), redis (7), virvi | Several Virvi containers sharing Redis. |
docker-compose.dev.yml | postgres (16), redis (7), minio | Local development. Runs no Virvi server. |
The virvi service builds the root Dockerfile (Node 20, Alpine). The image holds the API server, the dashboard, these docs and FFmpeg.
Single mode
Run every command from the repo root.
1. Get the code
git clone https://github.com/virvi-xr/virvi.gitcd virvi2. Write .env
Docker Compose reads .env in the repo root to fill in the Compose file. Single mode uses these four:
cat > .env <<EOFJWT_SECRET=$(openssl rand -hex 32)POSTGRES_PASSWORD=$(openssl rand -hex 16)PUBLIC_URL=http://localhost:3010PORT=3010EOF| Variable | Needed | Used for |
|---|---|---|
JWT_SECRET | Yes. Compose stops with Set JWT_SECRET in .env without it | Signing sign-in tokens |
POSTGRES_PASSWORD | No (default vlm_prod). Set your own | The vlm database user’s password |
PUBLIC_URL | No (default http://localhost:3010) | The address people use to reach the server |
PORT | No (default 3010) | The port on the host. The container always listens on 3010 |
Set POSTGRES_PASSWORD before the first start. Postgres keeps the password it was created with; changing it later breaks the connection.
3. Start
docker compose -f docker-compose.single.yml up -d --buildThe first build takes several minutes. On start, the container syncs the database schema, then starts the server.
4. Check it
curl -s http://localhost:3010/api/healthA healthy server answers 200 with "status":"ok" and "postgres":"ok". See Updating and Troubleshooting if not.
5. Create the admin account
Open http://localhost:3010 and sign up. The first account on a new install becomes its instance admin. Do this straight away on a public server: whoever signs up first gets admin.
What the single file sets up
postgres: databasevlm, uservlm, data in thepgdatavolume. Port 5432 is published on127.0.0.1only, for tools on the same machine.virvi:VIRVI_MODE=single,STORAGE_PROVIDER=local, uploads in theuploadsvolume (/app/uploads) and private import files in theprivatevolume (/app/private).
Your own domain
Two things change when people reach the server at a real address, such as https://virvi.example.com.
1. The dashboard’s addresses are built into the image. The Compose files build it with PUBLIC_URL from .env as its API address. Add its WebSocket address to .env too, then rebuild:
PUBLIC_URL=https://virvi.example.comNEXT_PUBLIC_WSS_URL=wss://virvi.example.comdocker compose -f docker-compose.single.yml up -d --buildRebuild whenever you change either one.
2. The server needs its public address and the proxy count. Set PUBLIC_URL=https://virvi.example.com in .env, and set TRUST_PROXY_HOPS for your proxy (see below).
Put a reverse proxy (Caddy, nginx, Traefik) in front for HTTPS. It must pass WebSocket upgrades: real-time sync runs on the same port as the API. With Caddy, reverse_proxy localhost:3010 does both.
Adding more variables
Every line of .env reaches the server (the Compose files load it with env_file). To set more (SMTP, OAuth, TRUST_PROXY_HOPS and so on), add them to .env:
TRUST_PROXY_HOPS=1SMTP_HOST=smtp.example.comEMAIL_FROM=noreply@example.comThe values under the virvi service’s environment: (mode, database, storage paths) win over .env. The full list is in Environment Variables.
Then apply it:
docker compose -f docker-compose.single.yml up -dScalable mode
docker-compose.scalable.yml runs two Virvi servers, virvi-1 and virvi-2, with Postgres, Redis and a Caddy proxy in front of them on host port ${PORT:-3010}. Redis (REDIS_URL=redis://redis:6379) shares real-time rooms between the servers. It has no password, so its port 6379 is published on 127.0.0.1 only.
docker compose -f docker-compose.scalable.yml up -d --buildHow requests reach the servers. A real-time room lives on one server, so a visitor has to reach that server. Each server has its own path, set by ROOM_SERVER_PATH (/n1, /n2). It tells visitors that path when they join a room, and Caddy sends that path to that server only. Everything else (the dashboard, the API, joining a room) can go to either server, and Caddy takes turns between them. The routes are in deploy/caddy/Caddyfile.scalable.
docker compose up --scale doesn’t work with this file, because each server needs its own path. To add a server:
- In the Compose file, copy the
virvi-2service asvirvi-3, withROOM_SERVER_PATH: /n3. - In
deploy/caddy/Caddyfile.scalable, add ahandle_path /n3/*block forvirvi-3:3010, and addvirvi-3:3010to the sharedreverse_proxyline. - Run
docker compose -f docker-compose.scalable.yml up -d.
HTTPS. Caddy serves plain HTTP on the published port. Either put your HTTPS proxy in front of it and set TRUST_PROXY_HOPS=2 in .env (your proxy and Caddy), or give Caddy your domain in place of :80 so it gets a certificate itself, and publish ports 80 and 443. With Caddy alone in front, keep the default TRUST_PROXY_HOPS=1.
If your servers aren’t all behind one address, set COLYSEUS_PUBLIC_ADDRESS on each instead, to the host (and path) where visitors reach that server, such as rooms-1.example.com.
Other things to know:
- All containers share the
uploadsvolume, so local storage works only while they run on one Docker host. Across hosts, useSTORAGE_PROVIDER=s3orr2. - Scene imports need
SCENE_IMPORT_S3_URIin scalable mode; the scalable file has no private volume. /metricsis served only withMETRICS_TOKENset, and a scraper must send it asAuthorization: Bearer <token>.- Every server syncs the database schema when it starts.
virvi-2waits untilvirvi-1is healthy, so they don’t sync at the same time.
Live streaming
Live streaming needs the separate media server in apps/streaming (RTMP in, HLS out). It isn’t in the Compose files.
Build and run it:
docker build -f apps/streaming/Dockerfile -t virvi-streaming .docker run -d --name virvi-streaming \ -p 1935:1935 -p 8000:8000 \ -e VIRVI_API_URL=http://<virvi-server-host>:3010 \ -e VIRVI_WEBHOOK_KEY=<shared-secret> \ -v virvi-streams:/data/streams \ virvi-streaming| Media server variable | Default | What it does |
|---|---|---|
VIRVI_API_URL | http://localhost:3010 | The Virvi server it checks stream keys with |
VIRVI_WEBHOOK_KEY | none | Shared secret; must equal the server’s STREAMING_WEBHOOK_KEY |
RTMP_PORT | 1935 | RTMP ingest port |
HTTP_PORT | 8000 | HLS playback port (/streams/<playbackId>/playlist.m3u8) |
OUTPUT_DIR | /data/streams in the image | Where HLS segments are written |
MAX_STREAMS | 4 | Most streams transcoded at once |
ENABLE_ABR | off | true transcodes several qualities |
FFMPEG_PATH | ffmpeg | FFmpeg binary (included in the image) |
Then set on the Virvi server: ENABLE_STREAMING=true, STREAMING_WEBHOOK_KEY (the same secret), RTMP_INGEST_URL (for example rtmp://stream.example.com:1935/live) and HLS_BASE_URL (for example https://stream.example.com/streams, behind HTTPS).
Development
docker-compose.dev.yml starts Postgres (user and password vlm / vlm_dev), Redis and MinIO (console on port 9001, vlm_dev / vlm_dev_secret). Run the server and dashboard yourself: see Quickstart.
docker compose -f docker-compose.dev.yml up -dStop and remove
docker compose -f docker-compose.single.yml down # stop; data volumes staydocker compose -f docker-compose.single.yml down -v # stop and DELETE the database and uploads