I use docker and bitbucket pipelines and I am running database phpunit tests in the local docker container and in bitbucket pipelines. This works. Within the phpunit.xml.dist I indicate the database url.
In the local docker container this is: mysql://user:password@mysql-database:3306/database
In bitbucket pipeline, however: mysql://user:password@localhost:3306/database
I do not want to change the phpunit.xml.dist every time, so the question is, how could I run both on the same host (I do not care if it is "localhost" oder "mysql-database")? I tried to set the container_name in bitbucket-pipelines.yml, but it doesn't work:
definitions:
services:
mysql:
image: mysql:5.6
container_name: mysql-database
environment:
MYSQL_DATABASE: 'database'
MYSQL_ROOT_PASSWORD: 'root'
MYSQL_USER: 'user'
MYSQL_PASSWORD: 'password'
Found the solution: a) as "goto" mentioned: don't set the database credentials in the phpunit.xml.dist b) my .env-file credentials were ignored, so I had to set the environment variables in the bitbucket settings