From 19f9b25a4612278f878202683677f928ed7f5c63 Mon Sep 17 00:00:00 2001 From: sakanaproductions Date: Fri, 30 Jun 2017 17:48:24 -0700 Subject: [PATCH] fixed issue #1017, added ENV variables back to Dockerfile and added startup file back --- mysql/Dockerfile | 18 +++++++++++++++++- mysql/startup | 3 +++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 mysql/startup diff --git a/mysql/Dockerfile b/mysql/Dockerfile index aada38f..f63e014 100644 --- a/mysql/Dockerfile +++ b/mysql/Dockerfile @@ -12,8 +12,24 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN chown -R mysql:root /var/lib/mysql/ +ADD startup /etc/mysql/startup + +ARG MYSQL_DATABASE=default +ARG MYSQL_USER=default +ARG MYSQL_PASSWORD=secret +ARG MYSQL_ROOT_PASSWORD=root + +ENV MYSQL_DATABASE=$MYSQL_DATABASE +ENV MYSQL_USER=$MYSQL_USER +ENV MYSQL_PASSWORD=$MYSQL_PASSWORD +ENV MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD + +RUN sed -i 's/MYSQL_DATABASE/'$MYSQL_DATABASE'/g' /etc/mysql/startup && \ + sed -i 's/MYSQL_USER/'$MYSQL_USER'/g' /etc/mysql/startup && \ + sed -i 's/MYSQL_PASSWORD/'$MYSQL_PASSWORD'/g' /etc/mysql/startup + ADD my.cnf /etc/mysql/conf.d/my.cnf -CMD ["mysqld"] +CMD ["mysqld", "--init-file=/etc/mysql/startup"] EXPOSE 3306 diff --git a/mysql/startup b/mysql/startup new file mode 100644 index 0000000..11ced19 --- /dev/null +++ b/mysql/startup @@ -0,0 +1,3 @@ +DROP USER MYSQL_USER; +CREATE DATABASE IF NOT EXISTS MYSQL_DATABASE; +GRANT ALL ON `MYSQL_DATABASE`.* TO 'MYSQL_USER'@'%' IDENTIFIED BY 'MYSQL_PASSWORD'; \ No newline at end of file