Deploying
Deploy SystemPrompt to production environments
On this page
This guide covers deploying SystemPrompt to production environments.
Deployment Options
| Option | Best For | Database | Managed By |
|---|---|---|---|
| SystemPrompt Cloud | Production workloads | Managed PostgreSQL | SystemPrompt |
| Self-hosted Docker | Full control | Your PostgreSQL | You |
| Self-hosted Binary | Minimal footprint | Your PostgreSQL | You |
Option 1: SystemPrompt Cloud
The easiest path to production with managed infrastructure.
Prerequisites
- SystemPrompt Cloud account
- CLI installed and logged in
Deploy
# Login if needed
systemprompt cloud auth login
# Create a cloud tenant
systemprompt cloud tenant create --region iad
# Create production profile
systemprompt cloud profile create production
# Deploy
systemprompt cloud deploy --profile production
Your application will be available at https://your-tenant.systemprompt.io.
Custom Domain
Add a CNAME record pointing to your tenant:
docs.yourdomain.com → your-tenant.systemprompt.io
Then configure in the dashboard or CLI:
systemprompt cloud domain add docs.yourdomain.com
Environment Variables
Set production secrets:
systemprompt admin config set-secret anthropic.api_key "sk-..."
systemprompt admin config set-secret openai.api_key "sk-..."
Option 2: Self-hosted Docker
Full control over your infrastructure.
Prerequisites
- Docker and Docker Compose
- PostgreSQL 14+
- Domain with SSL certificate
Docker Compose
Create docker-compose.yml:
version: '3.8'
services:
db:
image: postgres:16
environment:
POSTGRES_DB: systemprompt
POSTGRES_USER: systemprompt
POSTGRES_PASSWORD: ${DB_PASSWORD}
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U systemprompt"]
interval: 5s
timeout: 5s
retries: 5
api:
build: .
environment:
SYSTEMPROMPT_PROFILE: production
DATABASE_URL: postgres://systemprompt:${DB_PASSWORD}@db:5432/systemprompt
ports:
- "3000:3000"
depends_on:
db:
condition: service_healthy
volumes:
- ./services:/app/services:ro
- ./storage:/app/storage
nginx:
image: nginx:alpine
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
- ./certs:/etc/nginx/certs:ro
depends_on:
- api
volumes:
postgres_data:
Dockerfile
FROM rust:1.75 as builder
WORKDIR /app
COPY . .
RUN cargo build --release -p systemprompt-api
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/target/release/systemprompt-api /usr/local/bin/
COPY --from=builder /app/services /app/services
EXPOSE 3000
CMD ["systemprompt-api"]
Nginx Configuration
server {
listen 443 ssl http2;
server_name yourdomain.com;
ssl_certificate /etc/nginx/certs/fullchain.pem;
ssl_certificate_key /etc/nginx/certs/privkey.pem;
location / {
proxy_pass http://api:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Deploy
# Set environment variables
export DB_PASSWORD=your-secure-password
# Start services
docker-compose up -d
# Run migrations
docker-compose exec api systemprompt infra db migrate
# Sync content
docker-compose exec api systemprompt cloud sync local content --direction to-db -y
Option 3: Binary Deployment
For minimal footprint on dedicated servers.
Build
# Build release binary
cargo build --release -p systemprompt-api
# Binary is at target/release/systemprompt-api
Systemd Service
Create /etc/systemd/system/systemprompt.service:
[Unit]
Description=SystemPrompt API
After=network.target postgresql.service
[Service]
Type=simple
User=systemprompt
Group=systemprompt
WorkingDirectory=/opt/systemprompt
ExecStart=/opt/systemprompt/bin/systemprompt-api
Restart=always
RestartSec=5
Environment=SYSTEMPROMPT_PROFILE=production
[Install]
WantedBy=multi-user.target
Enable and start:
sudo systemctl enable systemprompt
sudo systemctl start systemprompt
Production Checklist
Security
- HTTPS enabled with valid SSL certificate
- Database credentials in secrets, not config files
- API keys stored securely
- Firewall configured (only 80/443 exposed)
- Rate limiting enabled
- CORS configured for your domains
Database
- PostgreSQL 14+ running
- Connection pooling configured
- Automatic backups scheduled
- Point-in-time recovery enabled
Monitoring
- Health check endpoint monitored
- Error alerting configured
- Metrics collection enabled
- Log aggregation set up
Performance
- Connection pool sized appropriately
- Static assets cached
- Database indexes verified
- Memory limits configured
Health Checks
SystemPrompt exposes health endpoints:
# Basic health
curl https://yourdomain.com/health
# Detailed status
curl https://yourdomain.com/health/ready
Backup and Recovery
Database Backup
# Manual backup
pg_dump -h localhost -U systemprompt systemprompt > backup.sql
# Automated via cron
0 2 * * * pg_dump -h localhost -U systemprompt systemprompt | gzip > /backups/db-$(date +\%Y\%m\%d).sql.gz
Content Backup
# Export content to files
systemprompt cloud sync local content --direction to-disk -y
# Backup services directory
tar -czf services-backup.tar.gz services/
Next Steps
- Configuration Reference - All config options
- CLI Reference - Management commands
- Troubleshooting - Common issues