【问题标题】:Deploy laravel using gitlab ci in VPS WITHOUT DOCKER在没有 DOCKER 的 VPS 中使用 gitlab ci 部署 laravel
【发布时间】:2018-12-06 08:44:31
【问题描述】:

现在我有兴趣使用 gitlab ci cd 在我的自定义 VPS 上部署我的 laravel 应用程序,我想在没有 docker 的情况下完成它。但是我发现的每个教程都在使用 docker。我正在寻找可以涵盖我的情况的 .gitlab.ci.yml 样本。 附言我已经为 laravel 配置了我的 vps。

【问题讨论】:

  • 您应该弄清楚手动部署需要采取哪些步骤。说 git clone、composer install、npm install、npm run、copy .env 等等。然后把它写成一个脚本
  • 我会推荐这个教程:devmarketer.io/learn/…
  • Nick Surmanidze,感谢您的评论,但我的问题是关于 .gitlab.ci.yml,但感谢您的帖子。我已经在本教程中设置了东西

标签: laravel gitlab gitlab-ci gitlab-ci-runner


【解决方案1】:

最后经过对 gitlab 本身的一些研究和试验,我想通了。我使用了 gitlab-runner 来执行 .gitlab-ci.yml 中的作业,并在一开始就编写了这个 yml 文件:

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"

如果你有更好的解决方案,可以在这里写。

【讨论】:

  • 这应该是官方的基本示例。喜欢它!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-10-10
  • 1970-01-01
  • 2018-12-04
  • 1970-01-01
  • 1970-01-01
  • 2021-07-27
相关资源
最近更新 更多