diff --git a/README.md b/README.md index a30baea..88a98bd 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ based images for Docker ## Available Images -- __pluie/alpine__ ( < 10 MB) Alpine/3.2 -- __pluie/alpine-apache__ ( ~ 37 MB) Apache/2.4.16 Php/5.6.21 +- __pluie/alpine__ ( < 10 MB) Alpine/3.4 +- __pluie/alpine-apache__ ( ~ 37 MB) Apache/2.4.23 Php/5.6.24 - __pluie/alpine-mysql__ ( ~ 160 MB) Mysql/5.5.47 [MariaDB] ## Base Image Structure diff --git a/pluie/alpine-apache/Dockerfile b/pluie/alpine-apache/Dockerfile index c7293bf..eed96bd 100644 --- a/pluie/alpine-apache/Dockerfile +++ b/pluie/alpine-apache/Dockerfile @@ -6,7 +6,10 @@ ADD files.tar /scripts RUN bash /scripts/install.sh -ENV SHENV_NAME=Apache SHENV_COLOR=67 HTTP_SERVER_NAME=docker-site.dev FIX_OWNERSHIP=1 +ENV SHENV_NAME=Apache \ + SHENV_COLOR=67 \ + HTTP_SERVER_NAME=docker-site.dev \ + FIX_OWNERSHIP=1 EXPOSE 80 diff --git a/pluie/alpine-apache/README.md b/pluie/alpine-apache/README.md index 44a892f..88174e5 100644 --- a/pluie/alpine-apache/README.md +++ b/pluie/alpine-apache/README.md @@ -1,6 +1,6 @@ # pluie/alpine-apache -Extend pluie/alpine with apache 2.4.16 +Extend pluie/alpine with apache 2.4.23 - error log are attached to stdout - no need port redirection diff --git a/pluie/alpine-apache/files.tar b/pluie/alpine-apache/files.tar index 41b460f..2b29c9b 100644 Binary files a/pluie/alpine-apache/files.tar and b/pluie/alpine-apache/files.tar differ diff --git a/pluie/alpine-apache/install.d/10-apache.sh b/pluie/alpine-apache/install.d/10-apache.sh index 0e4713d..68a0f70 100755 --- a/pluie/alpine-apache/install.d/10-apache.sh +++ b/pluie/alpine-apache/install.d/10-apache.sh @@ -2,6 +2,6 @@ # pluie/docker-images - a-Sansara (https://github.com/a-sansara) apk --update add apache2 \ -php-apache2 php-cli php-phar php-zlib php-zip php-ctype php-mysqli php-pdo_mysql php-xml \ -php-opcache php-pdo php-json php-curl php-gd php-mcrypt php-openssl \ +php5-apache2 php5-cli php5-phar php5-zlib php5-zip php5-ctype php5-mysqli php5-pdo_mysql php5-xml \ +php5-opcache php5-pdo php5-json php5-curl php5-gd php5-mcrypt php5-openssl \ # php-pdo_odbc php-soap php-pgsql diff --git a/pluie/alpine-apache/install.d/50-fix-apache.sh b/pluie/alpine-apache/install.d/50-fix-apache.sh index 2b9a308..eea85b2 100755 --- a/pluie/alpine-apache/install.d/50-fix-apache.sh +++ b/pluie/alpine-apache/install.d/50-fix-apache.sh @@ -6,6 +6,6 @@ chown -R 1000:apache /app/www chmod -R 755 /scripts/pre-init.d sed -i 's#^DocumentRoot ".*#DocumentRoot "/app/www"#g' /etc/apache2/httpd.conf sed -i 's#AllowOverride none#AllowOverride All#' /etc/apache2/httpd.conf -sed -ir 's/expose_php = On/expose_php = Off/' /etc/php/php.ini +sed -ir 's/expose_php = On/expose_php = Off/' /etc/php5/php.ini echo -e "\nIncludeOptional /app/vhost" >> /etc/apache2/httpd.conf rm -f /scripts/pre-init.d/50-example.sh diff --git a/pluie/alpine-mysql/Dockerfile b/pluie/alpine-mysql/Dockerfile index 2015ac4..53ef8ca 100644 --- a/pluie/alpine-mysql/Dockerfile +++ b/pluie/alpine-mysql/Dockerfile @@ -6,7 +6,8 @@ ADD files.tar /scripts RUN bash /scripts/install.sh -ENV SHENV_NAME=Mysql SHENV_COLOR=132 +ENV SHENV_NAME=Mysql \ + SHENV_COLOR=132 EXPOSE 3306 diff --git a/pluie/alpine-mysql/files.tar b/pluie/alpine-mysql/files.tar index ce84fa1..6434f22 100644 Binary files a/pluie/alpine-mysql/files.tar and b/pluie/alpine-mysql/files.tar differ diff --git a/pluie/alpine-mysql/install.d/40-mysql-fix.sh b/pluie/alpine-mysql/install.d/40-mysql-fix.sh index 6811c4f..733cd27 100644 --- a/pluie/alpine-mysql/install.d/40-mysql-fix.sh +++ b/pluie/alpine-mysql/install.d/40-mysql-fix.sh @@ -1,2 +1,5 @@ +#!/bin/bash +# pluie/docker-images - a-Sansara (https://github.com/a-sansara) + chown -R root:root /scripts/ rm -f /scripts/pre-init.d/50-example.sh diff --git a/pluie/alpine-mysql/main.sh b/pluie/alpine-mysql/main.sh index 885cb13..fba4107 100755 --- a/pluie/alpine-mysql/main.sh +++ b/pluie/alpine-mysql/main.sh @@ -2,6 +2,4 @@ # pluie/docker-images - a-Sansara (https://github.com/a-sansara) . /scripts/common.sh - -echo "[[ Starting Mysql Daemon ]]" exec /usr/bin/mysqld --user=mysql --console diff --git a/pluie/alpine-mysql/pre-init.d/10-db.sh b/pluie/alpine-mysql/pre-init.d/10-db.sh index 8b143da..cbefc82 100644 --- a/pluie/alpine-mysql/pre-init.d/10-db.sh +++ b/pluie/alpine-mysql/pre-init.d/10-db.sh @@ -1,15 +1,26 @@ #!/bin/bash # pluie/docker-images - a-Sansara (https://github.com/a-sansara) +function mysql.secure(){ + chown mysql:mysql $1 + sleep 5 + echo "[[ SECURING DATABASE ]]"; + echo "please wait." + sleep 5 + rm -f $1 + echo "done" +} + if [ ! -d "/run/mysqld" ]; then mkdir -p /run/mysqld chown -R mysql:mysql /run/mysqld fi if [ ! -d /var/lib/mysql/mysql ]; then + echo "[[ Initialize DB ]]" chown -R mysql:mysql /var/lib/mysql - mysql_install_db --user=mysql > /dev/null + mysql_install_db --user=mysql --verbose=1 --basedir=/usr --datadir=/var/lib/mysql --rpm > /dev/null if [ -z "$MYSQL_ROOT_PASSWORD" ]; then MYSQL_ROOT_PASSWORD=`pwgen -y -s 18 1` @@ -24,20 +35,19 @@ if [ ! -d /var/lib/mysql/mysql ]; then return 1 fi - cat << EOF > $tfile -USE mysql; -GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION; -UPDATE user SET password=PASSWORD("$MYSQL_ROOT_PASSWORD") WHERE user='root'; + cat <<-EOF > $tfile +UPDATE mysql.user SET password=PASSWORD('$MYSQL_ROOT_PASSWORD') WHERE user='root'; +DELETE FROM mysql.user WHERE user='root' AND host NOT IN ('localhost', '127.0.0.1', '::1', '$(hostname)'); +DELETE FROM mysql.user WHERE user=''; +DELETE FROM mysql.db WHERE db='test' OR db='test\_%'; GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION; -UPDATE user SET password=PASSWORD("") WHERE user='root' AND host='localhost'; +UPDATE mysql.user SET password=PASSWORD("") WHERE user='root' AND host='localhost'; EOF if [ ! -z "$MYSQL_DATABASE" ]; then - echo "[[ CREATE DATABASE $MYSQL_DATABASE ]]"; echo "CREATE DATABASE IF NOT EXISTS \`$MYSQL_DATABASE\` CHARACTER SET utf8 COLLATE utf8_general_ci;" >> $tfile fi if [ "$MYSQL_USER" != "" ] && [ "$MYSQL_USER" != 'root' ]; then - echo "[[ CREATE USER $MYSQL_USER ]]"; echo " CREATE USER '$MYSQL_USER'@'localhost' IDENTIFIED BY '$MYSQL_PASSWORD'; CREATE USER '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_PASSWORD';" >> $tfile @@ -47,6 +57,14 @@ GRANT ALL ON \`$MYSQL_DATABASE\`.* to '$MYSQL_USER'@'localhost' IDENTIFIED BY '$ GRANT ALL ON \`$MYSQL_DATABASE\`.* to '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_PASSWORD';" >> $tfile fi fi - /usr/bin/mysqld --user=mysql --bootstrap --skip-grant-tables=0 --verbose=0 < $tfile - rm -f $tfile + echo "FLUSH PRIVILEGES;" >> $tfile + + mysql.secure $tfile & + + echo "[[ Starting Mysql Daemon ]]" + exec /usr/bin/mysqld --user=mysql --console --init-file="$tfile" + +else + echo "[[ Skipping DB init ]]" + echo "[[ Starting Mysql Daemon ]]" fi diff --git a/pluie/alpine/Dockerfile b/pluie/alpine/Dockerfile index fd5317c..6ee0949 100644 --- a/pluie/alpine/Dockerfile +++ b/pluie/alpine/Dockerfile @@ -1,4 +1,4 @@ -FROM gliderlabs/alpine:3.2 +FROM alpine:3.4 MAINTAINER a-Sansara https://github.com/a-sansara @@ -6,6 +6,9 @@ ADD files.tar /scripts RUN apk --update add bash && bash /scripts/install.sh -ENV TERM=xterm SHENV_CTX=LOCAL SHENV_NAME=Alpine SHENV_COLOR=97 +ENV TERM=xterm \ + SHENV_CTX=LOCAL \ + SHENV_NAME=Alpine \ + SHENV_COLOR=97 ENTRYPOINT ["/scripts/main.sh"] diff --git a/pluie/alpine/README.md b/pluie/alpine/README.md index b02453a..fe0fe20 100644 --- a/pluie/alpine/README.md +++ b/pluie/alpine/README.md @@ -6,7 +6,7 @@ This Image provide a Linux Alpine distribution with : - curl - nano as editor -Base image : [gliderlabs/alpine:3.2] (https://registry.hub.docker.com/u/gliderlabs/alpine/) +Base image : [alpine:3.4] (https://hub.docker.com/_/alpine/) This project come with a structure to facilitate further images (like pluie/alpine-apache & pluie/alpine-mysql) diff --git a/pluie/alpine/files.tar b/pluie/alpine/files.tar index e769b96..a05ad1f 100644 Binary files a/pluie/alpine/files.tar and b/pluie/alpine/files.tar differ diff --git a/pluie/alpine/install.d/00-util.sh b/pluie/alpine/install.d/00-util.sh index 5f3fcfa..86c4209 100755 --- a/pluie/alpine/install.d/00-util.sh +++ b/pluie/alpine/install.d/00-util.sh @@ -1,3 +1,4 @@ #!/bin/bash +# pluie/docker-images - a-Sansara (https://github.com/a-sansara) apk --update add nano curl diff --git a/pluie/alpine/install.d/40-fix.sh b/pluie/alpine/install.d/40-fix.sh index aca68ca..29b327e 100755 --- a/pluie/alpine/install.d/40-fix.sh +++ b/pluie/alpine/install.d/40-fix.sh @@ -1,3 +1,4 @@ #!/bin/bash +# pluie/docker-images - a-Sansara (https://github.com/a-sansara) rm -f /var/cache/apk/* diff --git a/pluie/alpine/pre-init.d/50-example.sh b/pluie/alpine/pre-init.d/50-example.sh index 5217dfd..b987ff2 100755 --- a/pluie/alpine/pre-init.d/50-example.sh +++ b/pluie/alpine/pre-init.d/50-example.sh @@ -1,4 +1,5 @@ #!/bin/bash +# pluie/docker-images - a-Sansara (https://github.com/a-sansara) # ls -la /scripts chown -R root:root /scripts/