Hi.
Usually I use edbizarro/gitlab-ci-pipeline-php for CI/CD projects of laravel, but use a owned image of mysql.
But in new project I need use MariaDB, and like testing with this
stages:
- preparation
- building
- testing
- security
variables:
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: albarid_ci
MYSQL_PASSWORD: albarid_secret
MYSQL_DATABASE: albarid_ci
DB_HOST: mysql
cache:
key: $CI_BUILD_REF_NAME
composer:
stage: preparation
services:
- mariadb:10.3
image: edbizarro/gitlab-ci-pipeline-php:7.3-alpine
script:
- php -v
- echo "{\"http-basic\":{\"nova.laravel.com\":{\"username\":\"${NOVA_USERNAME}\",\"password\":\"${NOVA_PASSWORD}\"}}}" > ~/.composer/auth.json
- composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts
- cp .env.example .env
- php artisan key:generate
artifacts:
paths:
- vendor/
- .env
expire_in: 5 days
when: always
cache:
paths:
- vendor/
db-seeding:
stage: building
services:
- mariadb:10.3
image: edbizarro/gitlab-ci-pipeline-php:7.3-alpine
dependencies:
- composer
script:
- echo
- php artisan migrate:fresh --seed
artifacts:
paths:
- ./storage/logs # for debugging
expire_in: 1 days
when: on_failure
phpunit:
stage: testing
services:
- mariadb:10.3
image: edbizarro/gitlab-ci-pipeline-php:7.3-alpine
dependencies:
- composer
- db-seeding
script:
- php -v
- sudo cp /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.bak
- echo "" | sudo tee /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
- ./vendor/phpunit/phpunit/phpunit --version
- php -d short_open_tag=off ./vendor/phpunit/phpunit/phpunit -v --colors=never --stderr
- sudo cp /usr/local/etc/php/conf.d/docker-php-ext-xdebug.bak /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
artifacts:
paths:
- ./storage/logs # for debugging
expire_in: 1 days
when: on_failure
codestyle:
stage: testing
image: lorisleiva/laravel-docker:latest
script:
- phpcs --standard=PSR2 --extensions=php app
dependencies: []
phpcpd:
stage: testing
image: edbizarro/gitlab-ci-pipeline-php:7.3
script:
- test -f phpcpd.phar || curl -L https://phar.phpunit.de/phpcpd.phar -o phpcpd.phar
- php phpcpd.phar app/ --min-lines=50
dependencies: []
cache:
paths:
- phpcpd.phar
sensiolabs:
stage: security
image: edbizarro/gitlab-ci-pipeline-php:7.3
script:
- test -d security-checker || git clone https://github.com/sensiolabs/security-checker.git
- cd security-checker
- composer install
- php security-checker security:check ../composer.lock
dependencies: []
cache:
paths:
- security-checker/
Well This fails and I thin is a problem of port comunications.
Illuminate\Database\QueryException : SQLSTATE[HY000] [2002] Connection refused (SQL: SHOW FULL TABLES WHERE table_type = 'BASE TABLE')
[24](https://gitlab.castris.com/root/albarid/-/jobs/2260#L24) at /builds/root/albarid/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669
[25](https://gitlab.castris.com/root/albarid/-/jobs/2260#L25) 665| // If an exception occurs when attempting to run a query, we'll format the error
[26](https://gitlab.castris.com/root/albarid/-/jobs/2260#L26) 666| // message to include the bindings with SQL, which will make this exception a
[27](https://gitlab.castris.com/root/albarid/-/jobs/2260#L27) 667| // lot more helpful to the developer instead of just the database's errors.
[28](https://gitlab.castris.com/root/albarid/-/jobs/2260#L28) 668| catch (Exception $e) {
[29](https://gitlab.castris.com/root/albarid/-/jobs/2260#L29) > 669| throw new QueryException(
[30](https://gitlab.castris.com/root/albarid/-/jobs/2260#L30) 670| $query, $this->prepareBindings($bindings), $e
[31](https://gitlab.castris.com/root/albarid/-/jobs/2260#L31) 671| );
[32](https://gitlab.castris.com/root/albarid/-/jobs/2260#L32) 672| }
[33](https://gitlab.castris.com/root/albarid/-/jobs/2260#L33) 673|
[34](https://gitlab.castris.com/root/albarid/-/jobs/2260#L34) Exception trace:
[35](https://gitlab.castris.com/root/albarid/-/jobs/2260#L35) 1 Doctrine\DBAL\Driver\PDOException::("SQLSTATE[HY000] [2002] Connection refused")
[36](https://gitlab.castris.com/root/albarid/-/jobs/2260#L36) /builds/root/albarid/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:31
[37](https://gitlab.castris.com/root/albarid/-/jobs/2260#L37) 2 PDOException::("SQLSTATE[HY000] [2002] Connection refused")
[38](https://gitlab.castris.com/root/albarid/-/jobs/2260#L38) /builds/root/albarid/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:27
[39](https://gitlab.castris.com/root/albarid/-/jobs/2260#L39) Please use the argument -v to see more details.
Any ideas?
I added - mysql -u root -proot
before seeding for see reponse of server.
$ echo
26 $ mysql -u root -proot
27 ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2)