When we implemented support for cleartext authentication plugin, we had to check in the (arch-dependent) auth_test_plugin.so files since the default mysql docker images doesn't ship with that plugin. I filed an issue with the MySQL docker repo to see if they'd be open to building and tagging a mysql-community-test package variant. They said no, and suggested that we build our own MySQL image. This PR does just that.
Here's how we do it:
Add another Dockerfile for MySQL, called Dockerfile.mysql, that takes MYSQL_VERSION as a build argument. We use a multi-stage build to install mysql-community-test package on top of the official image. Then we we copy all the plugins from /usr/lib/mysql/plugin/ to the final image that simply inherits from the official image. This means that we're deciding to not build a final image that has mysql-community-test but only its plugins. The reason for this is that when we install the mysql-community-test package, it initializes the database and writes data to /var/lib/mysql. If you boot the image as is, it won't be set up properly since the entrypoint looks for /var/lib/mysql to decide whether or not to do the full setup. This is why the official Docker build deletes /var/lib/mysql. Since we don't want to own/duplicate the intricacies of setting up a clean-slate MySQL image, it's better that we just copy over what we need to the official image.
When we implemented support for cleartext authentication plugin, we had to check in the (arch-dependent)
auth_test_plugin.so
files since the defaultmysql
docker images doesn't ship with that plugin. I filed an issue with the MySQL docker repo to see if they'd be open to building and tagging amysql-community-test
package variant. They said no, and suggested that we build our own MySQL image. This PR does just that.Here's how we do it:
Add another Dockerfile for MySQL, called
Dockerfile.mysql
, that takesMYSQL_VERSION
as a build argument. We use a multi-stage build to installmysql-community-test
package on top of the official image. Then we we copy all the plugins from/usr/lib/mysql/plugin/
to the final image that simply inherits from the official image. This means that we're deciding to not build a final image that hasmysql-community-test
but only its plugins. The reason for this is that when we install themysql-community-test
package, it initializes the database and writes data to/var/lib/mysql
. If you boot the image as is, it won't be set up properly since the entrypoint looks for/var/lib/mysql
to decide whether or not to do the full setup. This is why the official Docker build deletes/var/lib/mysql
. Since we don't want to own/duplicate the intricacies of setting up a clean-slate MySQL image, it's better that we just copy over what we need to the official image.