Note

How to Deploy Strapi on Coolify from a GitHub Repo

You can deploy Strapi on Coolify in 1 click from the projects dashboard – that's great for new projects, but what if you have an existing Strapi project in GitHub you want to deploy? This post will show you how!

Deploy as 2 Resources: Postgres + Strapi

If you're deploying from GitHub, we deploy 2 things separately, and use them together:

  1. A Postges database for the data

  2. Your Strapi repository

Coolify project resources showing 2 boxes highlighting the strapi app and the postgres db
Strapi app, and Postgres database deployed in Coolify

1. Deploy Postgres

First, install PostgreSQL from the resources to your project:

Coolify dashboard showing search for postgres, with postgresql in the results
Install PostgreSQL

Set it up like this - give it a username, and database name, and update the password if you like.

Coolify config page for database highlighting username, databasename, and network set to 5432:5432, Proxy port set to 5432
For some raeson I have portmappings set to 5432:5432 - seems to work!

You can set the public port to 5432, and check make it publicly available if you're connecting from outside your server. Press deploy.

2. Deploy GitHub repo

Once that's running, it's time to deploy your Strapi GitHub repo. Choose public or private respository, whatever is your repo:

coolify new resource dashboard showing github based application options
Coolify - deploy a Git Based Application

Then to configure it, use this stuff:

Coolify settings highlighting Build: npm install, Build Command: npm run build --production, Start Command: npm run start

Set the Build: npm install, Build Command: npm run build --production, Start Command: npm run start

Then set Ports Exposes as 1337, and 1337:1337

Screenoshot of coolify dashboard showing fields: Ports Exposes as 1337, and 1337:1337

Connect Strapi to Postgres

Finally, to connect Strapi to your Postgres DB, you need to add the DB Name, DB Host, DB Username, DB Password, and DB Port to your Environmental Variables of the Strapi app.

This is the bit that tripped me up. If you're deploying your Strapi application on the same server as the database, just use the values that are shown in the internal connection string. Head back to your database config page, and you'll see this in the following field as Postgres URL (internal):

Highlight on the coolify dashboard, showing the connection string
The postgres string has all the details for Strapi

The hostname for internal will just be a random word. Whereas if you're connecting from outside, check the publicly available box, and follow the external string that will show up.

That should be it, you can check the logs to see if it connects:

Logs interface of the coolify dashboard for Strapi deployment, showing successful deployment
Successful Strapi deploy logs

Overall, this is going to save me $200 a month from Digital Ocean app platform!