Blog post about Coolify
This commit is contained in:
parent
158efda026
commit
f790ee26cf
77
src/blog/posts/2024/10/using-coolify-for-deploying-11ty.md
Normal file
77
src/blog/posts/2024/10/using-coolify-for-deploying-11ty.md
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
---json
|
||||||
|
{
|
||||||
|
"title": "Using Coolify for deploying 11ty",
|
||||||
|
"date": "2024-10-19T08:20:22.649Z",
|
||||||
|
"tags": [
|
||||||
|
"eleventy"
|
||||||
|
],
|
||||||
|
"excerpt": "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"
|
||||||
|
}
|
||||||
|
---
|
||||||
|
|
||||||
|
I've been meaning to try [Coolify](https://coolify.io) 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](https://coolify.io/docs/installation), I ran the install script on my VPS:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
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:
|
||||||
|
|
||||||
|
![Screenshot of the Coolify server configuration. The name field says "srvc.lol", the wildcard subdomain field says "https://srvc.lol". The IP address field is starred out.](./src/images/coolify-server.png)
|
||||||
|
|
||||||
|
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:
|
||||||
|
|
||||||
|
```dockerfile
|
||||||
|
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](https://coolify.io/docs/applications/#static-site-is-it-a-static-site) 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)](https://bunny.net?ref=6x27cy5y27), 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.
|
||||||
|
|
||||||
|
![Screenshot of the Webhook configuration screen in Gitea. The URL field contains the Coolify deployment endpoint, the HTTP method is "POST", and the secret is filled in. The "Trigger on" radio button is set to "Push Events".](./src/images/gitea-webhook.png)
|
||||||
|
|
||||||
|
## 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](https://flamedfury.com)):
|
||||||
|
|
||||||
|
* [Diving into Coolify by Matt Stein](https://mattstein.com/thoughts/diving-into-coolify/)
|
||||||
|
* [Self-hosting Your Website with Coolify v4: A Step-by-Step Guide: billyle.dev](https://billyle.dev/posts/self-hosting-your-website-with-coolify-v4-a-step-by-step-guide)
|
||||||
|
* [Fix Missing 404 Pages for Coolify Static Site Deployments: billyle.dev](https://billyle.dev/posts/fix-missing-404-pages-for-coolify-static-site-deployments)
|
||||||
|
|
||||||
|
[^1]: $1.52 for the first year from [Porkbun](https://porkbun.com)
|
BIN
src/images/coolify-server.png
Normal file
BIN
src/images/coolify-server.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 76 KiB |
BIN
src/images/gitea-webhook.png
Normal file
BIN
src/images/gitea-webhook.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 99 KiB |
Loading…
Reference in New Issue
Block a user