Example Yaml configuration for a project with a MySQL service dependency. Note that the mysql service will be accessible at database:3306
.
pipeline:
test:
image: golang
commands:
- go get
- go test
services:
database:
image: mysql
environment:
- MYSQL_DATABASE=test
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
The official mysql image provides environment variables used at startup to create the default username, password, database and more. Please see the official image documentation for more details.
services:
database:
image: mysql
environment:
+ - MYSQL_DATABASE=test
+ - MYSQL_ALLOW_EMPTY_PASSWORD=yes
If you need to start the mysql container with additional runtime options you can override the entrypoint and command arguments.
services:
database:
image: mysql
+ entrypoint: [ "mysqld" ]
+ command: [ "--character-set-server=utf8mb4" ]
If you are unable to connect to the mysql container please make sure you are giving mysql adequate time to initialize and begin accepting connections.
pipeline:
test:
image: golang
commands:
+ - sleep 15
- go get
- go test
services:
database:
image: mysql
If you are still unable to connect to the mysql container, please make sure you are using the service name as the hostname.
- mysql -u root -h 127.0.0.1:3306
+ mysql -u root -h tcp://database:3306
Questions?
We are always happy to help with questions you might have. Search our documentation or check out answers to common questions. You can also post questions or comments to our community forum.