BetterRewardsDocs
Open app
Browse guides

Deploy with Docker

Run betterrewards on your own server with docker compose: database, background jobs and HTTPS included.

6 min read · For companies

Docker is the reference way to run betterrewards. One command starts everything it needs on a single server: the web app, a background worker, a PostgreSQL database and, optionally, a web server that gets HTTPS certificates for you. Plan for about 30 minutes the first time.

You needNotes
A Linux serverAny VPS provider works. Ubuntu 24.04, 2 GB of memory or more (building the image needs it), 20 GB of disk. Usually around USD 5 to 10 a month.
A domain nameFor example rewards.example.com for the dashboard. You need to be able to add DNS records.
A way to send emailPeople sign in with a link sent by email. Any SMTP provider, or a Resend account (resend.com).
A Stripe accountConnected after the first sign-in, from the admin. Not needed to install.

Just want to look around first? Do the local trial below on your own computer. It needs only Docker Desktop, and no domain, email provider or Stripe account.

Try it on your computer

Install Docker Desktop, then run in a terminal:

git clone https://github.com/betterrewards/betterrewards.git
cd betterrewards
cp .env.example .env

Open .env in a text editor and set these lines:

AUTH_SECRET=<paste the output of: openssl rand -base64 32>
EMAIL_FROM=Rewards <rewards@example.com>
SMTP_HOST=mailpit
SMTP_PORT=1025
docker compose --profile dev-mail up -d
docker compose exec worker node worker/index.mjs create-owner you@example.com

The first start builds the image and takes a few minutes. Then open http://localhost:3000, enter the email you made owner, and open the sign-in email in the built-in test inbox at http://localhost:8025. No email leaves your computer in this mode.

1. Prepare the server

Create the server at your provider and connect to it with SSH (ssh root@<server IP>). Install Docker with its official script, and git:

curl -fsSL https://get.docker.com | sh
apt-get install -y git
docker compose version     # prints a version: Docker is ready

If your provider has a firewall, allow ports 22 (SSH), 80 and 443 (web). Nothing else needs to be open: the app and the database only listen inside the server.

Server with 1 GB of memory? Add swap before building, or the build stops with exit code 137: fallocate -l 2G /swapfile && chmod 600 /swapfile && mkswap /swapfile && swapon /swapfile

2. Point your domain at the server

At your DNS provider, add an A record for the dashboard host (for example rewards) with the server's IP address. If you plan short links such as go.example.com/anna, add a record for that host too. Check with ping rewards.example.com: it should answer from the server's IP. This can take a few minutes.

On Cloudflare DNS, set these records to DNS only (grey cloud) so the server can get its own certificate.

3. Configure

git clone https://github.com/betterrewards/betterrewards.git
cd betterrewards
cp .env.example .env
openssl rand -base64 32      # copy the output for AUTH_SECRET
nano .env

Set these values. Everything else in the file can stay as it is.

SettingValue
APP_URLhttps://rewards.example.com (your dashboard address, with https://)
AUTH_SECRETThe random value you just generated. Keep a copy somewhere safe (see Back up).
EMAIL_FROMRewards <rewards@example.com>, on a domain your email provider allows
SMTP_HOST, SMTP_PORT, SMTP_USER, SMTP_PASSWORDFrom your SMTP provider. Or set EMAIL_TRANSPORT=resend and RESEND_API_KEY instead.
CADDY_SITESrewards.example.com, or rewards.example.com, go.example.com with short links
TRACKING_DOMAINgo.example.com, only if you use short links
TRUST_PROXYtrue (the bundled web server, Caddy, sits in front of the app)
POSTGRES_PASSWORDOptional: any long random value instead of the default

Stripe keys can stay empty: you connect Stripe from the admin after signing in, and the key is stored encrypted.

4. Start

docker compose --profile https up -d
docker compose ps            # app, worker, postgres and caddy: running or healthy

The first start builds the image (a few minutes), creates the database tables, then starts everything. The https profile adds Caddy, which fetches certificates for the hosts in CADDY_SITES.

5. Make yourself the owner

docker compose exec worker node worker/index.mjs create-owner you@example.com

Open https://rewards.example.com, enter that email and click the link you receive. You land in the setup wizard: company details, Stripe, your first program and the tracking snippet. The Getting started guide for product owners explains each step.

Everyone else who signs in becomes a partner, unless you add them to your team as an admin (Settings → Team). To hand ownership over later: create-owner other@example.com --replace.

Check that it works

  • The dashboard opens over https with a valid certificate.
  • The sign-in email arrives within a minute, in the inbox. If it lands in spam, set up SPF and DKIM for your sending domain at your email provider.
  • docker compose logs worker shows no repeated errors. The worker runs background jobs: approving commissions, emails, payout batches, webhook retries.
  • Integrations → Tracking & links: the tracking check turns green once the snippet is on your site.

Update to a new version

cd betterrewards
git pull
docker compose --profile https up -d --build

Database changes are applied automatically before the app restarts. Read the changelog before updating.

Back up

Two things matter: the database and the .env file. Without the same AUTH_SECRET, saved Stripe keys and partner payout details cannot be decrypted, even from a good database backup.

# A database dump, e.g. daily from cron. Copy it off the server.
docker compose exec -T postgres pg_dump -U betterrewards betterrewards | gzip > backup-$(date +%F).sql.gz

# Restore: stop the app, empty the database, load the dump, start again.
docker compose stop app worker
docker compose exec -T postgres dropdb -U betterrewards betterrewards
docker compose exec -T postgres createdb -U betterrewards betterrewards
gunzip -c backup-2026-11-26.sql.gz | docker compose exec -T postgres psql -U betterrewards betterrewards
docker compose --profile https up -d

Troubleshooting

What you seeWhat to do
required variable AUTH_SECRET (or EMAIL_FROM) is missingSet it in .env, in the betterrewards folder, then run the command again.
Build stops with exit code 137The server ran out of memory. Add swap (see step 1) and run again.
The browser cannot connect, or shows a certificate warningCheck that DNS points at the server, ports 80 and 443 are open, and CADDY_SITES lists the host. docker compose logs caddy shows why a certificate failed.
http://<server IP>:3000 does not openOn purpose: the app only listens inside the server, so all traffic goes through Caddy and HTTPS. Use your domain. If your proxy runs on another machine, set APP_BIND=0.0.0.0.
No sign-in emaildocker compose logs app shows the error from the email provider. Check SMTP_HOST, SMTP_PORT (587, or 465 with SMTP_SECURE=true), the user and password, and that EMAIL_FROM is a sender the provider allows.
The email link opens localhost or the wrong addressAPP_URL is wrong. Fix it in .env and run docker compose --profile https up -d.
The app keeps restartingdocker compose logs app prints the invalid setting at the top, for example a mistyped value.