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 scriptonline Thomas– online Thomas2018-12-06 09:05:19 +00:00Commented Dec 6, 2018 at 9:05
-
I would recommend this tutorial: devmarketer.io/learn/…Nick Surmanidze– Nick Surmanidze2018-12-06 10:06:50 +00:00Commented Dec 6, 2018 at 10:06
-
1Nick 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 tutorialata– ata2018-12-06 11:11:01 +00:00Commented Dec 6, 2018 at 11:11
Add a comment
|
1 Answer
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.
5 Comments
William Randokun
This should be the official basic example. Love it!
Shashank Shah
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.
ata
@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.
Shashank Shah
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.
Shashank Shah
stackoverflow.com/questions/76629361/… Can you please check this question