Mendloop Docs Request access

Deploy on one small server

One 2 vCPU / 4 GB server running Postgres, Redis, Mendloop, the web app and Caddy for HTTPS.

One server runs Postgres, Redis, the three Mendloop processes, the web app and Caddy (HTTPS). It is sized for 2 vCPU / 4 GB, such as a 4 GB AWS Lightsail plan or a GCP e2-medium.

How requests are routedText
                             ┌─ /api/<id>/envelope, /api/<id>/store ─┐
                             │  /v1/events, /hooks/*                 ├─► ingest
https://app.example.com ─► Caddy                                     │
                             ├─ /api/*, /v1/*, /healthz, /readyz ────┴─► api
                             └─ everything else ───────────────────────► web

                                worker: events, workflows, RCA, jobs
                                Postgres 16 + pgvector, Redis 7: private, never exposed

One domain serves both the web app and the API, so there is no CORS setup and sign-in cookies just work.

1. Create the server#

On AWS Lightsail, for example:

  1. Create instance → Linux/Unix → OS only: Ubuntu 24.04 → the 4 GB plan. Pick the region nearest your users.
  2. Networking → Create static IP and attach it.
  3. Networking → IPv4 firewall: allow HTTP 80 and HTTPS 443. Keep SSH 22, restricted to your IP if you can.
  4. Snapshots → Enable automatic snapshots (daily).

2. Point the domain at it#

Add an A record, for example app → the static IP. If you use Cloudflare, set Proxy status: DNS only (grey cloud): Caddy gets its own Let's Encrypt certificate, which needs the server reachable directly on ports 80 and 443.

Or keep Cloudflare in front#

If Cloudflare should proxy the site and serve the public certificate (orange cloud):

  1. Cloudflare → SSL/TLS → Overview: mode Full (strict).
  2. SSL/TLS → Origin Server → Create Certificate for your hostname. Save the certificate as deploy/compose/certs/origin.pem and the private key as deploy/compose/certs/origin.key on the server (chmod 600 the key; the folder is git-ignored).
  3. Add CADDYFILE=Caddyfile.cloudflare to .env.production.
  4. Set the DNS record to Proxied.

3. Get the code onto the server#

SSH in. The repository is private, so use a read-only deploy key:

On the serverShell
ssh-keygen -t ed25519 -f ~/.ssh/mendloop_deploy -N ""
cat ~/.ssh/mendloop_deploy.pub     # add it on GitHub: repository → Settings → Deploy keys (read only)
printf 'Host github.com\n  IdentityFile ~/.ssh/mendloop_deploy\n' >> ~/.ssh/config
git clone <the repository's SSH URL> mendloop && cd mendloop

4. Start it#

On the serverShell
sudo ./scripts/deploy-server.sh app.example.com

The script installs Docker, tunes the host, adds 4 GB of swap, writes .env.production with fresh keys, builds the images (the first build takes 5 to 15 minutes), starts everything, runs the migrations, and asks for the first Super Admin. Then open https://app.example.com and sign in.

It is safe to re-run: host files are written only when their content differs. If the Docker daemon's settings changed, the script prints an ACTION NEEDED block instead of restarting Docker itself, because that stops every container for a few seconds. Pick the moment, then run sudo systemctl restart docker.

Danger:

Back up .env.production now, in a password manager for example. Losing MENDLOOP_MASTER_KEY makes every encrypted value unreadable: integration tokens, model keys, member emails.

5. Settings worth changing#

Setting Why
SMTP_URL, MAIL_FROM Sign-in links and invites. Amazon SES or any SMTP provider. Password sign-in works without it.
MENDLOOP_SIGNUP invite-only (the default here) so strangers can't sign up.
SANDBOX_DRIVER ci-only (the default here): your GitHub CI verifies fixes. docker needs more memory.
SENTRY_DSN, SENTRY_DSN_WEB Report Mendloop's own errors to Sentry. Events are scrubbed first: no users, cookies, request bodies, emails or tokens. Rebuild after setting SENTRY_DSN_WEB.
MENDLOOP_EMBEDDINGS off saves about 100 MB of memory if you don't need semantic dedupe.
SENTRY_TRACES_SAMPLE_RATE 0.05 on a small server.

After a change:

On the serverShell
sudo docker compose --env-file .env.production -f deploy/compose/docker-compose.prod.yml up -d

More settings are in Configuration.

Day to day#

On the serverShell
C="sudo docker compose --env-file .env.production -f deploy/compose/docker-compose.prod.yml"
$C ps                       # all seven services; the worker shows no health status on purpose
$C logs -f api              # dashboard requests
$C logs -f ingest           # incoming errors and webhooks
$C logs -f worker           # events, RCA, workflows, jobs
$C restart worker           # safe: unacknowledged events are re-read from Redis
docker stats --no-stream    # memory against the caps

Backups#

  • Automatic snapshots of the server (step 1) cover the whole disk.
  • A database dump you can copy off the server:
On the serverShell
sudo docker compose --env-file .env.production -f deploy/compose/docker-compose.prod.yml exec -T postgres \
  pg_dump -U mendloop mendloop | gzip > mendloop-$(date +%F).sql.gz

Costs#

Item Per month (approximate; check your provider's pricing)
Lightsail 4 GB (IP, disk and transfer included) about $24
Snapshots under $1
AI models your provider key, billed by the provider

Troubleshooting#

Problem Fix
The browser says the certificate is invalid DNS must point at the server with DNS only (grey cloud), ports 80 and 443 open. Check logs caddy.
The build is killed or very slow Check swap with swapon --show. The script adds 4 GB.
502 from Caddy A backend is restarting or unhealthy: ps, then logs api, logs ingest or logs caddy.
A container keeps restarting with exit code 137 It hit its memory cap. docker stats shows which; raise that service's limit in docker-compose.prod.yml and take the memory from another, or move to a bigger machine. The worker is killed first on purpose.
Background work stopped (no RCA, no new issues) logs worker. The worker has no healthcheck, so ps won't tell you. A growing XLEN ml:events is the signal.
Errors arrive but nothing appears in the dashboard Ingest accepted them (logs ingest) but the worker isn't consuming: logs worker and XINFO GROUPS ml:events.
Sign-in works but pages show an API error MENDLOOP_BASE_URL must be exactly https://<your domain>; rebuild the web image after changing it.
Errors from SDKs don't arrive Use the DSN shown in Settings → Projects; it points at https://<your domain>/<project number>.