Heroku to Dokku: A Rails Dev's Migration Tale


The Cost-Benefit Realization
As a Rails developer who recently migrated from Heroku to Dokku, I want to share my journey and the surprising benefits I discovered. This transition wasn't just about cost savings—it opened up new possibilities for my deployment workflow.
The Heroku Challenge
Before diving into Dokku's benefits, let me share why I started looking for alternatives. Heroku had been my go-to platform for years, offering:
Zero-configuration deployments
Excellent developer experience
Reliable infrastructure
Built-in add-ons
However, recent changes created some challenges:
Removal of free tier
Significant cost increases for basic dynos
Sleep states affecting development apps
Add-on costs adding up quickly
Why Dokku Won Me Over
1. Cost Efficiency
# Monthly Cost Comparison for a Basic Rails Setup
heroku_cost = {
basic_dyno: 7,
postgres: 9,
redis: 15,
ssl: 20,
total: 51
}
dokku_cost = {
server_2gb: 10,
managed_databases: 0, # Included!
ssl: 0, # Free via Let's Encrypt
total: 10
}
2. Infrastructure Control
Unlike Heroku's black box approach, Dokku lets me:
Choose my server provider (Digital Ocean, Linode, AWS)
Customize server resources
Configure nginx directly
Manage database backups my way
3. Multi-App Efficiency
One of my favorite discoveries:
# Deploy multiple apps on one server
dokku apps:create rails-app-1
dokku apps:create rails-app-2
dokku apps:create rails-app-3
# Each with its own domains and SSL
dokku domains:set rails-app-1 app1.domain.com
dokku domains:set rails-app-2 app2.domain.com
4. Familiar Workflow
Dokku maintains Heroku's git-based deployment:
# Just like Heroku
git push dokku main
# Even supports release phase
dokku config:set rails-app-1 DOKKU_RELEASE_COMMAND="rails db:migrate"
5. Database Flexibility
My Rails apps often need multiple databases:
# Create separate databases for different concerns
dokku postgres:create main_db
dokku postgres:create analytics_db
dokku postgres:create cache_db
# Link them easily
dokku postgres:link main_db rails-app
6. Custom Plugin Ecosystem
Beyond basic features:
# Install useful plugins
sudo dokku plugin:install https://github.com/dokku/dokku-postgres.git
sudo dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git
sudo dokku plugin:install https://github.com/dokku/dokku-redis.git
Real-World Benefits I've Experienced
Development Environment
Faster deployments (no queue waiting)
Direct log access
Quick database operations
Custom domain management
Production Advantages
Significant cost savings
Better resource utilization
Full control over backups
Custom monitoring solutions
Scaling Capabilities
# Scale processes individually
dokku ps:scale web=2
dokku ps:scale worker=1
# Monitor resource usage
dokku ps:report
Making the Transition Easier
Here's what helped me during migration:
- Environment Variable Management
# Export from Heroku
heroku config -a your-app > config.txt
# Import to Dokku
while read line; do
dokku config:set your-app $line
done < config.txt
- Database Migration
# Export from Heroku
heroku pg:backups:capture
heroku pg:backups:download
# Import to Dokku
dokku postgres:import database < latest.dump
When to Choose Dokku Over Heroku
Consider Dokku when you:
Need cost-effective hosting
Want multiple apps on one server
Require custom infrastructure
Have basic sysadmin knowledge
Value deployment flexibility
Stay with Heroku if you:
Need enterprise-level support
Require zero server management
Want managed add-on services
Have a larger team needing access controls
Learning Curve and ROI
The initial setup took me about a day, but the benefits were immediate:
Monthly costs dropped by 80%
Deployment times improved
More control over infrastructure
Better understanding of my stack
Conclusion
My journey from Heroku to Dokku has been transformative. While Heroku remains an excellent platform, Dokku provides a powerful, cost-effective alternative that doesn't compromise on developer experience. The learning curve is worth the benefits, especially for Rails applications where cost and control matter.
Remember: Dokku isn't just a Heroku alternative—it's a different way of thinking about deployments that empowers developers to take control of their infrastructure while maintaining the simplicity we love about Platform as a Service solutions.
If you're considering the switch, feel free to reach out. The Rails community around Dokku is growing, and sharing experiences helps everyone succeed in their deployment journey!
Happy Coding!
Subscribe to my newsletter
Read articles from Sulman Baig directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Sulman Baig
Sulman Baig
Senior Software Engineer with 11 years of expertise in Ruby on Rails and Vue.js, specializing in health, e-commerce, staffing, and transport. Experienced in software development and version analysis.