Hosting my Docker Container on a VPS with Coolify as a PaaS with GitHub Autodeploys
Date: 2024-10-16 | create | tech | docker | hosting | cloud | coolify |
I've been using Coolify the past few weeks to transition several of my side project sites to a VPS - both as an experiment and cost-cutting (and capping) measure.
In this screen cast I walk through setting up my newest project One Million Checkboxes on my VPS.
App Setup
- Docker Container that spins up an F# webapp
- Code hosted on Github private repo
Steps to Host my Docker Container on Coolify
Create new Deploy Key (SSH)
- Go to Coolify instance
- Go to
Keys and Tokens
- Click
Add
- Generate a new key and give it a descriptive name (I like
DATE_deploy-APPNAME
)
Configure GitHub repo to allow you to deploy from it
- Go to your GitHub Repo
- Go to
Settings
->Deploy keys
- Click
Add deploy key
- Copy / paste your PUBLIC deploy key here
- Save by hitting
Add Key
Create your app on Coolify
- Go to Coolify instance
- Go to
Dashboard
->Projects
- Select the Project you want to make the App in
- Click
New
->Private Repository (with Deploy Key)
- Select the private key you just made above
- Fill
Repository Url
withgit@...
from your GitHub Repo (IME this works better than https) - Fill
BuildPack
= Dockerfile - Fill
Branch
= main / master / whatever
Deploy your App
- On the configuration page - click Deploy
Setup Autodeploys from GitHub on branch push:
- Go to Coolify instance -> App Configuration page
- Go to
Webhooks
section - Find GitHub webhook and add a GitHub webhook password (you can create one)
- Go to your GitHub repo
- Go to
Settings
->Webhooks
- Click
Add Webhook
Payload URL
= the url in CoolifySecret
= The webhook password you just made- Send the push event
- Set to
Active
- Save with
Add webhook
Debugging Failures
There's bound to be some configuration stuff that your app needs to deploy.
Here are some I've needed to set myself:
can't open '/artifacts/h80448k08g00c4oggg84c4cc/Dockerfile': No such file or directory
I build my apps like monorepos so my Dockerfile can't be found in the root directory.
To fix:
- Go to
Configuration
- Go to
Build
section - Set
Base Directory
to where my Dockerfile lives - for me that's/App
- Click
Save
to save the configuration - Click
Deploy
to deploy with the new settings
URL gives Bad Gateway
For me this usually happens when my app is running fine but it's looking at the wrong port.
By default Coolify seems to point incoming traffic to port 3000 but my apps usually listen on 8080.
To fix:
- Go to
Configuration
- Go to
Network
section - Set
Ports Exposes
to the port you have - for me it's 8080 - Click
Save
to save the configuration - Click
Redeploy
to deploy with the new config
Next
Overall I've enjoyed using Coolify but it does have some rough edges as it's new and built by a solodev.
Let me know if you like this kind of post / want more on this topic and I'll make more guides.
If you liked this post you might also like:
Want more like this?
The best / easiest way to support my work is by subscribing for future updates and sharing with your network.