DEV Community

Cover image for Heroku to Dokku: A Rails Dev's Migration Tale
Sulman Baig
Sulman Baig

Posted on • Originally published at sulmanweb.com

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
}
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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"
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Making the Transition Easier

Here's what helped me during migration:

  1. 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
Enter fullscreen mode Exit fullscreen mode
  1. Database Migration
# Export from Heroku
heroku pg:backups:capture
heroku pg:backups:download

# Import to Dokku
dokku postgres:import database < latest.dump
Enter fullscreen mode Exit fullscreen mode

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!


Originally published at: https://sulmanweb.com

Imagine monitoring actually built for developers

Billboard image

Join Vercel, CrowdStrike, and thousands of other teams that trust Checkly to streamline monitor creation and configuration with Monitoring as Code.

Start Monitoring

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay