I’m having some issues getting my unit tests to connect to the MySQL database. I’ve included my current config.yml below. I am running docker-compose, then installing dockerize so I can wait for port 3306 to be open (which should mean that my database is ready to establish connections), but then when the final step runs, it fails with the message “MySQL server has gone away”. I’ve tried increasing the wait timeout and the maximum allowed packet size from the my.cnf file, but no luck so far.
I think the issue must be that the MySQL server isn’t ready when the tests run, because when I rerun the job with ssh, and connect to the machine, I am able to run my unit tests without this error. I thought this was supposed to be the problem that dockerize solved though?
Any help is appreciated, and please let me know if something requires clarification, thank you.
version: 2 jobs: build: machine: true steps: - checkout - run: name: Initialize containers with docker-compose.yml command: | chmod -R g+w . docker-compose up -d - run: name: install dockerize command: wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && sudo tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz environment: DOCKERIZE_VERSION: v0.6.1 - run: name: wait for db command: dockerize -wait tcp://localhost:3306 -timeout 1m - run: name: run unit tests command: | docker exec project_cashout-php_1 /bin/bash -c "vendor/bin/phpunit"