【发布时间】:2021-03-17 17:27:31
【问题描述】:
我允许自己发布一个支持主题,因为我被困在 Laravel 项目的 gitlab 的 CI 配置文件问题上几天
我的 .gitlab-ci.yml 文件
stages:
- build
- test
- deploy
- prod
cache:
paths:
- vendor/
- node_modules/
- .yarn
build env file:
stage: build
image: alpine:latest
script:
- cp .env.example .env
- sed -i “s/{{DB_USER}}/$MYSQL_USER/g” .env
- sed -i “s/{{DB_PASSWORD}}/$MYSQL_ROOT_PASSWORD/g” .env
artifacts:
paths:
- .env.example
composer:
stage: build
image: edbizarro/gitlab-ci-pipeline-php:8.0-alpine
cache:
key: ${CI_COMMIT_REF_SLUG}-composer
paths:
- vendor/
script:
- composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts
artifacts:
expire_in: 1 month
paths:
- vendor/
- .env
yarn:
stage: build
image: edbizarro/gitlab-ci-pipeline-php:8.0-alpine
cache:
key: ${CI_COMMIT_REF_SLUG}-npm
paths:
- node_modules/
# - Modules/mon-mondules/node_modules/ si utilisation de modules supplementaire
script:
- yarn config set cache-folder .yarn
- yarn install --pure-lockfile
# - cd Modules/mon-modules/node_modules/ && npm install $$ npm run production
artifacts:
expire_in: 1 month
paths:
- public/css/
- public/js/
- public/modules/
- public/mix-manifest.json
testing:
stage: test
services:
- mysql:5.7
image: edbizarro/gitlab-ci-pipeline-php:8.0-alpine
script:
# - ./vendor/bin/security-checker security:check
- ./vendor/phpunit/phpunit --no-coverage
deploy:
stage: deploy
image: edbizarro/gitlab-ci-pipeline-php:8.0-alpine
dependencies:
- build env file
script:
- php artisan key:generate
- php artisan migrate:refresh --seed
deploying to prod:
stage: prod
image: edbizarro/gitlab-ci-pipeline-php:8.0-alpine
script:
- echo "Deploy all the things!"
when: manual
only:
- master
前两个阶段运行良好,但到了测试阶段,管道失败并出现以下错误:
SQLSTATE[HY000] [1045] Access denied for user 'root'@'172.17.0.4' (using password: NO) (SQL: select * from information_schema.tables where table_schema = laravel and table_name = migrations and table_type = 'BASE TABLE')
我不知道如何解决这个问题,你能帮帮我吗?
【问题讨论】:
标签: laravel gitlab dockerfile gitlab-ci