Hi.
I've got the default mysql container running in our Bitbucket Pipeline. When running our db level unit tests, we are getting some errors due to a difference in configuration between the default image being used by Bitbucket's Pipeline and the configuration we run locally and in production.
Out of the 2,500 or so tests, we have 4 actual failures (the code has changed, the tests fail, so this is a good thing at the moment) and an additional 113 errors. The 113 are not present when/if we run the tests locally or in our production environments.
According to the Docker Hub image documentation (https://hub.docker.com/_/mysql/ and see "Using a custom MySQL configuration file") I can see that I could mount my my.cnf file into the container, but I do not know how to do that for the Bitbucket pipeline.
The Bitbucket documentation (https://confluence.atlassian.com/bitbucket/test-with-databases-in-bitbucket-pipelines-856697462.html#TestwithdatabasesinBitbucketPipelines-ConnectingtoMySQL) is a bit vague on this and simply refers to the Docker Hub image documentation (see previous link).
When running the mysql container inside Bitbucket, it makes no mention of loading any config at all.
At this stage, I'm not sure where to go next.
Any help would be appreciated.
Hey @Richard Quadling,
Pipelines Service containers do not support mounting in any volumes at this time, so you have 2 approaches to solving this.
1) Keep using Service Containers, but fork and customise the community mysql image. You could even use a scheduled pipeline to do this for you.
This involves creating a new Dockerfile; eg.
FROM mysql
ADD ./mysql-configuration.cnf /etc/mysql/conf.d/
and a pipeline.yml like:
pipelines:
custom: # Pipelines that can be scheduled or triggered manually
update-mysql-image: # The name that is displayed in the list in the Bitbucket Cloud GUI
- step:
script:
- docker login --username $DOCKER_USERNAME --password $DOCKER_PASSWORD # assuming you've created a Dockerhub Account
- docker build -t "richard_quadling/mysql:latest" . # assuming the Dockerfile is in the root.
- docker push richard_quadling/mysql:latest # push the image to Dockerhub
services:
- docker
2) You can use the Docker service to start the mysql service yourself, mounting the configuration, just as you would locally.
pipelines:
default:
- step:
script:
- docker run --name some-mysql -v $BITBUCKET_CLONE_DIR/mysql/conf.d:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag # Assuming your configuration is located in /mysql/conf.d in your repository
- # the rest of the build
services:
- docker
which allows you to manage all aspects of the mysql engine, but requires you to manage the service lifecycle, monitor it, and extract any logs as part of your build process.
Hope that helps,
Seb
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register NowOnline forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.