Self-hosting

Run Relayit on your own infrastructure with Docker Compose: images, required environment variables, and what differs from Cloud.

Overview

Relayit is source-available under the Business Source License 1.1. You can run it on your own servers for your own use. You may not offer it as a competing hosted notification service. See the LICENSE for the full terms.

A self-hosted install has three Relayit services, and optionally a fourth, plus Postgres, Redis, and S3-compatible storage:

ServiceImageRole
apighcr.io/ted-too/relayit-api:<tag>Public API (/health, POST /messages/email, /send/*, SES notifications), sign-in, and everything the dashboard does.
workerghcr.io/ted-too/relayit-worker:<tag>Background jobs: sending, retries, Domain verification and outbound webhooks. No port. Without it, sends are accepted but never go out.
webghcr.io/ted-too/relayit-web:<tag>The dashboard: static files that call the api from the browser.
template-builderghcr.io/ted-too/relayit-template-builder:<tag>Optional. Internal service for React Email workspace Git operations. Not in the default Compose file.
postgrespostgres:18-alpineDatabase. Postgres 18 or later.
redisredis:7-alpineCache, sessions, and job queues. Redis 7 or later.

You also need an S3-compatible bucket (for example Cloudflare R2, AWS S3, or a Bunny Storage zone) for attachments and template artifacts, and an Amazon SES account that all email goes through.

Run with Docker Compose

Clone the repository and copy the example environment file:

bash
git clone https://github.com/ted-too/relayit.git
cd relayit
cp env.example .env

Fill in .env. At minimum:

bash
IMAGE_TAG=alpha

API_URL=http://localhost:3005
APP_URL=http://localhost:3000

POSTGRES_PASSWORD=your-secure-password
BETTER_AUTH_SECRETS=1:replace-with-output-of-openssl-rand-base64-32

S3_ENDPOINT=https://your-account.r2.cloudflarestorage.com
S3_REGION=auto
S3_BUCKET=relayit
S3_ACCESS_KEY_ID=your-access-key-id
S3_SECRET_ACCESS_KEY=your-secret-access-key

SES_REGIONS=us-east-1
SES_ACCESS_KEY_ID=your-ses-access-key-id
SES_SECRET_ACCESS_KEY=your-ses-secret-access-key

Generate the auth secret with:

bash
openssl rand -base64 32

Start everything:

bash
docker compose pull
docker compose up -d
docker compose ps

Then open:

Sign up in the dashboard, create a Project, and follow the Quickstart using your own API URL instead of https://api.relayit.io.

Environment variables

env.example mirrors what the services validate at startup. Compose passes API_URL to the api, the worker and web, APP_URL to the api, and builds DATABASE_URL from the POSTGRES_* values.

API_URL and APP_URL mean the same thing everywhere: the public URL of the api, and of the dashboard. The dashboard calls the api from the browser with its session cookie, so the two must be the same site: two subdomains of one domain, such as api.your-domain.com and app.your-domain.com, or localhost on two ports. Hostnames on unrelated domains are not supported, and neither are two subdomains of a shared hosting suffix such as *.up.railway.app, which browsers treat as different sites; give both services subdomains of your own domain.

api (required)

VariableDescription
DATABASE_URLPostgres connection string.
REDIS_URLRedis connection string.
API_URLPublic URL of the api. Sign-in lives under it (/auth/*).
APP_URLPublic URL of the dashboard: the only origin allowed to call the api with the session cookie, and where sign-in returns to.
BETTER_AUTH_SECRETSVersioned secrets for auth and for sealing DKIM keys. Format 1:secret, or 2:new,1:old while rotating (the first is current).
SES_REGIONS, SES_ACCESS_KEY_ID, SES_SECRET_ACCESS_KEYThe same as the worker. The api registers new Domains with SES.
S3_ENDPOINT, S3_REGION, S3_BUCKET, S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEYS3-compatible object storage.

Optional: LOG_LEVEL; AUTH_COOKIE_DOMAIN, a parent domain for the session cookie, only if another site of yours on that domain must see that a visitor is signed in. Stripe keys are optional and should be left unset for self-hosting. React Email workspace Git operations also need TEMPLATING_BUILDER_URL and TEMPLATING_BUILDER_SECRET, pointing at a running template-builder. The api applies database migrations when it starts.

worker (required)

VariableDescription
DATABASE_URL, REDIS_URLThe same as the api.
API_URLPublic URL of the api. The worker points SES's notifications (through SNS) at it, and unsubscribe links go to it.
BETTER_AUTH_SECRETSThe same value as the api.
S3_*The same as the api.
SES_REGIONSThe SES regions to send through, comma-separated, for example us-east-1 or eu-central-1,us-east-1. New Domains are registered in the first.
SES_ACCESS_KEY_ID, SES_SECRET_ACCESS_KEYIAM credentials for the SES account.

Optional: LOG_LEVEL, and CF_API_TOKEN, CF_ROOT_DOMAIN, CF_ZONE_ID for a Sandbox Domain on your Cloudflare zone. The worker does not migrate the database; start it after the api, as the Compose file does.

web (required)

VariableDescription
API_URLPublic URL of the api, which the dashboard calls from the browser. Read when the container starts, not built in.

Image tags

TagDescription
alphaAlways the newest alpha release. The Compose default.
1.0.0-alpha.NA specific alpha release. Pin this in production.
mainLatest stable release (not used while Relayit ships alphas).

Release notes are on GitHub Releases.

Production notes

  • Put the api and web behind a reverse proxy with TLS, for example https://api.your-domain.com and https://app.your-domain.com, and set API_URL and APP_URL to those URLs. Forward X-Forwarded-For to the api: sign-in is rate-limited per client address.
  • The api serves HTTP and the worker runs background jobs; scale each by running more replicas of it. Several workers share the queue safely.
  • If sign-in fails from the dashboard, check that the api's APP_URL is the URL you open the dashboard at, that web's API_URL is the api's public URL, and that the two are subdomains of one domain.
  • Check logs with docker compose logs -f api, docker compose logs -f worker and docker compose logs -f web. If sends stay queued, check that the worker is running.

How self-hosted differs from Cloud

  • No Plans, unlimited entitlements. Without Stripe keys, every user gets unlimited Projects, Domains, retention, and sends.
  • Email and password sign-in. Social sign-in is not set up by default.
  • Your own SES account. Email goes through the SES account in SES_*. When the worker starts it creates the SES configuration set and SNS topic each region needs and subscribes API_URL to it, so the IAM user needs SES and SNS permissions.
  • No Sandbox Domain by default. It exists only if you give the worker a Cloudflare zone for it (CF_*).
  • Template workspace is optional. Without a template-builder service, sending with existing Templates works, but editing the React Email workspace does not.

Everything else, including the API, Domains, Templates, and suppression, works the same as on Cloud.