Using Coolify for deploying 11ty
Published:
I’ve been meaning to try Coolify for ages, as a self-hosted Netlify alternative. A couple of recent discussions prompted me to try it out, and after a couple of stumbling blocks I’ve finally got it working.
Setting up Coolify
This was pretty straightforward. Following the instructions on their website, I ran the install script on my VPS:
curl -fsSL https://cdn.coollabs.io/coolify/install.sh | bash
After waiting a while, this installed and started the Coolify service, which I could access at http://<my server ip>:8000
. I then followed the onboarding steps to create a new project, and deployed one of their preconfigured services as a test.
DNS woes
The issue I had was that Coolify, ideally, will use port 80, but I was installing it on a server that I had been using for a while, running Nginx. I played around with using reverse proxies via Nginx, but needing to create a new configuration for each site I wanted to deploy was a massive pain and I wound up accidentally taking my website offline.
Instead, I decided I was better off starting fresh. I provisioned a new VPS with Contabo, and even got a better deal than the one I was previously using - 6 cores, 16GB RAM, and a 400GB SSD for the same price as the previous VPS. Then I bought a new domain, https://srvc.lol[1], and pointed it at the new server with two records: one for the root domain, and another for a wildcard subdomain.
Then I created a new Server in Coolify, and made sure that it had the correct domain name for both the server domain, and the wildcard subdomain:
Now, when I deploy new services, Coolify will automatically generate a subdomain for it at https://<service-name>.srvc.lol
and configure HTTPS and routing for it.
Deploying 11ty using Docker
So, the main thing I wanted to host was my blog (this blog, as it happens). Coolify can just deploy static sites directly, but I have some custom routing rules in my Nginx config that I wanted to carry over, so I thought a Docker image would be the easiest way to go.
My first attempt at this was to build a custom Docker image that would copy the build out of my 11ty site, and then run Nginx to serve it:
FROM nginx:alpine
COPY _site /var/www/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
This worked, and I was able to successfully deploy my site, but I had issues building the image properly in my CI pipeline. I suspect it was to do with environment variables not being set correctly, but it was turning into a massive headache and I just wanted something simple.
Using Coolify’s static site builder
As I mentioned, Coolify can just deploy static sites directly, and use a Git repository as the source. I just pointed it at the repository for my blog, configured the environment variables I needed at build time (and made sure to check the “Build variable” checkbox), and it just deployed directly.
Then I added the correct domain, and pointed the DNS records at the new server. Voila! My site was up and running. I then just added the custom redirects I needed in Bunny (affiliate link), and once the DNS had propagated my site was live.
Auto deploying
If you’re using Github, Coolify can automatically deploy your site whenever you push to the repo using an app that comes preinstalled. Unfortunately, I’m using Gitea. However, Coolify can also just use a webhook to trigger a build, so I added the webhook to my repo, configured the secret, and now my site is automatically deployed whenever I push to Gitea.
Next steps
Coolify looks really useful, especially for deploying the lots of different services I use - I was especially looking forward to being able to deploy “serverless” functions, which I think I can easily do with Dockerfiles.
Next up, I need to work out how to transfer my Git server to Coolify, which I’m sure will be a pain, and then the handful of other services I’ve got running on my old VPS. Once they’re done, I’ll retire the old server and run everything on Coolify.
Useful links
Here’s a list of useful links that were shared with me (courtesy of Flamed):
- Diving into Coolify by Matt Stein
- Self-hosting Your Website with Coolify v4: A Step-by-Step Guide: billyle.dev
- Fix Missing 404 Pages for Coolify Static Site Deployments: billyle.dev