gpt4 book ai didi

laravel - Gitlab CI和Docker迁移时引发错误

转载 作者:行者123 更新时间:2023-12-02 18:32:59 25 4
gpt4 key购买 nike

我正在尝试使用GitLab CI和Docker运行PHPUnit测试。但是,当我要进行迁移时,会出现以下错误:

$ php artisan migrate



[PDOException]
SQLSTATE[HY000] [2002] No such file or directory




ERROR: Build failed with: exit code 1

这是我的 .gitlab-ci.yml文件:
# Before Script
before_script:
- composer self-update
- composer config -g github-oauth.github.com $GITHUB_AUTH_KEY
- composer install --prefer-dist
- cp .env.example .env
- echo "DB_HOST=mysql" >> .env
- echo "CHALLONGE_API=$CHALLONGE_API" >> .env
- echo "CHALLONGE_SUBDOMAIN=$CHALLONGE_SUBDOMAIN" >> .env
- echo "EBOT_DB_PASSWORD=$EBOT_DB_PASSWORD" >> .env
- echo "SOCKET_IO_IP=$SOCKET_IO_IP" >> .env
- echo "REDIS_HOST=$REDIS_HOST" >> .env
- php artisan key:generate
- php artisan migrate

# Services
services:
- mysql:lastest
- redis:latest

# Variables
variables:
MYSQL_USER: homestead
MYSQL_PASSWORD: secret
MYSQL_ROOT_PASSWORD: secret
MYSQL_DATABASE: $DB_NAME

# PHP 5.6
php:5.6:
image: bobey/docker-gitlab-ci-runner-php5.6
script:
- echo "Running PHPUnit Tests"
- php vendor/bin/phpunit --colors --debug --coverage-text

任何想法为什么会引发此错误?

最佳答案

我假设您的.env文件中的DB_HOST设置为localhost,它将尝试通过unix套接字连接到MySql服务器。但是,开箱即用不支持该功能。尝试在测试环境中将其设置为mysql,如docs:http://docs.gitlab.com/ee/ci/services/mysql.html中所述。

关于laravel - Gitlab CI和Docker迁移时引发错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34057854/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com