Coolify Deployment Guide
Deploy your TurboStack project to Coolify - a self-hosted alternative to Heroku/Vercel.Coolify is an open-source platform that lets you deploy applications using
Docker. This guide covers deploying both frontend and backend applications.
Prerequisites
Coolify Account
Sign up at coolify.io or self-host
Git Repository
Your code must be in a Git repository (GitHub, GitLab, etc.)
PostgreSQL
Available through Coolify or external provider
Domain (Optional)
Custom domain for production deployment
Deployment Architecture
Coolify automatically handles SSL certificates, reverse proxy, and internal
networking between services.
Step 1: Create Project
Step 2: Setup Database
Create PostgreSQL Service
- Select “New Resource” → “Database”
- Choose PostgreSQL 16
- Configure:
- Name:
turbostack-db - Database:
turbostack - Username:
turbostack - Password: Generate strong password
- Name:
Step 3: Deploy Backend API
Create API Application
- Select “New Resource” → “Application”
- Choose “Git Repository”
- Enter repository URL
- Select
mainbranch
Step 4: Deploy Frontend
Create Web Application
- Select “New Resource” → “Application”
- Choose “Git Repository”
- Same repository,
mainbranch
Step 5: Update CORS Settings
After both deployments are complete:Custom Domains & SSL
- Add Custom Domain
- Wildcard SSL
Database Migrations
Run migrations after deployment:Environment Variables Reference
Backend API Required
Backend API Required
Frontend Required
Frontend Required
NEXT_PUBLIC_API_URL=https://api.yourdomain.com
Troubleshooting
Build fails with 'module not found'
Build fails with 'module not found'
Cause: Base Directory is not emptySolution: Set Base Directory to empty (leave blank)
Database connection error
Database connection error
Cause: Wrong connection string or database not readySolution:
- Verify DATABASE_URL format
- Ensure database service is running
- Use
dbas host (internal network)
API returns 502 Bad Gateway
API returns 502 Bad Gateway
Cause: Port mismatch or health check failingSolution:
- Verify port 4101 is exposed in Dockerfile
- Check health endpoint returns 200 OK
- Review application logs
CORS errors on frontend
CORS errors on frontend
Cause: CORS_ORIGIN not set correctlySolution:
- Update API CORS_ORIGIN to frontend domain
- Redeploy API after change
- Clear browser cache
Build timeout
Build timeout
Cause: Build taking too longSolution:
- Increase build timeout in Coolify settings
- Optimize Dockerfile (use build cache)
- Use smaller base images
Monitoring & Logs
- Application Logs
- Container Stats
- Health Checks
View real-time logs in Coolify dashboard:
- Navigate to application
- Click “Logs” tab
- Filter by severity (info, warn, error)
Scaling & Performance
Horizontal Scaling
Deploy multiple instances behind load balancer
Vertical Scaling
Increase container resources (CPU, RAM)
Database Scaling
Use connection pooling (PgBouncer)
CDN Integration
Cache static assets globally