Vercel Deployment (Recommended)
The easiest way to deploy Scira is using Vercel’s one-click deployment:Click the Deploy button
Click the “Deploy with Vercel” button above to start the deployment process.
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_KEYANTHROPIC_API_KEYDATABASE_URLBETTER_AUTH_SECRETREDIS_URL
Deploy
Click “Deploy” and Vercel will:
- Clone the repository
- Install dependencies
- Build the application
- Deploy to production
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:Prepare environment file
Create a Edit
.env file with all required environment variables:.env and configure all production values.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
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:Set to
production for production deploymentsPostgreSQL connection string
Redis connection URL for caching and rate limiting
Secret key for authentication. Generate with:
Production Security Checklist
Database Migrations
Run database migrations after deployment:Migration Best Practices
- Test migrations locally first - Always test migrations in a development environment
- Backup before migrating - Create a database backup before running migrations
- Use transactions - Drizzle ORM automatically wraps migrations in transactions
- Monitor migration progress - Watch logs during migration execution
- 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 innext.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
Build fails with module not found error
Build fails with module not found error
Ensure all dependencies are properly installed:
Database connection fails
Database connection fails
- Verify
DATABASE_URLis correct - Check database server is accessible
- Ensure database user has proper permissions
- Verify SSL/TLS configuration if required
Authentication doesn't work
Authentication doesn't work
- Check
BETTER_AUTH_SECRETis set - Verify OAuth redirect URLs match deployment URL
- Ensure OAuth credentials are correct
- Check
trustedOriginsin auth configuration
Images not loading
Images not loading
- Check image remote patterns in
next.config.ts - Verify external image sources are allowed
- Ensure CDN/blob storage is accessible
