Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How do I amend the default configuration of a mysql service in BitBucket Pipeline?

Richard Quadling
Contributor
April 12, 2018

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.

 

2 answers

1 accepted

1 vote
Answer accepted
SebC
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 25, 2018 edited

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 

0 votes
AS November 6, 2020 edited

Edit:
Posted wrong answer.
Please remove this.

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

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 Now
AUG Leaders

Atlassian Community Events