'Turn off MySQL strict mode in docker file for Github Actions CI Build
We've recently integrated Github Actions into our projects and are wanting to switch mysql strict mode off for the github test suite.
services:
mysql:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: github_db
ports:
- 3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
I've tried adding an extra option "sql_mode" but that didn't work:
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 --sql_mode=""
I tried adding it as a command option:
command: --sql_mode=""
which gave the error Unexpected value 'command'
I've also tried adding it under variables:
variables:
strict_mode: false
But that gave the error:
Unexpected value 'variables'
Is there a way to turn strict mode off for mysql in our docker file?
Thanks in advance.
Solution 1:[1]
This is what worked for me:
- Name the mysql container so we can reference it later. Github Actions calls
docker create
under the hood, passing in theoptions
as flags.--name
is one of the available flags, spelled out in the docker docs
services:
mysql:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: github_db
ports:
- 3306
options:
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
--name=somemysql
- Make a new Github Actions step that runs prior to the step that runs the tests. This step execs into the docker container, logs into mysql, and changes the
sql_mode
, in one line.
steps:
(some steps)
...
- name: Change mysql sql_mode
run: >
docker exec somemysql mysql -u root -e "SET GLOBAL sql_mode = '';"
...
(Step that runs the tests goes here)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Schleicher |