DEV Community

Alex Spinov
Alex Spinov

Posted on

Dokku Has a Free API — Heres How to Build Your Own Mini-Heroku in 5 Minutes

Dokku is the smallest PaaS implementation — a Docker-powered Heroku alternative in about 200 lines of Bash. Git push to deploy, buildpacks, and plugins.

Why Dokku?

  • Heroku workflow: git push dokku main to deploy
  • Buildpacks: Auto-detect Node, Python, Ruby, Go, etc.
  • Plugins: PostgreSQL, Redis, MongoDB, Let's Encrypt
  • Tiny footprint: Runs on 512MB RAM
  • Free: Open source
  • Battle-tested: 10+ years, 25K+ GitHub stars

Install

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

Create and Deploy

# On server
dokku apps:create my-app

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

Dokku auto-detects your language and builds.

Add Database

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

# Create database
dokku postgres:create my-db

# Link to app (auto-sets DATABASE_URL)
dokku postgres:link my-db my-app
Enter fullscreen mode Exit fullscreen mode

Environment Variables

dokku config:set my-app SECRET_KEY=abc123 NODE_ENV=production
dokku config:show my-app
Enter fullscreen mode Exit fullscreen mode

Custom Domains + HTTPS

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

# Enable HTTPS
sudo dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git
dokku letsencrypt:enable my-app
Enter fullscreen mode Exit fullscreen mode

Scale

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

# Check status
dokku ps:report my-app
Enter fullscreen mode Exit fullscreen mode

Docker Deploy

# Deploy from Docker image
dokku git:from-image my-app myregistry/my-app:v1.2

# Or from Dockerfile
# Just have a Dockerfile in your repo and git push
Enter fullscreen mode Exit fullscreen mode

View Logs

dokku logs my-app -t  # tail logs
dokku logs my-app -n 100  # last 100 lines
Enter fullscreen mode Exit fullscreen mode

Backups

dokku postgres:export my-db > backup.sql
dokku postgres:import my-db < backup.sql
Enter fullscreen mode Exit fullscreen mode

Real-World Use Case

A solo developer hosts 8 side projects on a $6 DigitalOcean droplet with Dokku. Each project deploys with git push, has its own PostgreSQL database, and automatic HTTPS. Total cost: $6/mo instead of $200+/mo on Heroku.


Need to automate data collection? Check out my Apify actors for ready-made scrapers, or email spinov001@gmail.com for custom solutions.

Top comments (0)