Skip to content

Deployment

The supported production layout is one API process, one WhatsApp/BullMQ worker, MongoDB, and Redis. The included Compose stack implements that topology.

v1.0.1 was released on 2026-12-05 and the container image is published at ghcr.io/leviro/relay:1.0.1 (docker pull ghcr.io/leviro/relay:1.0.1). The Compose commands below still build the image locally as leviro-relay:local — the shipped compose.yaml builds locally and the repo documents no GHCR-based Compose procedure.

  • Docker Engine and Docker Compose v2, or Node.js 24+ with independently managed MongoDB/Redis
  • At least 2 GB RAM for a small installation; media processing may require more
  • Persistent storage for MongoDB, Redis, uploads, and logs
  • Outbound HTTPS/WebSocket access to WhatsApp services
  • A TLS reverse proxy for any internet-facing deployment

Node.js 24 LTS is used by the production image. The runtime also includes FFmpeg/FFprobe for media conversion and dumb-init for correct signal handling.

Service Published port Persistent data
api 127.0.0.1:${APP_PORT:-3000} (localhost only) state named volume at /app/state
worker None the same state volume, same path
mongodb None mongodb named volume
redis None redis named volume with AOF enabled

One volume holds everything the application writes, mounted into both containers at the same path: /app/state/data, /app/state/uploads, /app/state/gallery, /app/state/logs. Sharing it is not a convenience — the API accepts an upload and the worker sends it, and backups run in the worker and read gallery/.

MongoDB and Redis run with no authentication in the Compose file, which is only safe because they are reachable solely over the private Compose network and publish no ports. Do not publish their ports (even on 127.0.0.1) without adding authentication first.

Terminal window
git clone https://github.com/leviro/relay.git
cd relay
docker compose up -d --build
docker compose ps
docker compose logs --tail=100 api worker

The image runs as the unprivileged node user, drops Linux capabilities, and uses a one-minute shutdown grace period so an active BullMQ job can finish.

Terminate TLS in nginx, Caddy, Traefik, or an equivalent proxy. The proxy must forward Host, X-Forwarded-For, and X-Forwarded-Proto, support HTTP/1.1 upgrades for Socket.IO, permit request bodies up to MAX_FILE_SIZE_MB, and use timeouts long enough for large media uploads.

location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
client_max_body_size 50m;
proxy_read_timeout 120s;
}

Set TRUST_PROXY only to the actual proxy hop count or trusted CIDRs. An overly broad value allows clients to spoof addresses used by rate limiting. HTTPS is also required for service-worker registration and PWA installation on non-localhost origins.

Terminal window
git clone https://github.com/leviro/relay.git
cd relay
cp .env.example .env
npm ci
npm run build
WORKER_MODE=separate node src/index.js
WORKER_MODE=separate node src/worker.js

For a small installation, one process can host both roles: WORKER_MODE=single node src/index.js. Do not launch src/worker.js alongside it.

  1. Back up MongoDB and the state volume.
  2. Review release notes and .env.example changes.
  3. Pull the new source.
  4. Rebuild and recreate application containers:
Terminal window
docker compose build --pull
docker compose up -d
docker compose ps
docker compose logs --tail=100 api worker

The worker drains its active message during graceful shutdown. Avoid forcing a container kill unless it is genuinely stuck.

Monitor API health and HTTP availability, worker restarts and WhatsApp connection state, MongoDB/Redis health and disk usage, failed BullMQ jobs and campaign failure rate, state volume capacity, and repeated login failures.

Terminal window
docker compose ps
docker compose logs --since=30m api worker
docker compose top
docker stats
  • Run exactly one worker for each WhatsApp account/session.
  • Do not horizontally scale workers against the same MongoDB auth records.
  • API replicas require deliberate Socket.IO routing; the provided Compose file intentionally runs one API replica.

v1.0.1 was released on 2026-12-05: tag v1.0.1 (commit 0fe673a), GitHub Release, and a public GHCR image ghcr.io/leviro/relay:1.0.1 (digest sha256:f1f374c6a0fd0a7cf9220eb80559ac410263f2a0476595f7d9f1006d8e11a2b3), also tagged 1.0, latest, and sha-0fe673ac7941ed75727353708724af50310b44b3. The release mechanics below are how that image was produced.

When a v* tag is pushed, the release workflow builds the container image once, verifies it against a real MongoDB and Redis, and publishes that same image to GHCR (ghcr.io/leviro/relay) — one build, tagged and pushed, never rebuilt at publish time — with the exact version, major.minor, sha-<full sha>, and latest (stable + highest stable only) tags. A workflow_dispatch run is the dry run: it builds and verifies and publishes nothing. See docs/RELEASING.md in the Relay repository for versioning, tags, and identifying the exact image a container is running. A GitHub Release object was created for v1.0.1; no deployment is automated by any workflow.