Deployment
Docker Compose (Recommended)
Section titled “Docker Compose (Recommended)”The generated project includes a Dockerfile and docker-compose.yml. This is the simplest way to deploy:
services: postgres: image: postgres:16-alpine environment: POSTGRES_USER: rebase POSTGRES_PASSWORD: rebase POSTGRES_DB: rebase volumes: - pgdata:/var/lib/postgresql/data ports: - "5432:5432"
app: build: ./backend ports: - "3001:3001" environment: DATABASE_URL: postgresql://rebase:rebase@postgres:5432/rebase JWT_SECRET: ${JWT_SECRET} NODE_ENV: production depends_on: - postgres volumes: - uploads:/app/uploads
volumes: pgdata: uploads:docker compose up -dProduction Checklist
Section titled “Production Checklist”Before deploying to production, ensure:
| Item | Details |
|---|---|
| JWT_SECRET | Use a cryptographically strong random string (≥ 32 chars). Never reuse across environments. |
| DATABASE_URL | Use a managed Postgres instance (Neon, Supabase, RDS) with TLS enabled |
| CORS | Configure allowed origins on your backend if frontend and backend are on different domains |
| Storage volumes | Mount persistent volumes for file uploads. Or switch to S3 for production. |
| HTTPS | Terminate TLS at your reverse proxy (nginx, Cloudflare, load balancer) |
| Registration | Set ALLOW_REGISTRATION=false after creating your admin account |
Serving the Frontend
Section titled “Serving the Frontend”In production, the backend can serve the frontend as a static SPA:
import { serveSPA } from "@rebasepro/backend";
// After initializeRebaseBackend()serveSPA(app, "./frontend/dist");Build the frontend first:
cd frontend && pnpm buildThis way you only need to deploy one server that handles both SPA and API.
Cloud Platforms
Section titled “Cloud Platforms”Railway / Render / Fly.io
Section titled “Railway / Render / Fly.io”- Push your code to a Git repository
- Connect the repo to your cloud platform
- Set environment variables (
DATABASE_URL,JWT_SECRET, etc.) - The included
Dockerfilewill be auto-detected
Google Cloud Run
Section titled “Google Cloud Run”# Build the containerdocker build -t gcr.io/YOUR_PROJECT/rebase-backend ./backend
# Push to Container Registrydocker push gcr.io/YOUR_PROJECT/rebase-backend
# Deploygcloud run deploy rebase-backend \ --image gcr.io/YOUR_PROJECT/rebase-backend \ --set-env-vars DATABASE_URL=...,JWT_SECRET=... \ --allow-unauthenticatedChanging the Base URL
Section titled “Changing the Base URL”If you want Rebase to run at a sub-path (e.g., /admin):
Frontend — Update the BrowserRouter basename:
<BrowserRouter basename="/admin"> <App /></BrowserRouter>Backend — Update the base path:
await initializeRebaseBackend({ // ... basePath: "/admin/api"});Next Steps
Section titled “Next Steps”- Backend Overview — Full backend configuration
- Storage Configuration — S3 setup for production