DEV Community

Pradeep Kumar
Pradeep Kumar

Posted on • Updated on

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

Updated: 2024-04-16
Read more at: https://coolify.io/docs/knowledge-base/git/gitlab/integration#private-repositories


Following Steps are outdated

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.

Top comments (2)

Collapse
 
demo_felhasznalo_5f85531e profile image
Demo Felhasznalo

Not working on Collify, this post is cloned from a very old post., you should test before posting

Collapse
 
themodernpk profile image
Pradeep Kumar

@demo_felhasznalo_5f85531e I have already written Following Steps are out dated