I recently migrated RssFeedPulse to Coolify.
If you're wondering what Coolify is or want to understand why I'm migrating from my old PAAS to Coolify, then you might want to read the previous post, which talks about just that.
To sum up, Coolify is a PAAS (like Vercel, Heroku etc.) that you can install yourself on the server of your choice.
And what really interests me about this PAAS is that it lets you run a lot of things, including applications in Kotlin, the language I use for RssFeedPulse.
So today I'd like to talk mainly about how to deploy a Kotlin application on Coolify.
Installing Coolify
But first, you need to install Coolify.
I won't go into too much detail here. It's really quite simple, done in a single command line:
curl -fsSL https://cdn.coollabs.io/coolify/install.sh | bash
And on the first steps with the platform, I recommend this video :
TIP
EXCEPT the part about minIO, we'll talk about that in a future post, but it makes no sense to follow this video's advice on that point.
In terms of Hosting, I did as in the previous video and chose to use Hetzner which offers servers at relatively attractive prices.
The documentation states that Coolify requires a minimum of 2CPU and 2Gb RAM.
In practice, this gave me the following:
So I quickly switched to a more powerful machine with 4CPU and 8Gb RAM.
Once installed, I advise you to quickly use a domain name to access your Coolify application. Personally, I use Cloudflare, which also takes care of the SSL certificate.
Once that's done, I invite you to :
- change your password,
- activate 2FA,
- set up a firewall rule on Hetzner to authorize access only on port 80 and 443.
Once again, I'll pass quickly over the Coolify installation itself, as I'm more interested in what comes next.
Deploying a Kotlin application
On Coolify, you can deploy any app that might run in a Docker container, BUT, fortunately, you don't have to touch Docker at all.
In my case, for RssFeedPulse, I first set up a GitHub "source".
This source can then be used by Coolify to browse all your repositories on Github (or Gitlab).
From there, when you create a new resource, you can choose to use this source
Once you've chosen the right repository, it's time to move on to configuration.
You'll notice in the screenshot that Coolify uses NixPacks to build your application.
NixPacks has the enormous advantage of being able to read your sources, recognize most existing build tools and correctly build a Docker container to run on Coolify.
For my application, I customized 3 elements:
- the domain name (more on that later)
- the port to be exposed on my Docker container (here 8080 by default for a Spring Boot application)
- the boot command. I configured the Xms and Xmx correctly, as well as the path to the built jar:
java -Xms128m -Xmx512m -XX:MaxDirectMemorySize=128m -jar target/myJAR-0.0.1-SNAPSHOT.jar
And that's all. Most of the default configurations are fine.
Even so, there are a few things that can be improved.
First of all, of course, you probably have environment variables, I don't think I need to explain how it works :)
TIP
Please note that Coolify doesn't currently manage Secret. There is no default secret manager.
Next, you can properly configure Health Checks.
Health Checks are URLS that Coolify can use to check the health of your application.
If you're using Spring Boot Actuator, you'll have one by default: /actuator/health
.
The domain name
I mentioned above that you can configure a custom domain for your application.
I use Cloudflare to manage my DNS. All you have to do is enter a Record type A to the IP of your server on Hetzner and that's all there is to it.
I personally keep the Proxy mode, which allows me to benefit from Cloudflare's DDOS protection as well as other little features (cache, etc.).
BUT, at first it didn't work.
There's a parameter to change in Cloudflare!
In SSL :
Set encryption mode to full.
By default, it's set to flexible, i.e. your connection is HTTPS only between your visitors and Cloudflare, but then HTTP between Cloudflare and Coolify.
Not what you want.
You want HTTPS throughout the entire chain, so you need to switch to Full.
Deployment notifications
If you've followed this correctly, you now have a server running Coolify and a Kotlin application.
At the very least, it would be nice to have notifications if a deployment is successful, or if it fails, wouldn't it?
To do this, go to Coolify settings and configure your SMTP server first. (Personally, I use mailgun).
Next, go to "Notifications" in the left-hand menu, and you'll be able to activate email, Telegram or Discord notifications if you wish.
And that's it!
Of course, you might say that a database is missing?
True. But we'll see about that in a future post :)