Overview
Bounty is built with Next.js and can be deployed to various platforms. This guide covers deployment to Vercel (recommended) and self-hosted infrastructure.Prerequisites
Before deploying, ensure you have:Environment Variables
All required environment variables configured. See Environment Variables.
Database
PostgreSQL database set up and migrated. See Database Setup.
Deployment Options
Vercel (Recommended)
Vercel provides the best experience for Next.js applications with:- Zero-configuration deployments
- Automatic HTTPS and CDN
- Serverless functions for API routes
- Edge network for optimal performance
- Built-in analytics and monitoring
- Cron jobs for scheduled tasks
Self-Hosted
Deploy on your own infrastructure:- Full control over hosting environment
- Use existing infrastructure
- Deploy to any Node.js hosting platform
- Custom domain and SSL configuration
Deploying to Vercel
Initial Setup
Create Vercel Account
Sign up at vercel.com using your GitHub account.
Import Repository
- Click “Add New Project”
- Import your Bounty repository from GitHub
- Vercel will auto-detect the Next.js framework
Configure Build Settings
Vercel should auto-detect these settings:
- Framework Preset: Next.js
- Root Directory:
./(monorepo root) - Build Command:
bun build(or use default) - Output Directory:
.next(auto-detected) - Install Command:
bun install
Vercel has native Bun support. It will automatically use Bun based on your
package.json packageManager field.Set Environment Variables
In Vercel dashboard → Project Settings → Environment Variables, add all variables from your
.env file.Required Variables:DATABASE_URLBETTER_AUTH_SECRETBETTER_AUTH_URL(use Vercel domain)GITHUB_CLIENT_ID&GITHUB_CLIENT_SECRETGITHUB_APP_*(all GitHub App variables)UPSTASH_REDIS_REST_URL&UPSTASH_REDIS_REST_TOKENNEXT_PUBLIC_BASE_URL(use Vercel domain)
Post-Deployment Configuration
Update OAuth Callback URLs
Update OAuth Callback URLs
Update your GitHub OAuth App and GitHub App settings with your Vercel domain:GitHub OAuth App:
- Authorization callback URL:
https://your-app.vercel.app/api/auth/callback/github
- Callback URL:
https://your-app.vercel.app/api/auth/callback/github - Webhook URL:
https://your-app.vercel.app/api/webhooks/github
Configure Custom Domain
Configure Custom Domain
- Go to Project Settings → Domains
- Add your custom domain (e.g.,
bounty.yourdomain.com) - Follow Vercel’s DNS configuration instructions
- Update environment variables with new domain:
- Update OAuth callback URLs in GitHub to use new domain
Set up Cron Jobs
Set up Cron Jobs
Bounty includes cron job configuration in This runs session cleanup daily at 2 AM UTC.Protect Cron Endpoints:
Set
vercel.json:CRON_SECRET environment variable and verify in your cron handlers.Configure Webhooks
Configure Webhooks
Test webhook delivery:
- GitHub Webhooks: Trigger test event in GitHub App settings
- Stripe Webhooks: Use Stripe CLI or dashboard to send test event
- Check Vercel Functions logs for successful processing
- GitHub:
https://your-domain.com/api/webhooks/github - Stripe:
https://your-domain.com/api/webhooks/stripe
Vercel Configuration File
Thevercel.json file in the repository root configures Vercel-specific settings:
SKIP_ENV_VALIDATION- Allows build to use Vercel environment variablescrons- Defines scheduled tasks (Hobby/Pro plans only)
Monitoring on Vercel
Deployment Logs
View build and deployment logs in Vercel dashboard → Deployments → [deployment] → Building
Function Logs
Monitor serverless function execution in Vercel dashboard → Deployments → [deployment] → Functions
Analytics
Track performance and usage in Vercel dashboard → Analytics (requires Pro plan)
Speed Insights
Monitor Core Web Vitals in Vercel dashboard → Speed Insights (requires Pro plan)
Self-Hosted Deployment
Building for Production
Deployment Options
- Docker
- PM2
- Systemd
- Nginx Reverse Proxy
Create a Build and Run:
Dockerfile for containerized deployment:SSL/TLS Configuration
For self-hosted deployments, set up SSL certificates: Using Let’s Encrypt (Certbot):Build Scripts Reference
All build scripts are defined inpackage.json:
Health Checks
Implement health check endpoint for monitoring:https://your-domain.com/api/health
Troubleshooting
Build Failures
Build Failures
Common Issues:
- Missing environment variables during build
- Type errors in TypeScript
- Dependency conflicts
- Set
SKIP_ENV_VALIDATION=truefor build - Run
bun check-typeslocally first - Clear node_modules and reinstall:
rm -rf node_modules && bun install
Runtime Errors
Runtime Errors
Common Issues:
- Database connection errors
- Missing environment variables
- OAuth redirect mismatches
- Verify DATABASE_URL is correct and accessible
- Check all required env vars are set
- Ensure callback URLs match environment
Webhook Delivery Failures
Webhook Delivery Failures
Common Issues:
- GitHub webhooks timing out
- Invalid webhook signatures
- Firewall blocking requests
- Check webhook endpoint is publicly accessible
- Verify GITHUB_WEBHOOK_SECRET matches GitHub App
- Review webhook delivery logs in GitHub App settings
Performance Issues
Performance Issues
Common Issues:
- Slow database queries
- High memory usage
- Rate limiting
- Add database indexes for frequently queried columns
- Increase serverless function memory (Vercel)
- Configure Redis rate limiting properly
- Use database connection pooling
Production Checklist
Before going live, verify:Environment
- All environment variables set
- Using production API keys (not test keys)
- Secrets are strong and unique
-
NEXT_PUBLIC_EARLY_ACCESS_ENABLEDset appropriately
OAuth & Webhooks
- GitHub OAuth callbacks match domain
- GitHub App webhooks configured
- Stripe webhooks set up (if using payments)
- Discord webhooks tested (if using)
Security
- HTTPS enabled
- Secrets not committed to git
- Rate limiting configured
- CORS settings appropriate
Monitoring
- Error tracking (Sentry) configured
- Analytics (PostHog) enabled
- Health check endpoint working
- Logs being collected
Continuous Deployment
Vercel (Automatic)
Vercel automatically deploys:- Production: Commits to
mainbranch - Preview: Pull requests and other branches
GitHub Actions (Self-Hosted)
Set up automated deployments:Next Steps
Installation Guide
Set up local development environment
API Reference
Explore Bounty’s API endpoints
Environment Variables
Configure your environment
GitHub Repository
View source code and report issues