diff --git a/docker/main/Dockerfile b/docker/main/Dockerfile index b5ae5f9..886422a 100644 --- a/docker/main/Dockerfile +++ b/docker/main/Dockerfile @@ -1,5 +1,10 @@ FROM ubuntu:14.04 +# Ensure UTF-8 +RUN locale-gen en_US.UTF-8 +ENV LANG en_US.UTF-8 +ENV LC_ALL en_US.UTF-8 + COPY conf/php.ini /etc/php5/mods-available/docker-boilerplate.ini COPY conf/supervisord.conf /etc/supervisor/conf.d/supervisord.conf COPY conf/locale.conf /opt/docker/locale.conf diff --git a/docker/main/bin/dnsmasq.sh b/docker/main/bin/dnsmasq.sh index 9de927e..4093200 100644 --- a/docker/main/bin/dnsmasq.sh +++ b/docker/main/bin/dnsmasq.sh @@ -40,8 +40,8 @@ function dnsmasq_start() { ## set dnsmasq to main nameserver echo "nameserver 127.0.0.1" > /etc/resolv.conf - ## wait for 6 hours - sleep 21600 + ## wait for 10 hours + sleep 36000 } ## Fetch IP from services diff --git a/docker/main/bin/init-mysql.sh b/docker/main/bin/init-mysql.sh new file mode 100644 index 0000000..3024b27 --- /dev/null +++ b/docker/main/bin/init-mysql.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +############################# +## Init MySQL +############################# + +echo "[client] +host=mysql +user=\"$MYSQL_USER\" +password=\"$MYSQL_PASSWORD\" + +[mysql] +host=mysql +user=\"$MYSQL_USER\" +password=\"$MYSQL_PASSWORD\" +database=\"$MYSQL_DATABASE\" +default-character-set=utf8 +local-infile=1 +show-warnings +auto-rehash +sigint-ignore +reconnect + +[mysqldump] +host=mysql +user=\"$MYSQL_USER\" +password=\"$MYSQL_PASSWORD\" + +" | tee /root/.my.cnf > /home/.my.cnf diff --git a/docker/main/bin/init-php.sh b/docker/main/bin/init-php.sh new file mode 100644 index 0000000..de8f251 --- /dev/null +++ b/docker/main/bin/init-php.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash + +############################# +## Init PHP +############################# +echo " +date.timezone = ${PHP_TIMEZONE} +" >> /etc/php5/mods-available/docker-boilerplate.ini + +############################# +## Init PHP-FPM +############################# + +# Backup original +if [ ! -f "/opt/docker/.fpm-www.conf" ]; then + cp /etc/php5/fpm/pool.d/www.conf /opt/docker/.fpm-www.conf +fi + +## Remove old logs +rm -f -- /tmp/php.access.log /tmp/php.slow.log /tmp/php.error.log +touch -- /tmp/php.access.log /tmp/php.slow.log /tmp/php.error.log +chmod 666 /tmp/php.access.log /tmp/php.slow.log /tmp/php.error.log + +# Restore original +cp /opt/docker/.fpm-www.conf /etc/php5/fpm/pool.d/www.conf +sed -i "s@listen = /var/run/php5-fpm.sock@listen = 9000@" /etc/php5/fpm/pool.d/www.conf + +# Manipulate php-fpm configuration +echo " +; Server resource settings + +pm.max_children = 10 +pm.start_servers = 2 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 + +catch_workers_output = yes + +access.format = \"%R - %u %t \\\"%m %r%Q%q\\\" %s %f cpu:%C%% mem:%{megabytes}M reqTime:%d\" +access.log = /tmp/php.access.log +slowlog = /tmp/php.slow.log +request_slowlog_timeout = 30s + +php_admin_value[error_log] = /tmp/php.error.log +php_admin_flag[log_errors] = on + +env[TYPO3_CONTEXT] = ${TYPO3_CONTEXT} +env[FLOW_CONTEXT] = ${FLOW_CONTEXT} +env[FLOW_REWRITEURLS] = ${FLOW_REWRITEURLS} +" >> /etc/php5/fpm/pool.d/www.conf diff --git a/docker/main/bin/init-ssmtp.sh b/docker/main/bin/init-ssmtp.sh new file mode 100644 index 0000000..4bf8972 --- /dev/null +++ b/docker/main/bin/init-ssmtp.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +############################# +## Init SSMTP +############################# + +sed -i "s/mailhub=.*/mailhub=${MAIL_GATEWAY}/" /etc/ssmtp/ssmtp.conf +sed -i "s/#FromLineOverride=.*/FromLineOverride=YES/" /etc/ssmtp/ssmtp.conf diff --git a/docker/main/bin/init-system.sh b/docker/main/bin/init-system.sh new file mode 100644 index 0000000..8b7e0bb --- /dev/null +++ b/docker/main/bin/init-system.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +## Set uid/gid for www-data user +usermod --uid "${PHP_UID}" --shell /bin/bash --home /home www-data +groupmod --gid "${PHP_GID}" www-data diff --git a/docker/main/entrypoint.sh b/docker/main/entrypoint.sh index 9fd964d..e59be6d 100755 --- a/docker/main/entrypoint.sh +++ b/docker/main/entrypoint.sh @@ -1,95 +1,17 @@ #!/bin/bash set -e -############################# -## Init UID/GID -############################# - -usermod --uid "${PHP_UID}" --shell /bin/bash --home /home www-data -groupmod --gid "${PHP_GID}" www-data - -############################# -## Init MySQL -############################# - -echo "[client] -host=mysql -user=\"$MYSQL_USER\" -password=\"$MYSQL_PASSWORD\" +## Init system +source /opt/docker/init-system.sh -[mysql] -host=mysql -user=\"$MYSQL_USER\" -password=\"$MYSQL_PASSWORD\" -database=\"$MYSQL_DATABASE\" -default-character-set=utf8 -local-infile=1 -show-warnings -auto-rehash -sigint-ignore -reconnect +## Init MySQL (client) +source /opt/docker/init-mysql.sh -[mysqldump] -host=mysql -user=\"$MYSQL_USER\" -password=\"$MYSQL_PASSWORD\" - -" | tee /root/.my.cnf > /home/.my.cnf - -############################# ## Init SSMTP -############################# +source /opt/docker/init-ssmtp.sh -sed -i "s/mailhub=.*/mailhub=${MAIL_GATEWAY}/" /etc/ssmtp/ssmtp.conf - -############################# -## Init PHP -############################# -echo " -date.timezone = ${PHP_TIMEZONE} -" > /etc/php5/mods-available/docker-boilerplate.ini - -############################# -## Init PHP-FPM -############################# - -# Backup original -if [ ! -f "/opt/docker/.fpm-www.conf" ]; then - cp /etc/php5/fpm/pool.d/www.conf /opt/docker/.fpm-www.conf -fi - -## Remove old logs -rm -f -- /tmp/php.access.log /tmp/php.slow.log /tmp/php.error.log -touch -- /tmp/php.access.log /tmp/php.slow.log /tmp/php.error.log -chmod 666 /tmp/php.access.log /tmp/php.slow.log /tmp/php.error.log - -# Restore original -cp /opt/docker/.fpm-www.conf /etc/php5/fpm/pool.d/www.conf -sed -i "s@listen = /var/run/php5-fpm.sock@listen = 9000@" /etc/php5/fpm/pool.d/www.conf - -# Manipulate php-fpm configuration -echo " -; Server resource settings - -pm.max_children = 10 -pm.start_servers = 2 -pm.min_spare_servers = 1 -pm.max_spare_servers = 3 - -catch_workers_output = yes - -access.format = \"%R - %u %t \\\"%m %r%Q%q\\\" %s %f cpu:%C%% mem:%{megabytes}M reqTime:%d\" -access.log = /tmp/php.access.log -slowlog = /tmp/php.slow.log -request_slowlog_timeout = 30s - -php_admin_value[error_log] = /tmp/php.error.log -php_admin_flag[log_errors] = on - -env[TYPO3_CONTEXT] = ${TYPO3_CONTEXT} -env[FLOW_CONTEXT] = ${FLOW_CONTEXT} -env[FLOW_REWRITEURLS] = ${FLOW_REWRITEURLS} -" >> /etc/php5/fpm/pool.d/www.conf +## Init SSMTP +source /opt/docker/init-php.sh ############################# ## COMMAND