From 86f88fcff0011e6a9150b20252ddc4b5c1a554e4 Mon Sep 17 00:00:00 2001 From: Moritz Eysholdt Date: Tue, 30 Apr 2019 19:23:57 +0000 Subject: [PATCH] Initialize MySQL Database in /workspace/mysql --- mysql/Dockerfile | 8 +++++++- mysql/client.cnf | 10 ++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 mysql/client.cnf diff --git a/mysql/Dockerfile b/mysql/Dockerfile index 6b587943d..9f4b8287d 100644 --- a/mysql/Dockerfile +++ b/mysql/Dockerfile @@ -6,14 +6,20 @@ USER root RUN apt-get update \ && apt-get install -y mysql-server \ && apt-get clean && rm -rf /var/cache/apt/* /var/lib/apt/lists/* /tmp/* \ - && cp /etc/mysql/debian.cnf /etc/mysql/mysql.conf.d/debian.cnf \ && mkdir /var/run/mysqld \ && chown -R gitpod:gitpod /etc/mysql /var/run/mysqld /var/log/mysql /var/lib/mysql /var/lib/mysql-files /var/lib/mysql-keyring /var/lib/mysql-upgrade # Install our own MySQL-Config COPY mysql.cnf /etc/mysql/mysql.conf.d/mysqld.cnf +# Install default-login for MySQL clients +COPY client.cnf /etc/mysql/mysql.conf.d/client.cnf + + USER gitpod +# Initialize MySQL Database via .bashrc, but only if ther is no database data yet. +RUN echo "[ ! -d /workspace/mysql ] && mysqld --initialize-insecure" >> ~/.bashrc + # Launch the MySQL daemon via .bashrc, but only if it is not yet running. RUN echo "[ ! -e /var/run/mysqld/mysqld.pid ] && mysqld --daemonize" >> ~/.bashrc \ No newline at end of file diff --git a/mysql/client.cnf b/mysql/client.cnf new file mode 100644 index 000000000..12dcd7ad1 --- /dev/null +++ b/mysql/client.cnf @@ -0,0 +1,10 @@ +[client] +host = localhost +user = root +password = +socket = /var/run/mysqld/mysqld.sock +[mysql_upgrade] +host = localhost +user = root +password = +socket = /var/run/mysqld/mysqld.sock