How to self-host Comp AI CRM, the CRM built for AI agents, on a VPS
Updated 11/29/2026
Comp AI CRM is an open-source (MIT) CRM built around an AI agent: the agent researches contacts and companies, fills in the records and keeps them current, and people work on top of what it prepared. The project is designed for Vercel but runs on your own server too. We do not offer it as a one-click app for a simple reason: sign-in works exclusively through Google or Microsoft, and only you can create that OAuth app, in your own account. Without it there is no way in. The guide below does the install by hand, step by step.
What you need
- A cloud server with Ubuntu 24.04 and at least 4 GB RAM. Building the Next.js app is the heaviest part.
- A domain with two subdomains pointing at the server's IP:
crm.example.comfor the app andapi.crm.example.comfor the API. - An OAuth client in Google Cloud Console (or an app registration in Microsoft Entra ID), with the redirect URI
https://api.crm.example.com/api/auth/callback/google. - A Vercel AI Gateway key for the agent's model. Without it the CRM works, but the agent researches nothing.
1. Tools on the server
apt-get update && apt-get install -y git curl unzip
curl -fsSL https://get.docker.com | sh
curl -fsSL https://deb.nodesource.com/setup_24.x | bash - && apt-get install -y nodejs
curl -fsSL https://bun.sh/install | bash
export PATH="$HOME/.bun/bin:$PATH"
2. Code and database
The repository's docker-compose.yml starts PostgreSQL. Before that, bind the port to loopback only, so the database is not reachable from the internet.
git clone https://github.com/trycompai/crm.git /opt/crm
cd /opt/crm
sed -i 's|"5432:5432"|"127.0.0.1:5432:5432"|' docker-compose.yml
docker compose up -d
cp .env.example .env
3. Configuration
Open .env and fill in at least these values. The session secret is shared by the API and the app; if they differ you get a redirect loop, not an error.
BETTER_AUTH_SECRET=$(openssl rand -base64 32)
ALLOWED_SIGN_IN="example.com"
GOOGLE_CLIENT_ID="..."
GOOGLE_CLIENT_SECRET="..."
API_URL="https://api.crm.example.com"
APP_URL="https://crm.example.com"
AUTH_COOKIE_DOMAIN=".crm.example.com"
AGENT_URL="http://127.0.0.1:2000"
AI_GATEWAY_API_KEY="..."
ALLOWED_SIGN_IN is the entire authorisation model: an email domain admits everyone at that domain, a single address admits one person. The optional variables (Perplexity for web search, Slack, a cron secret) are described in the same file.
4. Build
cd /opt/crm
bun install
bun run db:deploy
bun run build
The db:deploy command applies the Prisma migrations to the database in the container. The build takes a few minutes and compiles the three parts: the web app, the NestJS API and the agent.
5. Three systemd services
The app listens on 3000, the API on 3001 and the agent on 2000. One service each, sharing the same .env:
for svc in app:apps/app:"/root/.bun/bin/bun run start" api:apps/api:"/root/.bun/bin/bun dist/main.js" agent:apps/agent:"/root/.bun/bin/bun run start"; do
name=${svc%%:*}; rest=${svc#*:}; dir=${rest%%:*}; cmd=${rest#*:}
cat > /etc/systemd/system/crm-$name.service <<UNIT
[Unit]
Description=Comp AI CRM $name
After=network.target docker.service
[Service]
EnvironmentFile=/opt/crm/.env
WorkingDirectory=/opt/crm/$dir
ExecStart=$cmd
Restart=always
[Install]
WantedBy=multi-user.target
UNIT
done
systemctl daemon-reload
systemctl enable --now crm-api crm-app crm-agent
6. HTTPS with Caddy
apt-get install -y caddy
cat > /etc/caddy/Caddyfile <<'CADDY'
crm.example.com {
reverse_proxy 127.0.0.1:3000
}
api.crm.example.com {
reverse_proxy 127.0.0.1:3001
}
CADDY
systemctl restart caddy
Open https://crm.example.com and sign in with the allowed Google account. If the page keeps sending you back to sign-in, check BETTER_AUTH_SECRET, AUTH_COOKIE_DOMAIN and the redirect URI in Google.
7. Mailbox sync
The CRM reads the reps' email through the same OAuth client. Set CRON_SECRET in .env and add a cron job that periodically calls POST /internal/sync/mailboxes on the API with that secret, exactly as the project README describes.
Worth knowing
- The agent runs on a model reached through the Vercel AI Gateway. The model is chosen on the app's settings page, not through a variable.
- Updates are
git pull,bun install,bun run db:deploy,bun run buildand a restart of the three services. - For a classic CRM without an agent and without external dependencies, the catalog has one-click alternatives such as Odoo or ERPNext.
Put this guide into practice on your own VPS
EU cloud servers, billed hourly, ready in minutes, with one-click installs for dozens of apps.
See pricingRelated tutorials
Error tracking for your applications with GlitchTip
Catch production exceptions with the Sentry SDKs on a small server: the project, the DSN, alerts and uptime.
Updated 11/29/2026Dev environmentsTest your application's email with smtp4dev
Send the email from Laravel, WordPress, Node or Python to a test SMTP server and read it in a web inbox, without it ever reaching real customers.
Updated 11/29/2026Dev environmentsHow to set up a staging environment
Test changes on a copy of production before shipping them, to avoid surprises.
Updated 11/29/2026