DEV Community

Pradeep Kumar
Pradeep Kumar

Posted on • Updated on

Connect Coolify (heroku alternative) with Gitlab (self-hosted) & Deploy Laravel using Dockerfile

Step 1: Connect Coolify with GitLab:

  • Login coolify dashboard
  • Click on Git Sources
  • Click on Add > GitLab.com
  • First enter the HTML URL, it the url where gitlab is hosted
  • Then enter API which is <gitlab-url>/api
  • Then Choose GitLab Application Type, it should be Instance-wide application (self-hosted)
  • Now, visit your <gitlab-url>/admin/applications and click on New Application. Enter the application name eg: coolify, in Redirect URI enter the Webhook URL from your coolify page: Screenshot

And choose api, read_respository, email then Click Save application.

On next page, you'll the the OAuth ID, Application ID & Secret:
Screenshot - OAuth ID

Once, this is done, we're ready to deploy the apps.

Step 2: Create a repository and clone

Step 3: Setup laravel

Step 4: Create a Dockerfile at the root of the project:

FROM docker.io/bitnami/laravel:9
COPY . .
RUN composer install
CMD php artisan serve --host=0.0.0.0
EXPOSE 443
Enter fullscreen mode Exit fullscreen mode

Commit all the files.

Step 5: Point your domain to coolify ip.

To do this you need to add 2 A record from your domain control panel:

A     <project>.domain-name.com       xxx.xxx.xxx.xxx
A     *.<project>.domain-name.com     xxx.xxx.xxx.xxx
Enter fullscreen mode Exit fullscreen mode

xxx.xxx.xxx.xxx is your coolify server ip.

Step 6: Deploy Laravel

  • From coolify dashboard, click on Applications
  • Click on "+" icon and select source
  • Select your repository
  • Select the Destination
  • Select Docker at "Configure Build Pack" screen
  • Now, on General page, choose following options:
URL (FQDN): <project>.domain-name.com
Port: 8000
Dockerfile Location: /Dockerfile
Base Directory: (keep the default value)
Enable Automatic Deployment: Enabled
Enable MR/PR Previews: Enableed
Debug Logs: Enabled
Enter fullscreen mode Exit fullscreen mode
  • Click Save and Click on Build Logs, after success build visit the url, you will be able to see the Laravel.

Discussion (0)