Dokku
An open source, self-hosted ‘Platform As A Service’ (PAAS) alternative to Heroku.
Dokku helps you build and manage the lifecycle of applications from building to scaling.
Homepage: https://dokku.com/
I've been using this for a while to host all my sites under https://kevbot.xyz without issue. I started using it because of this Youtube tutorial series.
It's nice if you don't like messing with Docker to deploy stuff. Dokku uses docker in the background, but you don't have to worry about that too often. Instead it uses buildpacks similar to Heroku, which automatically build your project much like you would locally.
On the other hand, if you really like docker, I can recommend https://caprover.com/ over dokku. It's a similar concept to dokku, but it exposes more of the Dockery docker-doos to you, the developer.
Pros
- Allows for very easy self-hosting. As a matter of fact I believe you have to self-host it. I don't think Dokku-as-a-service exists (well, there's Heroku but that's not so commonly recommended nowadays.)
- Dokku is very actively maintained (mostly by https://github.com/josegonzalez). With great documentation.
- Rich plugin ecosystem.
- GitOps. Dokku servers function as git servers, so you just push a new repo and it builds a new publicly-exposed app in ~1 min.
- example:
git remote add dokku dokku@DOKKU_HOST:myapp && git push dokku
. You'll soon have a deployed app under https://myapp.kevbot.xyz. To update it, just push again. - This encourages, if not enforces, 12 Factor style app design which is good.
- example:
- CLI-based everything. You can deploy / manage stuff from local machine, or you can ssh onto the actual server and manage things there.
- Can run many Apps on the box. Currently I have 20 apps plus 6 Databases running on one machine.
- Can run many DBs on the box (see here for a full list). On my single box, I'm currently currently running 3 Redis, 2 Postgres, and 1 mariadb instances.
- Dokku has a great build system that you usually don't have to wrestle with much once you understand it. I'm usually using thee herokuish Python, Node, or static site buildpacks. And sometimes Dockerfile-based deployments. You have many options, including nix-based deployments though I've never tried that. Just search
dokku
on github for a bunch of projects people have made.
Meh
- You have to run either Ubuntu or Debian on your Dokku server. And depending on how many apps you want to run, I'd recommend at least 2gb ram and at least 20gb disk. (My racknerd VPS has 3 cpu cores, 4gb ram, 80gb ssd).
- The official system requirements are here: https://dokku.com/docs/getting-started/installation/#system-requirements
- Dokku supports autoscaling, but I've never used it for that. I think Dokku is most straightforward used single-node, but who knows?
Cons
- No official web dashboard. This does exist in the Dokku Pro version (which I do not yet have). You can get by using
ctop
, for a tui dashboard, though (see below). - Sometimes upgrading dokku versions can be a bit of a pain. There is
sudo dokku-update run --system-update
which helps out some. See docs.- also see Dokku Hardships (private)
- You kind of have to start with a freshly installed VPS and it kind of “takes over” a lot of your system's networking details. I've never tried adding Dokku to a VPS that I've been using for a while.
- Once you get away from the happy-path of using-buildpacks-someone-else-has-already-made, things can get tricky. Dockerfile deployments exist, but can get hairy. Docker Compose deployments do not exist at all (as of Jan 2024 at least).
- Definitely not serverless-style architecture. Your Dokku instance will be a pet-server. You can set up backups which can be restored, but it's not the most seamless.
- Dokku uses a lot of bespoke concepts, tooling, build systems, and more. You'll sometimes need to add files in your repo like
app.json
,.buildpacks
,.static
, orapt-packages
. You aren't all that locked into Dokku from this, though as these files are pretty light in content generally.
A nice command to view container resource usage and more
# run this on the actual dokku machine
sudo docker run --rm -ti \
--name=ctop \
--volume /var/run/docker.sock:/var/run/docker.sock:ro \
quay.io/vektorlab/ctop:latest
More docs on ctop here: https://github.com/bcicen/ctop
If you need to free up space
Docker tends to kind of fill the hard drive up with cruft such as old containers / layers and stuf.
This command will clear all your unused and cached containers. Your next builds will likely take longer.
sudo docker system prune -a