Skip to content

Commit

Permalink
Initialize MySQL Database in /workspace/mysql
Browse files Browse the repository at this point in the history
  • Loading branch information
meysholdt committed Apr 30, 2019
1 parent b4a7815 commit 86f88fc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
8 changes: 7 additions & 1 deletion mysql/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 10 additions & 0 deletions mysql/client.cnf
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 86f88fc

Please sign in to comment.