*ฅ^•ﻌ•^ฅ* ✨✨  HWisnu's blog  ✨✨ о ฅ^•ﻌ•^ฅ

Coolify part 2 : deploying Flask/Quart app via Github

Introduction

This is part-2, make sure you've read part-1 of the series.

Interesting fact I encountered when reading / learning about Coolify is the abundance of JS/TS project examples but non-existant for Python project especially Flask or Quart.

flask quart

I prefer to use a modular library like Flask/Quart rather than a "battery-included" library like Django. I love the freedom of choice when using Flask/Quart!

Deploy project via Coolify in your VPS

Continuing from the previous part (installing Coolify in VPS), now we can start deploying projects!

Tutorial references

There are plenty of references you can learn from, I don't want to waste my time writing / trying to explain what's been covered by others.

Videos

Articles

Requirement: watch the videos, read the articles + Coolify docs

Server setup

I encountered something odd, maybe a glitch: at first the server did not run well. It kept on saying something wrong with the yaml script. How I solved this: in Server -> Proxy tab, reset configuration to default. This fixed the error and the server proxy runs well.

proxy-reset

Deploy source: Github

Deploying via Github remains the easiest method. From the references provided above you should've got a picture on how to do this. However it's interesting there's lacking tutorials / references on how to deploy a Python webapp.

Install Github app

The references are pretty clear how to do this, also for better security and best practice: never give access to all repos, so choose only the selected repos.

Configuration

This one is an important step, as the references (JS/TS webapp) shows we only need to select the resource from Github and deploy --> DONE! But it's not the same with deploying Python based webapps. I'm using Flask and Quart, we need to add a line in the Start Command.

What you input there depends on your server runner, for example app.py program:

Below is a Flask synchronous app: flask-build

Quart asynchronous app: quart-build

As you can see the commands are similar, just depends on the server runner you're using.

<--IMPORTANT!--> The step here is crucial and could make or break your app deployment if incorrectly setup. For example in the Flask app I'm using port 9000, then in the Network config we need to expose the correct port.

coolify-port

Press SAVE to activate the new config.

Modify firewall rules

Since we are going to use some other ports for our web apps, we need to enable them via firewall rules.

ufw allow 3000/tcp  # port 3000
ufw allow 8080/tcp  # port 8080
ufw allow 9000/tcp  # port 9000

ufw status          # check the firewall status
ufw reload          # reload firewall to the latest config

Deploy the project

Assuming everything else is correct, last part is to press Deploy. You'll be taken to a new screen where the deployment process is shown underway and depending on the complexity of your app, it might take a while.

Deployment Log deploy-log

Once the deployment process is done, go to the Logs tab. If you get these kinds of logs:

running-log

That means you've successfully built your app! Now click the Links tab where you can find the url, select the url and it will open a new window in a web browser. If you see your app then deployment is a SUCCESS...congrats!

Auto-build feature

One of the best part of Coolify: it supports auto-build feature just like in Vercel and other serverless providers. That means if you did an update to your webapp and pushed the update to Github, Coolify will auto-detect the changes and automatically auto-build and re-deploy the app.