Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploy laravel using gitlab ci in VPS WITHOUT DOCKER

Nowadays I'm interested in deploying my laravel application on my custom VPS using gitlab ci cd and I wanted to do it without docker. But every tutorial I find is using docker. I was searching for a sample of .gitlab.ci.yml that will cover my situation. P.S. I've already configured my vps for laravel.

like image 319
ata Avatar asked Nov 01 '25 09:11

ata


1 Answers

Finally after some research in gitlab itself and trials, I figured it out. I used gitlab-runner which executes the jobs in .gitlab-ci.yml And wrote this yml file for the very beginning:

before_script:
  - echo "Before script"
  - cd /var/www/html/project
building:
  stage: build
  script:
    - git pull origin develop
    - composer install
    - cp .env.example .env
    - php artisan key:generate
    - php artisan migrate --seed
    - sudo chown -R my-user:www-data /var/www/html/project/
    - find /var/www/html/project -type f -exec chmod 664 {} \;
    - find /var/www/html/project -type d -exec chmod 775 {} \;
    - chgrp -R www-data storage bootstrap/cache
    - chmod -R ug+rwx storage bootstrap/cache
testing:
  stage: test
  script:
    - php ./vendor/bin/phpunit
deploying:
  stage: deploy
  script:
    - echo "Deployed"

If you have a better solution, you can write here.

like image 78
ata Avatar answered Nov 03 '25 09:11

ata



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!