A self-hosted CRM in one container.
Revenue Engine ships as a single Docker image that serves the API and the web app. Point it at a PostgreSQL database and you have a private CRM.
What you need.
- PostgreSQL 13 or newer, reached as an ordinary database role (see below).
- A container host: Fly.io, a virtual server, Kubernetes or anything else that runs a Docker image. The image is built for linux/amd64.
- HTTPS in front of the app. The session cookie is marked Secure.
- Optionally, SMTP for email, S3-compatible storage for attachments, and an Anthropic API key for Ask AI.
Try it on your machine.
git clone https://github.com/sirdab/revenue-engine.git
cd revenue-engine
cp .env.example .env # then set SESSION_SECRET (openssl rand -hex 32)
docker compose --profile app up -d --build
# open http://localhost:8080 and create a workspace
This Compose profile is a try-out, not a deployment: mail goes to a local inbox with no login, and files are stored with default credentials. On Apple silicon, build the image on an amd64 machine or run pnpm dev instead.
The one database rule.
Workspaces are kept apart by PostgreSQL row-level security. Superusers and roles with BYPASSRLS skip it entirely, so the app must connect as an ordinary role. The admin user of a managed database is often not one.
CREATE ROLE crm_app LOGIN PASSWORD '<long random password>' NOSUPERUSER NOBYPASSRLS;
GRANT crm_app TO CURRENT_USER;
CREATE DATABASE crm OWNER crm_app;
Connect to PostgreSQL directly, not through a transaction-mode pooler such as PgBouncer. The app marks each connection with its workspace for the length of a session, and transaction pooling does not preserve that.
Run it.
docker build -t revenue-engine .
docker run -p 8080:8080 --env-file .env revenue-engine \
sh -c "node dist/migrate.mjs && exec node --enable-source-maps dist/index.mjs"
The migrations are inside the image and are safe to run on every start. Several containers can serve at once, because all state lives in PostgreSQL.
| Variable | What it is for |
|---|---|
DATABASE_URL | Required. Connection string for the ordinary database role. |
SESSION_SECRET | Required. A long random string that signs the session cookie. |
PORT | Required. The port the server listens on; the image expects 8080. |
APP_BASE_URL | The public URL, used in emails, Slack messages, canonical links and the sitemap. |
SMTP_HOST, SMTP_PORT, SMTP_USER, SMTP_PASSWORD, MAIL_FROM | Optional. Email for password resets and notifications. |
S3_ENDPOINT, S3_BUCKET_NAME, S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY | Optional. S3-compatible storage for attachments. |
ANTHROPIC_API_KEY | Optional. Turns on Ask AI. |
Deploy on Fly.io.
Create the database
Create a Managed Postgres cluster, then a database and a user for the app. Use the cluster's direct address, not the pooled one.
Create the app and its secrets
Set
DATABASE_URL,SESSION_SECRETandAPP_BASE_URLwithfly secrets set.Deploy
fly deploy --remote-onlybuilds the image and runs the migrations as a release command before any machine is updated.
Every command, in order, is in DEPLOY.md.
Before you go live.
- The database role is not a superuser and does not have
BYPASSRLS. SESSION_SECRETis long, random and different in every environment.- HTTPS is in front of the app, and
APP_BASE_URLis its public URL. - Database backups are switched on.
- The demo seed never runs against a real database: it deletes every workspace.
Self-hosting questions.
What does it cost to run?
The software is free. You pay only for the server and the database you run it on.
Does it scale past one server?
Yes. The server holds no state of its own: run several containers behind a load balancer and they share one database.
How do upgrades work?
Pull the new image and start it. The migrations run first and skip whatever is already applied.
Can I use a managed PostgreSQL service?
Yes. Create the application role as shown above, and connect directly rather than through a transaction-mode pooler.
Put your pipeline to work.
Create a workspace in under a minute. Bring the team in when you are ready.