DEV Community

Alex Spinov
Alex Spinov

Posted on

Dokku Has a Free API: Build Your Own Heroku on a $5 VPS

What is Dokku?

Dokku is the smallest PaaS implementation you've ever seen. It's a self-hosted Heroku alternative that runs on a single server. Push code with git push — Dokku builds, deploys, and manages your apps.

100% free. 100% open source.

Install

wget -NP . https://dokku.com/bootstrap.sh
sudo DOKKU_TAG=v0.34.8 bash bootstrap.sh
Enter fullscreen mode Exit fullscreen mode

Deploy Your First App

# On your local machine:
git remote add dokku dokku@your-server:my-app
git push dokku main
Enter fullscreen mode Exit fullscreen mode

That's it. Dokku detects your language, builds the app, and deploys it.

The CLI API

App Management

# Create app
dokku apps:create my-app

# List apps
dokku apps:list

# Destroy app
dokku apps:destroy my-app

# View logs
dokku logs my-app -t  # Follow logs

# Run one-off command
dokku run my-app python manage.py migrate
dokku run my-app rails console
Enter fullscreen mode Exit fullscreen mode

Domains & SSL

# Add domain
dokku domains:add my-app myapp.com
dokku domains:add my-app www.myapp.com

# Auto SSL with Let's Encrypt
dokku letsencrypt:enable my-app

# Auto-renewal
dokku letsencrypt:cron-job --add
Enter fullscreen mode Exit fullscreen mode

Environment Variables

# Set env vars
dokku config:set my-app DATABASE_URL=postgres://... SECRET_KEY=abc123

# View env vars
dokku config:show my-app

# Unset
dokku config:unset my-app DEBUG
Enter fullscreen mode Exit fullscreen mode

Databases (Plugins)

# Install PostgreSQL plugin
sudo dokku plugin:install https://github.com/dokku/dokku-postgres.git postgres

# Create database
dokku postgres:create my-db

# Link to app (sets DATABASE_URL automatically)
dokku postgres:link my-db my-app

# Backup
dokku postgres:export my-db > backup.sql

# Redis
sudo dokku plugin:install https://github.com/dokku/dokku-redis.git redis
dokku redis:create my-cache
dokku redis:link my-cache my-app
Enter fullscreen mode Exit fullscreen mode

Scaling

# Scale processes
dokku ps:scale my-app web=2 worker=1

# Set resource limits
dokku resource:limit my-app --memory 512m --cpu 1
Enter fullscreen mode Exit fullscreen mode

Docker Options

# Mount volumes
dokku storage:mount my-app /var/lib/dokku/data/storage:/app/uploads

# Set Docker options
dokku docker-options:add my-app deploy "--restart=always"
Enter fullscreen mode Exit fullscreen mode

Network & Ports

# Set port mapping
dokku ports:add my-app http:80:3000
dokku ports:add my-app https:443:3000

# View ports
dokku ports:list my-app
Enter fullscreen mode Exit fullscreen mode

Buildpacks vs Dockerfile

# Use buildpacks (auto-detect)
# Just push code — Dokku detects Node.js, Python, Ruby, etc.

# Use Dockerfile
# Just include a Dockerfile in your repo — Dokku uses it automatically

# Use Docker image
dokku git:from-image my-app myorg/my-image:latest
Enter fullscreen mode Exit fullscreen mode

Zero-Downtime Deploys

# Enable zero-downtime checks
dokku checks:enable my-app

# Custom health check
# In your app root, create CHECKS:
# /health  200  OK
Enter fullscreen mode Exit fullscreen mode

Popular Plugins

Plugin Purpose
postgres PostgreSQL databases
redis Redis instances
letsencrypt Auto SSL certificates
mongo MongoDB databases
mysql MySQL databases
rabbitmq Message queues
elasticsearch Search engine

Dokku vs Alternatives

Feature Dokku Coolify CapRover
Interface CLI Web UI Web UI
Deploy git push Git/Docker Git/Docker
Footprint ~256MB ~1GB ~512MB
Plugins 100+ Built-in Limited
Maturity 10+ years 3 years 5 years

Need a lightweight deployment solution or server automation?

📧 spinov001@gmail.com
🔧 My tools on Apify Store

git push to deploy — is Dokku the best PaaS for indie hackers? Let me know!

Top comments (0)