4

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.

3
  • You should figure out what steps to take for a manual deploy. Say git clone, composer install, npm install, npm run, copy .env etc. And make it into a script Commented Dec 6, 2018 at 9:05
  • I would recommend this tutorial: devmarketer.io/learn/… Commented Dec 6, 2018 at 10:06
  • 1
    Nick Surmanidze, thank you for your comment, but my question was about .gitlab.ci.yml, but thank you for your post. I've already setup things in this tutorial Commented Dec 6, 2018 at 11:11

1 Answer 1

9

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.

Sign up to request clarification or add additional context in comments.

5 Comments

This should be the official basic example. Love it!
What executer you have used while registering the new runner? There are many options like a shell, ssh, docker, etc. which once you have used.
@ShashankShah At that moment I used ssh executor. However, this is the first solution I had in mind then. Now I would use a very different approach to handle this.
Hi @ata thanks for the quick reply! I tried the same but I am getting the error "ERROR: Preparation failed: ssh command Connect() error: getting host key callback: open /root/.ssh/known_hosts: no such file or directory" I am not sure what to enter in Enter the path to the SSH identity file in the last step of runner registration.
stackoverflow.com/questions/76629361/… Can you please check this question

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.