Skip to main content
This guide covers deploying Scira to production environments, including Vercel, Docker-based deployments, and custom infrastructure. The easiest way to deploy Scira is using Vercel’s one-click deployment: Deploy with Vercel
1

Click the Deploy button

Click the “Deploy with Vercel” button above to start the deployment process.
2

Configure environment variables

Vercel will prompt you to configure the required environment variables. See the Environment Variables guide for details on each variable.At minimum, you’ll need:
  • OPENAI_API_KEY
  • ANTHROPIC_API_KEY
  • DATABASE_URL
  • BETTER_AUTH_SECRET
  • REDIS_URL
3

Deploy

Click “Deploy” and Vercel will:
  • Clone the repository
  • Install dependencies
  • Build the application
  • Deploy to production
4

Run database migrations

After deployment, run database migrations:

Vercel Configuration

Scira is optimized for Vercel with the following Next.js configuration:
  • Output: Standalone mode for optimal performance
  • Server Actions: 20MB body size limit for file uploads
  • Image Optimization: Configured for various external image sources
  • Edge Config: Support for Vercel Edge Config
  • Analytics: Built-in Vercel Analytics and Speed Insights integration

Docker Deployment

Production Docker Setup

For Docker-based production deployments:
1

Prepare environment file

Create a .env file with all required environment variables:
Edit .env and configure all production values.
2

Build the production image

Build the Docker image:
The multi-stage Dockerfile optimizes for:
  • Small image size - Uses Alpine Linux and output tracing
  • Security - Runs as non-root user
  • Performance - Standalone Next.js build
3

Run the container

Start the container:

Docker Compose Production

For orchestrating multiple containers:

Container Health Checks

Add health checks to your Docker setup:

Environment Setup

Required Environment Variables

For production, you must configure:
string
required
Set to production for production deployments
string
required
PostgreSQL connection string
string
required
Redis connection URL for caching and rate limiting
string
required
Secret key for authentication. Generate with:

Production Security Checklist

Before deploying to production, ensure you:
  • ✅ Use strong, randomly generated secrets
  • ✅ Enable HTTPS/SSL encryption
  • ✅ Configure proper CORS origins
  • ✅ Set up database connection pooling
  • ✅ Enable Redis for rate limiting
  • ✅ Configure OAuth redirect URLs correctly
  • ✅ Never expose API keys in client-side code
  • ✅ Set up monitoring and error tracking
  • ✅ Configure database backups
  • ✅ Use environment-specific configurations

Database Migrations

Run database migrations after deployment:

Migration Best Practices

  1. Test migrations locally first - Always test migrations in a development environment
  2. Backup before migrating - Create a database backup before running migrations
  3. Use transactions - Drizzle ORM automatically wraps migrations in transactions
  4. Monitor migration progress - Watch logs during migration execution
  5. Rollback plan - Have a rollback strategy ready if migrations fail

Health Checks and Monitoring

Health Check Endpoint

Implement a health check endpoint for monitoring:

Monitoring Recommendations

  • Application Performance - Use Vercel Analytics or similar
  • Error Tracking - Configure error logging (e.g., Sentry)
  • Database Monitoring - Monitor query performance and connection pool
  • Redis Monitoring - Track cache hit rates and memory usage
  • API Rate Limiting - Monitor rate limit hits via Upstash

Performance Optimization

Next.js configuration in next.config.ts includes:

Scaling Considerations

Database Scaling

  • Use connection pooling (PgBouncer)
  • Configure read replicas for read-heavy workloads
  • Optimize indexes for frequently queried fields
  • Monitor slow queries and optimize them

Redis Scaling

  • Use Redis Cluster for high availability
  • Configure appropriate eviction policies
  • Monitor memory usage and scale vertically if needed

Application Scaling

  • Enable horizontal scaling with multiple instances
  • Use load balancing for traffic distribution
  • Configure CDN for static assets
  • Optimize image delivery with Next.js Image component

Troubleshooting

Common Deployment Issues

Ensure all dependencies are properly installed:
  • Verify DATABASE_URL is correct
  • Check database server is accessible
  • Ensure database user has proper permissions
  • Verify SSL/TLS configuration if required
  • Check BETTER_AUTH_SECRET is set
  • Verify OAuth redirect URLs match deployment URL
  • Ensure OAuth credentials are correct
  • Check trustedOrigins in auth configuration
  • Check image remote patterns in next.config.ts
  • Verify external image sources are allowed
  • Ensure CDN/blob storage is accessible

Next Steps