Deployment
Deploy Datyze with Docker and Coolify on VPS infrastructure
Deployment
Datyze is optimized for self-hosting with Docker and Coolify on VPS infrastructure. The application uses Next.js standalone mode for minimal Docker image size.
Docker Configuration
Dockerfile Overview
The multi-stage Dockerfile optimizes for production:
Building the Image
Running Locally
Coolify Deployment
Prerequisites
- A VPS with Coolify installed
- PostgreSQL database (can be provisioned in Coolify)
- Domain name configured
Step 1: Connect Repository
- Open Coolify dashboard
- Create a new application
- Connect your Git repository
- Select Dockerfile as the build pack
Step 2: Configure Environment
Add all required environment variables:
Step 3: Deploy
Click Deploy and Coolify will:
- Clone your repository
- Build the Docker image
- Run database migrations
- Start the application
Environment Variables
Required Variables
| Variable | Description |
|---|---|
DATABASE_URL | PostgreSQL connection string |
AUTH_SECRET | Min 32-character secret for NextAuth |
AUTH_URL | Your production domain |
NEXT_PUBLIC_APP_URL | Same as AUTH_URL |
Generate AUTH_SECRET
OAuth Providers
| Variable | Provider |
|---|---|
GOOGLE_CLIENT_ID | Google OAuth |
GOOGLE_CLIENT_SECRET | Google OAuth |
GITHUB_CLIENT_ID | GitHub OAuth |
GITHUB_CLIENT_SECRET | GitHub OAuth |
Email Configuration
| Variable | Provider |
|---|---|
RESEND_API_KEY | Resend |
BREVO_API_KEY | Brevo |
EMAIL_FROM | Sender email |
Payment Configuration
Stripe:
| Variable | Description |
|---|---|
STRIPE_SECRET_KEY | Stripe secret key |
STRIPE_WEBHOOK_SECRET | Webhook signing secret |
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY | Publishable key |
Lemon Squeezy:
| Variable | Description |
|---|---|
LEMONSQUEEZY_API_KEY | API key |
LEMONSQUEEZY_STORE_ID | Store ID |
LEMONSQUEEZY_WEBHOOK_SECRET | Webhook secret |
Database Setup
Using Coolify's PostgreSQL
- In Coolify, create a new PostgreSQL database
- Copy the connection string
- Add it as
DATABASE_URLto your app
External Database
Use any PostgreSQL provider:
- Neon - Serverless PostgreSQL
- Supabase - PostgreSQL with extras
- Railway - Simple hosting
- Your own PostgreSQL - Self-hosted
Database Migrations
Development
Push schema changes directly:
Production
Generate and run migrations:
Migrations run automatically during Docker build.
Health Checks
The application includes a health check endpoint:
Configure in Coolify:
SSL/HTTPS
Coolify automatically provisions SSL certificates via Let's Encrypt. Ensure your domain's DNS is properly configured:
Monitoring
Sentry Integration
Add Sentry for error tracking:
Rate Limiting (Optional)
Rate limiting uses Upstash Redis but is completely optional. Without configuration:
- All API requests are allowed (graceful degradation)
- The application works normally
- No errors or warnings
If you need rate limiting later, add:
Tip: Start without rate limiting. Add it later when you have users and need protection against API abuse.
Performance Tips
- Enable standalone mode - Already configured in
next.config.ts - Use edge caching - Cloudflare or similar CDN
- Optimize images - Use Next.js Image component
- Database indexes - Already configured for common queries
Troubleshooting
Database Connection Failed
Check DATABASE_URL format:
Build Errors
- Verify all environment variables are set
- Try with
SKIP_ENV_VALIDATION=1 - Clear Docker cache:
docker build --no-cache
Auth Errors
- Ensure
AUTH_URLmatches your domain exactly - Check OAuth callback URLs in provider settings
Docker Compose
For local production testing:
Run with:
Next Steps
- Architecture - Understand the codebase
- Authentication - Configure OAuth for production
- Payments - Set up payment webhooks