Heroku to Dokku: A Rails Dev's Migration Tale

Senior Software Engineer with 12 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.
Search for a command to run...

Senior Software Engineer with 12 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.
No comments yet. Be the first to comment.
This comprehensive series will equip readers with practical knowledge and skills in deploying Rails applications using Kamal, Dokku, and other relevant tools.
In my previous article, we explored deploying Rails 8 applications using Docker and Kamal. https://sulmanweb.com/deploy-rails-8-docker-kamal-production-guide Today, I'm excited to share how we can take this deployment process to the next level by a...
Motivation After building several Shopify embedded apps, I've learned valuable lessons about what works (and what definitely doesn't) in the embedded app environment. Today, I'm sharing these insights to help you avoid common pitfalls and build bette...

As a developer working with Shopify's ecosystem, I recently built a multi-tenant SaaS application that synchronizes customer data between Shopify stores and external services. In this article, I'll share my experience and technical insights into crea...

As developers, we're always looking for ways to streamline our deployment process while maintaining security and reliability. Today, I'm excited to share my experience setting up an automated deployment pipeline for a Rails application using Dokku an...

The Challenge: Modernizing Rails Deployment When I recently needed to deploy my Rails 8 application with multiple databases, I faced a common dilemma: choosing between expensive managed solutions and complex self-managed servers. My requirements were...

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.
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
# 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
}
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
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
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"
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
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
Faster deployments (no queue waiting)
Direct log access
Quick database operations
Custom domain management
Significant cost savings
Better resource utilization
Full control over backups
Custom monitoring solutions
# Scale processes individually
dokku ps:scale web=2
dokku ps:scale worker=1
# Monitor resource usage
dokku ps:report
Here's what helped me during migration:
# 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
# Export from Heroku
heroku pg:backups:capture
heroku pg:backups:download
# Import to Dokku
dokku postgres:import database < latest.dump
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
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
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!