Deployment
This guide covers running your Rangka application in production behind a reverse proxy.
1. Build Custom UI (if applicable)
If your project has custom views, fields, or cards, compile them first:
rangka buildThis bundles custom components into .rangka/ with a manifest. If you have no custom UI, skip this step.
2. Environment Variables
Create a .env file or set these in your deployment environment:
# Required
DATABASE_URL=postgres://user:password@host:5432/rangka_prod
# Optional
PORT=3000
LOG_LEVEL=info # debug, info, warn, errorSecurity: Never commit
.envto version control.
3. Start the Server
rangka startThe server scans your project, connects to PostgreSQL, syncs the schema, and starts listening on port 3000.
For process management, use systemd, PM2, or Docker:
systemd unit (/etc/systemd/system/rangka.service):
[Unit]
Description=Rangka ERP
After=network.target postgresql.service
[Service]
Type=simple
User=rangka
WorkingDirectory=/opt/rangka
EnvironmentFile=/opt/rangka/.env
ExecStart=/usr/local/bin/rangka start
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.targetsudo systemctl enable rangka
sudo systemctl start rangkaDocker (Dockerfile):
FROM node:18-alpine
WORKDIR /app
COPY . .
RUN npm ci --production
RUN npx rangka build
EXPOSE 3000
CMD ["npx", "rangka", "start"]4. Reverse Proxy Setup
Put Rangka behind a reverse proxy for TLS termination, compression, and static asset caching.
nginx (/etc/nginx/sites-available/rangka):
upstream rangka {
server 127.0.0.1:3000;
keepalive 64;
}
server {
listen 443 ssl http2;
server_name erp.example.com;
ssl_certificate /etc/letsencrypt/live/erp.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/erp.example.com/privkey.pem;
# API requests
location /api/ {
proxy_pass http://rangka;
proxy_http_version 1.1;
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;
proxy_set_header Connection "";
proxy_read_timeout 120s;
}
# SPA fallback — all other routes serve index.html
location / {
proxy_pass http://rangka;
proxy_http_version 1.1;
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;
proxy_set_header Connection "";
}
client_max_body_size 10m;
gzip on;
gzip_types text/plain application/json application/javascript text/css;
gzip_min_length 1000;
}
server {
listen 80;
server_name erp.example.com;
return 301 https://$host$request_uri;
}Enable the site:
sudo ln -s /etc/nginx/sites-available/rangka /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx5. Production Checklist
Before going live, verify:
- [ ]
DATABASE_URLpoints to the production database - [ ]
rangka buildhas been run (if you have custom UI) - [ ] TLS is configured (never run without HTTPS in production)
- [ ] Process manager restarts the server on crash
- [ ] Backups are configured for the database
- [ ] Log rotation is configured
Common Issues
"No database config found" — Ensure
rangka.config.tsin the project root has database settings.
"Connection refused" on port 3000 — Check that your firewall or reverse proxy is targeting the correct port.
Custom components not loading — Run
rangka buildbeforerangka start. The server serves from.rangka/only if it exists.
Further Reading
- CLI reference — all available commands
- Custom Widgets — building and bundling custom components