Deployment
Deploy Complaintr to production.
Docker Compose (Recommended)
The simplest way to deploy Complaintr is with Docker Compose:
# Clone the repository
git clone <repo-url> && cd complaintr
# Configure environment
cp .env.example .env
# Edit .env with your production values
# Start all services
docker compose up --build -dThis starts three services:
- db: PostgreSQL 17 Alpine on port 5432
- web: Next.js app on port 3000
- telegram-bot: Telegram bot for notifications and complaint submissions
Environment Variables for Production
Set these in your .env file or as environment variables:
| Variable | Production Value |
|---|---|
DATABASE_URL | PostgreSQL connection (use the db service hostname) |
BETTER_AUTH_SECRET | Random 64-char string generated with openssl rand -hex 32 |
BETTER_AUTH_URL | Your production URL (e.g., https://complaintr.example.com) |
GOOGLE_CLIENT_ID | Google OAuth client ID (create in Google Cloud Console) |
GOOGLE_CLIENT_SECRET | Google OAuth client secret |
ADMIN_EMAILS | Comma-separated list of admin email addresses |
TELEGRAM_BOT_TOKEN | Bot token from @BotFather (optional, for Telegram features) |
Google OAuth Configuration
- Go to Google Cloud Console
- Create an OAuth 2.0 Client ID
- Add authorized redirect URIs:
https://your-domain.com/api/auth/callback/google
- Copy the Client ID and Secret to your
.env
Manual Deployment
Prerequisites
- Bun 1.3.4+
- PostgreSQL 17
- Node.js (for some build tools)
Build
bun install
bun run buildThe web app builds to apps/web/.next/standalone/.
Run
# Start PostgreSQL
docker compose up db -d
# Push database schema
bun run db:push
# Start the web app
cd apps/web && bun run startReverse Proxy (Nginx)
Example Nginx configuration for production:
server {
listen 80;
server_name complaintr.example.com;
location / {
proxy_pass http://localhost: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;
proxy_cache_bypass $http_upgrade;
}
}SSL (Let's Encrypt)
Use Certbot with Nginx:
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d complaintr.example.comHealth Checks
The web app includes a health check endpoint:
curl http://localhost:3000/api/healthThe Docker Compose configuration uses this for container health checks.
Database Backups
# Backup
pg_dump postgresql://complaintr:complaintr@localhost:5432/complaintr > backup.sql
# Restore
psql postgresql://complaintr:complaintr@localhost:5432/complaintr < backup.sqlMonitoring
Logs
- Web app: stdout (Next.js server logs)
- Telegram bot: stderr (console.error for operational logs)
- Database: PostgreSQL logs within the Docker container
Analytics
Complaintr does not include built-in analytics. Consider adding:
- Plausible or Umami for privacy-friendly page analytics
- Sentry for error tracking
- Grafana + Prometheus for infrastructure monitoring
Scaling Considerations
For high-traffic deployments:
- Database: Use a managed PostgreSQL service (Supabase, Neon, AWS RDS)
- Web app: Run multiple instances behind a load balancer
- Sessions: Better Auth stores sessions in PostgreSQL, which scales with your database
- Rate limiting: Currently PostgreSQL-based. For large scale, consider Redis for rate limit storage
- File storage: Not applicable (Complaintr does not handle user file uploads)
