Reputation: 739
We had a working build pipeline in Bitbucket until our recent Laravel 11 upgrade, and now it is unable to find the mysql driver to connect to the DB. Here is the error when running migrations/tests:
In Connection.php line 825:
could not find driver (Connection: mysql, SQL: select exists (select 1 from
information_schema.tables where table_schema = 'homestead' and table_name
= 'migrations' and table_type in ('BASE TABLE', 'SYSTEM VERSIONED')) as `ex
ists`)
In Connector.php line 66:
could not find driver
Here was our working (L9-10) bitbucket-pipelines.yml:
image: php:8.2-fpm
definitions:
services:
mysql:
image: mysql:8.0
environment:
MYSQL_DATABASE: 'homestead'
MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
MYSQL_USER: 'homestead'
MYSQL_PASSWORD: 'secret'
steps:
- step: &install-dependencies
name: Setup
caches:
- composer
- node
script:
- docker-php-ext-install pcntl
- apt-get update && apt-get install -qy git curl unzip
- curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
- composer install --no-progress --no-scripts
- curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
- apt-get install -y nodejs
- npm i --no-progress
- npm run build
artifacts:
- vendor/**
- node_modules/**
- public/**
.scripts:
- &setup-tests |
apt-get update && apt-get install -qy libmcrypt-dev default-mysql-client
echo "memory_limit = 256M" > $PHP_INI_DIR/conf.d/php-memory-limits.ini
cp .env.pipelines .env
php artisan key:generate
php artisan storage:link
pipelines:
# default pipeline
branches:
'{develop,staging,master}':
- step: *install-dependencies
- parallel:
- step:
name: Unit
script:
- *setup-tests
- php artisan test tests/Unit
services:
- mysql
- step:
name: Feature
script:
- *setup-tests
- php artisan test tests/Feature
services:
- mysql
I am able to run tests locally using the mysql driver, so it seems like there's an extension we're missing in the image.
Upvotes: 0
Views: 60
Reputation: 739
Fixed by adding docker-php-ext-install pdo_mysql
to the setup-tests
script.
Upvotes: 0