I want to create a docker image on top of the mysql one that already contains the necessary scheme for my app.
I tried adding lines to the Dockerfile that will import my scheme as a sql file. I did so as such (my Dockerfile):
FROM mysql ENV MYSQL_ROOT_PASSWORD="bagabu" ENV MYSQL_DATABASE="imhere" ADD imhere.sql /tmp/imhere.sql RUN "mysql -u root --password="bagabu" imhere < /tmp/imhere.sql"
To my understanding, that didn't work because the mysql docker image does not contain a mysql client (best practices state "don't add things just because they will be nice to have") (am I wrong about this?)
what might be a good way to do this? I have had a few things in mind, but they all seem like messy workarounds.
- install the mysql client, do what I have to do with it, then remove/purge it.
- copy the mysql client binary to the image, do what I have to do, then remove it.
- Create the schema in another sql server and copy the db file themselves directly (this seems very messy and sounds to me like a contaminated pool of problems)
Any suggestions? Hopefully in a way that will be easy to maintain later and maybe conform with the best practices as well?