I wish to build a docker image with an initialised database. This initial data will contain a default client ref value 'XXX'.
Here's my Dockerfile:
FROM mysql/mysql-server:5.7
COPY data.sql /docker-entrypoint-initdb.d/
When starting up the container of this image, I need to replace the ref value with the user's particular value, 'ABCD', which will come from an environment variable set by a docker compose file.
So the update query to run is something like:
update client set ref='ABCD' where ref='XXX'
How do I get the Dockerfile to do this? I don't think it can be a RUN command as I don't want the update to be part of the image build, but part of the startup of the image (it's fine if it runs this update on every startup).
I have all the usual mysql env varibles set (MYSQL_ROOT_PASSWORD/MYSQL_ROOT_HOST/MYSQL_DATABASE/MYSQL_USER/MYSQL_PASSWORD) and hope to refer to another env var for the desired ref to be setting. Keen to see this could be done as raw commands as well as a script.