How to Migrate from Heroku to Dokku
·OSSAlt Team
herokudokkumigrationpaasguide
How to Migrate from Heroku to Dokku
Dokku was built as a mini-Heroku. Same buildpacks, same Procfile, same git push workflow — running on your own VPS. The migration is the smoothest of any Heroku alternative.
Step 1: Install Dokku
# On a fresh Ubuntu VPS (22.04+)
wget -NP . https://dokku.com/install/v0.34.8/bootstrap.sh
sudo DOKKU_TAG=v0.34.8 bash bootstrap.sh
# Set your domain
dokku domains:set-global yourdomain.com
# Add your SSH key
cat ~/.ssh/id_rsa.pub | dokku ssh-keys:add admin
Step 2: Create App and Services
# Create app (same name as your Heroku app)
dokku apps:create myapp
# Install and create database
sudo dokku plugin:install https://github.com/dokku/dokku-postgres.git
dokku postgres:create myapp-db
dokku postgres:link myapp-db myapp
# Install and create Redis (if needed)
sudo dokku plugin:install https://github.com/dokku/dokku-redis.git
dokku redis:create myapp-redis
dokku redis:link myapp-redis myapp
Step 3: Set Environment Variables
# Export from Heroku
heroku config -a myapp --shell > heroku-env.txt
# Set in Dokku (one by one)
dokku config:set myapp NODE_ENV=production
dokku config:set myapp SECRET_KEY=your-secret
dokku config:set myapp SMTP_HOST=smtp.example.com
# Or bulk set
dokku config:set myapp $(cat heroku-env.txt | xargs)
Step 4: Deploy
# On your local machine
cd your-project
# Add Dokku remote
git remote add dokku dokku@your-server:myapp
# Push to deploy
git push dokku main
Your Procfile works unchanged. Your buildpacks work unchanged. Same deployment experience.
Step 5: Set Up SSL
# Install Let's Encrypt plugin
sudo dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git
# Configure email
dokku letsencrypt:set myapp email admin@yourdomain.com
# Enable SSL
dokku letsencrypt:enable myapp
# Auto-renewal
dokku letsencrypt:cron-job --add
Step 6: Set Up Domain
# Add custom domain
dokku domains:add myapp myapp.yourdomain.com
# Remove default domain
dokku domains:remove myapp myapp.yourdomain.com
Point DNS A record to your Dokku server.
Step 7: Migrate Database Data
# Export from Heroku
heroku pg:backups:capture -a myapp
heroku pg:backups:download -a myapp
# Import to Dokku Postgres
dokku postgres:import myapp-db < latest.dump
Heroku → Dokku Command Mapping
| Heroku | Dokku |
|---|---|
heroku create | dokku apps:create |
git push heroku main | git push dokku main |
heroku config:set | dokku config:set |
heroku logs --tail | dokku logs myapp -t |
heroku ps:scale web=2 | dokku ps:scale myapp web=2 |
heroku run bash | dokku run myapp bash |
heroku addons:create | dokku plugin:install + dokku <service>:create |
heroku domains:add | dokku domains:add |
heroku maintenance:on | dokku maintenance:enable |
Cost Comparison
| Dynos | Heroku | Dokku (VPS) | Savings |
|---|---|---|---|
| 1 Basic | $7/month | $5/month (shared VPS) | $24/year |
| 1 Standard | $25/month | $10/month | $180/year |
| 2 Standard + DB | $75/month | $20/month | $660/year |
| Production setup | $250+/month | $40/month | $2,520/year |
Migration Timeline
| Day | Task |
|---|---|
| Day 1 | Install Dokku, create app, set up services |
| Day 2 | Migrate env vars, deploy, test |
| Day 3 | Set up SSL, domain, migrate database |
| Week 2 | Monitor, verify everything works |
| Week 3 | Switch DNS, cancel Heroku |
Compare PaaS platforms on OSSAlt — deployment workflow, add-ons, and pricing side by side.