Back to articles
Technology Insight

Build Your Own Private PaaS with Dokku: Heroku-Style 'git push' Deployments on a $2 VPS

June 2, 2026

The DevOps Dilemma: Cloud Convenience vs. Infrastructure Costs

For modern developers, platform-as-a-service (PaaS) providers like Heroku, Render, and Railway have revolutionized how we deploy applications. The simplicity is unmatched: you write code, execute a single git push command, and your application is live, secured with SSL, and accessible to the world. However, this convenience comes at a premium. As your portfolio grows, hosting multiple hobby projects, staging environments, or microservices on these platforms quickly becomes cost-prohibitive.

On the other end of the spectrum lies the traditional Virtual Private Server (VPS). While you can secure a basic VPS for as little as $2 to $5 per month from providers like DigitalOcean, Hetzner, or RackNerd, managing it manually introduces significant friction. Configuring Nginx reverse proxies, setting up Docker containers, managing Let's Encrypt SSL certificates, and writing custom deployment scripts can easily consume hours of valuable development time.

What if you could combine the simplicity and developer experience of Heroku with the affordability and control of a self-hosted VPS? Enter Dokku, the smallest PaaS implementation you will ever think about.

What is Dokku?

Dokku is an open-source, extensible Platform-as-a-Service that runs on your own server. Powered by Docker and written largely in Bash, Dokku allows you to build and manage the lifecycle of applications entirely via Git. It acts as a lightweight, single-host alternative to Heroku, meaning you can host dozens of isolated applications, databases, and cron jobs on a single cheap server.

"Dokku brings the magic of Heroku's developer workflow directly to your own infrastructure, giving you full autonomy without the administrative overhead."

Why Choose Dokku Over Traditional CI/CD?

  • Cost Efficiency: Run multiple applications, APIs, and databases on a single $2–$5/month VPS instead of paying $7+ per app on commercial platforms.
  • Heroku Compatibility: Dokku supports Heroku Buildpacks out of the box, alongside native Dockerfile deployments.
  • Automated SSL: Free, auto-renewing Let's Encrypt certificates are managed via a simple plugin.
  • Zero Vendor Lock-in: You own the server, the data, and the configuration. Moving to a different VPS provider takes minutes.

Prerequisites and Server Preparation

Before installing Dokku, you will need a few basic components. For this guide, a entry-level VPS with 1GB of RAM and 1 CPU core (typically costing around $2 to $4/month) is perfectly sufficient for hosting a few lightweight Node.js, Python, or Go applications.

  1. A VPS running a clean installation of Ubuntu 22.04 LTS or Ubuntu 24.04 LTS.
  2. A fully qualified domain name (e.g., yourdomain.com) with wildcard DNS records pointing to your VPS IP address (e.g., *.yourdomain.com and yourdomain.com pointing to 123.45.67.89).
  3. An SSH key pair configured on your local machine and added to your VPS for secure, passwordless authentication.

Step-by-Step Guide: Installing Dokku on Your VPS

To begin, connect to your server via SSH as the root user:

ssh root@your_server_ip

1. Run the Official Dokku Installation Script

Dokku provides a streamlined installation script that handles the setup of Docker, Nginx, and all required system dependencies automatically. Execute the following commands:

# Download and install the bootstrap script
wget -O bootstrap.sh [https://dokku.com/install/v0.34.x/bootstrap.sh](https://dokku.com/install/v0.34.x/bootstrap.sh)
sudo DOKKU_TAG=v0.34.x bash bootstrap.sh

Note: Ensure you check the official Dokku documentation for the latest stable version tag to replace v0.34.x.

2. Configure Global Domain and SSH Keys

Once the installation finishes, you must tell Dokku what domain it should use to route incoming HTTP traffic to your applications. Run the following command on the server:

dokku domains:set-global yourdomain.com

Next, you need to import your local machine's public SSH key so that Dokku recognizes your local Git client when you push code. From your local machine, run:

cat ~/.ssh/id_rsa.pub | ssh root@your_server_ip "dokku ssh-keys:add admin"

Deploying Your First Application: The Heroku Workflow

With Dokku fully configured, you are ready to experience the seamless deployment pipeline. Let us walk through deploying a standard web application.

1. Create the App Container on the Server

SSH back into your VPS and provision a new logical application space:

dokku apps:create my-awesome-app

2. Configure a Managed Database (Optional)

If your application requires a relational database like PostgreSQL or a caching layer like Redis, Dokku handles this via official plugins. Install the PostgreSQL plugin and link it to your application:

# Install the plugin
sudo dokku plugin:install [https://github.com/dokku/dokku-postgres.git](https://github.com/dokku/dokku-postgres.git)

# Create a database instance
dokku postgres:create my-db

# Link the database to your app (this automatically injects the DATABASE_URL environment variable)
dokku postgres:link my-db my-awesome-app

3. Deploy Code via Git Push

Navigate to your local application's project directory on your development machine. Add your Dokku server as a Git remote destination:

git remote add dokku dokku@your_domain.com:my-awesome-app

Now, initiate the deployment process by pushing your main branch:

git push dokku main

Dokku will detect your code structure (using Buildpacks or your local Dockerfile), compile your assets, provision an isolated Docker container, configure the Nginx reverse proxy, and assign a subdomain: [http://my-awesome-app.yourdomain.com](http://my-awesome-app.yourdomain.com).

Securing Production Apps with Let's Encrypt SSL

Running applications over insecure HTTP is unacceptable in modern web development. Dokku simplifies SSL provisioning to a single command through its Let's Encrypt plugin. On your server, run:

# Install the Let's Encrypt plugin
sudo dokku plugin:install [https://github.com/dokku/dokku-letsencrypt.git](https://github.com/dokku/dokku-letsencrypt.git)

# Set your email for renewal notifications
dokku letsencrypt:set my-awesome-app email [email protected]

# Enable SSL for your application
dokku letsencrypt:enable my-awesome-app

The plugin will automatically generate an SSL certificate, update Nginx to handle HTTPS traffic, force HTTP-to-HTTPS redirection, and schedule a background cron job to renew the certificate automatically before it expires.

Advanced Configuration and Best Practices

Managing Environment Variables

Never hardcode secrets or API keys into your source code. Dokku manages configuration securely via environment variables, accessible to your application at runtime:

dokku config:set my-awesome-app NODE_ENV=production API_KEY=xyz123

Optimizing Low-Memory ($2) Servers

When running Dokku on a budget VPS with limited memory, large application builds (such as compiling heavy npm assets) can occasionally exhaust system RAM, causing the deployment to fail. To prevent this, always ensure your server has a Swap File enabled. Run these commands on your VPS to allocate 2GB of virtual swap memory:

sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

Conclusion: Ultimate Control at a Fraction of the Cost

By leveraging Dokku on a low-cost VPS, you effectively eliminate the financial friction of building, testing, and maintaining side projects or business microservices. You gain a robust, production-grade PaaS that matches the operational elegance of Heroku while retaining complete control over your underlying infrastructure. For developers seeking to master self-hosting and optimize cloud architecture budgets, Dokku stands out as an indispensable tool in the modern DevOps toolkit.

Build Your Own Private PaaS with Dokku: Heroku-Style 'git push' Deployments on a $2 VPS | DPTCloud