From 07e13f77d902edde5a57e2c4ee0defea0834b709 Mon Sep 17 00:00:00 2001 From: Juan Cuzmar Date: Wed, 11 Sep 2019 15:46:48 -0300 Subject: [PATCH] Change mairdb installing into entrypoint --- Dockerfile | 1 - entry.sh | 17 ++++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6b9eef0..b614a07 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,7 +41,6 @@ RUN curl -sS https://getcomposer.org/installer | \ RUN cp /usr/share/zoneinfo/${TIMEZONE} /etc/localtime && \ echo "${TIMEZONE}" > /etc/timezone && \ mkdir -p /run/mysqld && chown -R mysql:mysql /run/mysqld /var/lib/mysql && \ - mysql_install_db --user=mysql --verbose=1 --basedir=/usr --datadir=/var/lib/mysql --rpm > /dev/null && \ mkdir -p /run/apache2 && chown -R apache:apache /run/apache2 && chown -R apache:apache /var/www/localhost/htdocs/ && \ sed -i 's#\#LoadModule rewrite_module modules\/mod_rewrite.so#LoadModule rewrite_module modules\/mod_rewrite.so#' /etc/apache2/httpd.conf && \ sed -i 's#ServerName www.example.com:80#\nServerName localhost:80#' /etc/apache2/httpd.conf && \ diff --git a/entry.sh b/entry.sh index 1e358cc..3d68eab 100644 --- a/entry.sh +++ b/entry.sh @@ -1,18 +1,20 @@ #!/bin/sh # start apache +echo "Starting httpd" httpd +echo "Done httpd" + # check if mysql data directory is nuked # if so, install the db +echo "Checking /var/lib/mysql folder" if [ ! -f /var/lib/mysql/ibdata1 ]; then - mysql_install_db --user=root > /dev/null + echo "Installing db" + mysql_install_db --user=mysql --verbose=1 --basedir=/usr --datadir=/var/lib/mysql --rpm > /dev/null + echo "Installed" fi; -if [ ! -d "/run/mysqld" ]; then - mkdir -p /run/mysqld -fi - # from mysql official docker repo if [ -z "$MYSQL_ROOT_PASSWORD" -a -z "$MYSQL_RANDOM_ROOT_PASSWORD" ]; then echo >&2 'error: database is uninitialized and password option is not specified ' @@ -22,8 +24,10 @@ fi # random password if [ ! -z "$MYSQL_RANDOM_ROOT_PASSWORD" ]; then + echo "Using random password" MYSQL_ROOT_PASSWORD="$(pwgen -1 32)" echo "GENERATED ROOT PASSWORD: $MYSQL_ROOT_PASSWORD" + echo "Done" fi tfile=`mktemp` @@ -41,9 +45,12 @@ cat << EOF > $tfile FLUSH PRIVILEGES; EOF +echo "Querying user" /usr/bin/mysqld --user=root --bootstrap --verbose=0 < $tfile rm -f $tfile +echo "Done query" # start mysql # nohup mysqld_safe --skip-grant-tables --bind-address 0.0.0.0 --user mysql > /dev/null 2>&1 & +echo "Starting mariadb database" exec /usr/bin/mysqld --user=root --bind-address=0.0.0.0