Coolify for hosting - part 1
The last couple of days I tried out Coolify and compare it to my up and running Dokku instances.
When I started in 2019 my full freelancing journey I encountered the need to host some projects somewhere. As most of the software I'm developing is web-based I wanted to have a setup that allows me to easily create a new instance, setup some stuff up and start deploying at will or even automatically. The evaluated version at the time of this writing is v4.0.0-beta.297
.
The common workflow
My most common workflow for projects is:
- development
- setup CI to run on each PR/MR
- setup CD to run on each merge to
main
- (setup CD for preview deployments -> complicated and depends on the project)
- production
- setup CD to run when a tag / release was created
Dokku - the status quo
The easiest way back then was to use Dokku for the development part. The production part is always dependent on how things need to scale as Dokku is single server and likely will stay that way. Since then I am a happy user of this mature piece of software. After an initial ramp up you can get quickly familiar with how things are working and have a good tool for deployment at hand. There are also quite some good plugins (Let's encrypt f.e.) that round up this tool even more.
On the other hand Dokku is somewhat a bit lower level and has its constraints. One is the already mentioned single server scalability (vertical scaling). Another one is the limitation when applications become more complex (micro services et al). Also there is a limit of available services. The usual suspects like DBs etc. are easily possible but if you need Kafka or other ones you might end in a Cul-de-sac.
Coolify - first steps
A couple of days ago I stumbled over a video on Youtube while procrastinating that briefly mentioned Coolify. I also watched the referred video and the suggested sidebar one which went in more detail and handled the currently 4 beta of Coolify. As Coolify looked clean and organized I though to give it a shot and try how it fits to my current workflow.
Setup
First you need to setup a new server for hosting Coolify. I went with a Hetzner Cloud ARM instance. Also it's recommended to take a cloud init script like this one. The setup of Coolify itself is rather easy curl -fsSL
https://cdn.coollabs.io/coolify/install.sh
| bash
. This installs all the prerequisites. Please follow the steps to harden and configure your instance from f.e. this video. This goes into detail of every aspect as well as shows some use cases.
Costs
The costs are around 4,00 € for the Hetzner instance (depending on the size).
First steps
First of all after looking around in the UI a bit I went with creating the first service (by cross-checking the before mentioned video here and there). There is a service catalogue where I got a bit lost trying out never seen before software. Well, procrastination. Beware that this is still a beta version software and so I was bitten by a service (Twenty CRM) that was broken. Don't get carried away too much like I was in trying to get this running. The best you can do is to file a bug report at Coolify unless it's an important piece of software. Note though that you can deploy almost any software as Coolify supports Docker Compose files alongside Docker, Nixpacks etc. This means there are hardly limits to single server software.
Mission
As mentioned in the beginning of this post my aim is to evaluate if Coolify can replace or enhance my Dokku workflow.
For this I want at the minimum a means for continuous deployment to test and host my software projects. To achieve this Coolify offers multiple ways. I won't get into detail about all of them because I only tested the GitHub App one.
The process is guided and works well. The only thing you might need to fiddle around is the name of the app as it needs to be unique.
After setting up the GitHub integration, the env variable need to be set. Prerequisite is to have a containerized app at best with maybe an .env
file. There are nice things like a developer mode for env vars where you can just quickly dump your needed ones and adapt to their needs.
Setup the app
As mentioned the app is a dockerized Elixir app with a Postgres service required for persistence. I went with creating a dedicated Postgres database via the UI. I copied the DSN
string and added it as the DATABASE_URL
env var to the app.
I enabled (or it was per default?) auto deployment and did a test push. The errors if there are some are good to understand. I had missed some config parts and needed to trial and error a little bit (Dockerfile location, some other settings here and there).
The only downside of the auto deployment is that the deployment is triggered by a merge webhook directly although usually I have a CI action running that should pass before hand. But there is a "workaround" for this by using the Coolify webhook to trigger it manually.
The next steps investigating preview deployments will follow in a separate post.