trilogy-libraries / trilogy

Trilogy is a client library for MySQL-compatible database servers, designed for performance, flexibility, and ease of embedding.
MIT License
697 stars 68 forks source link

Build mysql test image for CI #174

Closed ngan closed 5 months ago

ngan commented 5 months ago

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.