From acc6d1c545e1edf2bd08b7c6c2b72b82c1574f45 Mon Sep 17 00:00:00 2001 From: Deon George Date: Tue, 28 Apr 2020 16:30:48 +1000 Subject: [PATCH] Updated to WP 5.4, added nginx and msmtp --- Dockerfile | 23 ++++++++++++++++------- init | 15 ++++++++++++++- msmtprc | 18 ++++++++++++++++++ nginx-app.conf | 35 +++++++++++++++++++++++++++++++++++ www.conf | 9 +++++++++ 5 files changed, 92 insertions(+), 8 deletions(-) mode change 100755 => 100644 Dockerfile create mode 100644 msmtprc create mode 100644 nginx-app.conf create mode 100644 www.conf diff --git a/Dockerfile b/Dockerfile old mode 100755 new mode 100644 index 07603f0..701aebd --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,22 @@ # NAME leenooks/wordpress -# VERSION 5.1.1-fpm +# VERSION 5.4-fpm -FROM wordpress:5.1.1-fpm +FROM wordpress:5.4-fpm -RUN apt-get update && apt-get install -y openssh-server ssmtp && rm -rf /var/lib/apt/lists/* /tmp/* \ - && useradd -c "Hosting Admin User" -u 1000 -g users -G www-data -d /var/www/html -M lamp \ - && sed -i -e 's/^mailhub=mail$/mailhub=smtp/' -e "s/^hostname=/#hostname=/" -e 's/#FromLineOverride=YES/FromLineOverride=YES/' /etc/ssmtp/ssmtp.conf +RUN apt-get update && apt-get install -y openssh-server msmtp nginx \ + && rm /etc/nginx/sites-enabled/default \ + && apt-get -y autoremove \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +RUN docker-php-ext-install -j$(nproc) opcache + +RUN useradd -c "Hosting Admin User" -u 1000 -g users -G www-data -d /var/www/html -M lamp +RUN sed -e 's/^expose_php = On/expose_php = Off/' /usr/local/etc/php/php.ini-production > /usr/local/etc/php/php.ini +COPY www.conf /usr/local/etc/php-fpm.d/ +COPY nginx-app.conf /etc/nginx/conf.d/ +COPY msmtprc /etc/ +RUN sed -i -e 's#^;sendmail_path =#sendmail_path = "/usr/bin/msmtp -t"#' /usr/local/etc/php/php.ini COPY sshd_config.patch /tmp RUN (cd / && patch -p0 ) < /tmp/sshd_config.patch && rm /tmp/sshd_config.patch @@ -15,5 +26,3 @@ EXPOSE 9000/tcp 22/tcp COPY init /sbin ENTRYPOINT [ "/sbin/init" ] CMD [ "php-fpm" ] - -RUN docker-php-ext-install -j$(nproc) opcache diff --git a/init b/init index e2c18de..524c83e 100755 --- a/init +++ b/init @@ -1,8 +1,21 @@ #!/bin/sh -if [ -x /usr/sbin/sshd -a "${SSH_START}" = "TRUE" ]; then +NO_NGINX=${NO_NGINX:-TRUE} +SSH_START=${SSH_START:-FALSE} + +function nginx_start() { + # Start NGINX + if [ -x /usr/sbin/nginx -a "${NO_NGINX}" != "TRUE" ]; then + echo "* Starting NGINX..." + start-stop-daemon --start --pidfile /var/run/nginx.pid --exec /usr/sbin/nginx -- -g 'daemon on; master_process on;' + fi +} + +if [ -x /usr/sbin/sshd -a "${SSH_START}" = "TRUE" ]; then [ ! -d /var/run/sshd ] && mkdir /var/run/sshd start-stop-daemon --start --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd -- -p 22 fi +nginx_start + exec /usr/local/bin/docker-entrypoint.sh "$@" diff --git a/msmtprc b/msmtprc new file mode 100644 index 0000000..505acf3 --- /dev/null +++ b/msmtprc @@ -0,0 +1,18 @@ +# A system wide configuration file is optional. +# If it exists, it usually defines a default account. +# This allows msmtp to be used like /usr/sbin/sendmail. +account default + +# The SMTP smarthost +host smtp + +# Envelope-from address +#from user@example.com +domain example.com + +# Construct envelope-from addresses of the form "user@oursite.example" +#auto_from on +#maildomain example.com + +# Syslog logging with facility LOG_MAIL instead of the default LOG_USER +syslog LOG_MAIL diff --git a/nginx-app.conf b/nginx-app.conf new file mode 100644 index 0000000..9f86955 --- /dev/null +++ b/nginx-app.conf @@ -0,0 +1,35 @@ +server { + listen 80 default_server; + listen [::]:80 default_server; + + access_log none; + client_max_body_size 10m; + error_log none; + fastcgi_buffers 16 16k; + fastcgi_buffer_size 16k; + index index.php index.html; + root /var/www/html/public; + server_tokens off; + + set $my_https "off"; + if ($http_x_forwarded_proto = "https") { + set $my_https "on"; + } + + location / { + try_files $uri $uri/ /index.php?$query_string; + } + + location ~ \.php$ { + try_files $uri =404; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass 127.0.0.1:9000; + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param SERVER_NAME $host; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param HTTPS $my_https; + fastcgi_param PHP_ADMIN_VALUE "sendmail_path=/usr/sbin/sendmail -i -t"; + } +} diff --git a/www.conf b/www.conf new file mode 100644 index 0000000..77aa955 --- /dev/null +++ b/www.conf @@ -0,0 +1,9 @@ +[www] +group = www-data +listen = 127.0.0.1:9000 +pm = dynamic +pm.max_children = 25 +pm.max_spare_servers = 10 +pm.min_spare_servers = 5 +pm.start_servers = 10 +user = www-data