My Elixir/Phoenix application uses docker-compose and mysql. I decided on CircleCI for continuous-integration (CI) for its free container support. There were a few problems making it all run inside the CircleCI container environment.
CircleCI defaults to a docker version < v1.10.
Since I am using docker-compose locally, I also want to use the same setup
during CI. Docker-compose requires a docker server whose version is greater or
equal to v1.10. I override the existing docker version on the CircleCI container
host through the machine
mapping.
# circle.yml
machine:
pre:
- curl -sSL https://s3.amazonaws.com/circle-downloads/install-circleci-docker.sh | bash -s -- 1.10.0
Docker-compose is not available on the container host by default.
I need to install docker-compose after installing the required docker version.
# circle.yml
dependencies:
pre:
- curl -L https://github.com/docker/compose/releases/download/1.8.0-rc2/docker-compose-`uname -s`-`uname -m` > ../bin/docker-compose && chmod +x ../bin/docker-compose
MySQL is installed on the container host (port conflict).
My application uses mysql. Docker-compose setup starts mysql on port 3306
.
The 3306
port is the default mysql port and conflicts with the mysql-server
installation on the host container. I remove the host’s mysql installation.
# circle.yml
machine:
pre:
- sudo apt-get --purge autoremove -y mysql-server
Full configuration
# circle.yml
machine:
pre:
- curl -sSL https://s3.amazonaws.com/circle-downloads/install-circleci-docker.sh | bash -s -- 1.10.0
- sudo apt-get --purge autoremove -y mysql-server
services:
- docker
dependencies:
pre:
- curl -L https://github.com/docker/compose/releases/download/1.8.0-rc2/docker-compose-`uname -s`-`uname -m` > ../bin/docker-compose && chmod +x ../bin/docker-compose
- docker-compose pull
override:
- echo 'skip dependencies-override'
test:
pre:
- echo 'skip test-pre'
override:
- docker-compose up mysql:
background: true
- bin/wait_for_mysql
- bin/app.ci
I override the dependencies
and pre-test
mappings with echo
statements
because:
- CircleCI infers the wrong dependencies for my app.
- CircleCI infers the wrong pre-test actions for my app.
My helper script, bin/app.ci
pulls the app dependencies and properly runs
my tests.