- Private CRM: an AI CRM where Claude does the data entry and you make the calls · part 11 of 12
- Rust
- Docker
- CRM
- hosting
Deploying a Rust web app to a VPS with one docker compose command
Private CRM installs and updates with docker compose up -d --build: PostgreSQL, the app, a queue worker and a scheduler, behind Caddy, shipped over rsync.
1 min read
The whole install for Private CRM is one command, and the update is the same command:
docker compose up -d --build
That starts four containers, migrates the database, and creates the admin account on first run. This post covers how the compose file is laid out, what happens on boot, and how code gets to the server.
One image, four containers
The compose file defines the app once as a YAML anchor and starts it three ways, plus PostgreSQL:
x-app: &app
build: .
restart: unless-stopped
env_file: .env
environment:
DB_CONNECTION: postgres
volumes:
- storage:/app/storage
services:
db:
image: postgres:17-alpine
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}']
app:
<<: *app
command: serve
depends_on:
db:
condition: service_healthy
worker:
<<: *app
command: worker
depends_on:
app:
condition: service_healthy
scheduler:
<<: *app
command: scheduler
depends_on:
app:
condition: service_healthy
(Trimmed. The real file also has ports and the app's health check on /up.)
The worker runs queued jobs like CSV imports (part 7). The scheduler runs task reminders every minute and the nightly quiet-deal and overdue-invoice checks (part 9). Both wait for the app to be healthy, which means migrations have already run when they start.
Locally I run SQLite. Here it's PostgreSQL, and the test suite passes on both (part 2 has the one bug that difference caused).
What happens on boot
On every start the app:
- runs any new migrations
- creates the admin from
ADMIN_EMAILandADMIN_PASSWORDif no admin exists yet, and never adds demo data - makes an
APP_KEYon first start and keeps it in the storage volume
That last one removes a step people get wrong. You leave APP_KEY empty in .env, and the key survives rebuilds because it lives in a volume, not in the image.
Data lives in two volumes, pgdata for the database and storage for uploads and the key, so --build never touches it. The guide ends with one warning: docker compose down -v deletes both.
Building Rust on a small VPS
The first build compiles the Rust server and takes 5 to 15 minutes on a small VPS. Later builds reuse the cache and take seconds to a few minutes. The server needs at least 2 GB of RAM, or swap, or the compiler gets killed halfway. If image size bothers you, I covered that in my guide to reducing Docker image size.
Getting code there with rsync
No registry, no CI. An npm script sends the working copy to the server:
npm run rsync:prod
It runs rsync -azP --delete and excludes .git, .env, storage, target, node_modules, build output, tests, the local SQLite database and logs. The useful detail: --delete never removes a file that matches an exclude, so the server's own .env is safe even though the local one isn't sent.
An update is then one line:
npm run rsync:prod && ssh myserver 'cd /var/www/crm && docker compose up -d --build'
My rsync guide covers the flags.
A domain with Caddy
The app binds to 127.0.0.1 on a port of your choice, so the only way in is through the proxy. Caddy needs two lines:
crm.example.com {
reverse_proxy 127.0.0.1:8010
}
Caddy fetches the certificate. Two settings on the app side make it work:
APP_URLmust match the address in the browser. The app only answers requests for that host.TRUSTED_PROXIESset to the Docker network range (172.16.0.0/12) tells the app to believe Caddy when it says the visitor used https.
Https isn't optional here. Browsers only allow push notifications on https or localhost, so push starts working once the certificate is in place. If reverse proxies are new to you, start with self-hosting with a reverse proxy.
Push keys, once
VAPID keys come from the same image:
docker compose run --rm --no-deps app push:keys
Make them once and keep them. New keys cut off every device that already turned notifications on.
Backups and migrations that rewrite data
The guide has two backup commands: a pg_dump piped through gzip for the database, and a tar of the storage volume for uploads and the key. Copy both off the server.
Migrations run on start, which is convenient right up until one rewrites data. The pull request for the agents' feature requests (part 6) included migration 032, which maps old free-text deal sources to a fixed list. Its deploy note said to take a backup first. Every later pull request ends with a "Deploying" section saying which migrations run and what they change.
Two copies on one server
A second folder with a different COMPOSE_PROJECT_NAME, APP_PORT and APP_URL gets its own database and volumes. Handy for a staging copy next to production.
What to take from this
Run your worker and scheduler as separate containers from the same image, gate them on the app's health check, and keep the app key and uploads in a volume. Then make the update command identical to the install command, so there's only one thing to remember. Before trusting it with real data, run through a self-hosted security checklist.
The last part covers the gap checklist and the code review that found leaks no test had caught.
Last updated 4 Dec 2026 · filed under Rust, docker, crm, hosting