The refreshing feeling of freedom when using Dokku
08 Apr 2024 - Frans Vanhaelewijck
Some time ago, I discovered Dokku — an innovative open-source tool that transforms your own server into a powerful deployment platform, akin to Heroku or Render.com. Let me share what I learned and explain why Dokku might be the solution to a problem you didn’t know you had.
How to get started
I recommend starting with a simple Rails ‘Hello World’ application. This approach allows you to concentrate on the deployment process without the complexities of setting up and connecting to a database, running database seeds, and so on.
To begin, I reset my VPS, a modest 1GB instance running Ubuntu v20. The next step was installing Dokku, and after some time, my Ruby on Rails app was live on my own server.
Redeploying new versions
Redeploying a new version of your app works similarly to how it does on Render.com or Heroku. A simple “git push origin” to your VPS (your remote server) triggers a rebuild and redeployment.
The real magic of Dokku lies in its seamless deployment process, which ensures zero downtime for end users. Dokku achieves this by keeping the old instance of your app running until the newly deployed instance returns a 200 response code on its app/up page and is ready to go live, ensuring a smooth transition.
Time is money
This is a great experience; deploying apps directly to a server under my control, without reliance on external platforms, offers freedom and significant cost savings. However, it’s important to remember that time is money. Of course, time spent tweaking Dokku settings is time not spent on developing new features or acquiring new customers.
Using platforms like Heroku or Render.com involves costs for
- app deployment,
- a database, and possibly
- a service like Redis.
These costs can escalate, especially when deploying multiple apps.
Consider the extensive details on Heroku’s pricing page. I believe these funds could be more effectively allocated to your VPS, should the need arise. If you require additional capacity, simply upgrade to a higher tier for your VPS, or, for particularly resource-intensive applications, migrate to a dedicated server equipped with its own Dokku installation.
Scaling up your app(s) and multi server support
If you would ever reach the capacity limits of a single server, Dokku offers an official k3s core plugin that facilitates the transition from single to multi-server setups. This plugin leverages enhancements in other areas of Dokku—such as the proxy layer, cron integration, and registry support—to deliver a simplified Kubernetes experience, enabling you to deploy your application across multiple servers easily.
Other great features
Dokku has 2 other features I found very useful:
- Let’s Encrypt integration for easy HTTPS setup and
- the capability to link a specific domain name to each of your apps running on a single server. I have successfully linked several domains to different apps on my server.
Alternatives
While Dokku is open-source and free to use, there’s also Dokku Pro—a premium version with a graphical user interface, priced at around $850. This version enhances the Dokku experience with a GUI and supports the project’s maintainers. It’s a sound investment for those deeply invested in Dokku.
Alternatives like Hatchbox.io by Chris Oliver from GoRails.com (a paid service) and Kamal (open-sourced by 37signals) offer unique features. However, I chose Dokku for its simplicity and efficiency, which perfectly aligns with my needs.
Is it difficult?
Dokku provides an efficient alternative, functioning as a thin layer on top of Docker. It demands minimal Docker knowledge for successful app deployments.
This post encourages you to explore deploying your apps on your own VPS. Expertise in system administration isn’t necessary for success. If I managed to get comfortable with Dokku in just a few days, you can too.
Interesting links
- Official documentation: https://dokku.com/docs/getting-started/installation/
- Hackernews post: https://news.ycombinator.com/item?id=31376241
- Dokku vs Kamal: https://deploymentfromscratch.com/tools/dokku-vs-kamal/
- Hatchbox.io: https://hatchbox.io/