Updated to WP 5.4, added nginx and msmtp

This commit is contained in:
Deon George 2020-04-28 16:30:48 +10:00
parent 3c194bea82
commit acc6d1c545
5 changed files with 92 additions and 8 deletions

23
Dockerfile Executable file → Normal file
View File

@ -1,11 +1,22 @@
# NAME leenooks/wordpress # 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/* \ RUN apt-get update && apt-get install -y openssh-server msmtp nginx \
&& useradd -c "Hosting Admin User" -u 1000 -g users -G www-data -d /var/www/html -M lamp \ && rm /etc/nginx/sites-enabled/default \
&& sed -i -e 's/^mailhub=mail$/mailhub=smtp/' -e "s/^hostname=/#hostname=/" -e 's/#FromLineOverride=YES/FromLineOverride=YES/' /etc/ssmtp/ssmtp.conf && 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 COPY sshd_config.patch /tmp
RUN (cd / && patch -p0 ) < /tmp/sshd_config.patch && rm /tmp/sshd_config.patch 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 COPY init /sbin
ENTRYPOINT [ "/sbin/init" ] ENTRYPOINT [ "/sbin/init" ]
CMD [ "php-fpm" ] CMD [ "php-fpm" ]
RUN docker-php-ext-install -j$(nproc) opcache

15
init
View File

@ -1,8 +1,21 @@
#!/bin/sh #!/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 [ ! -d /var/run/sshd ] && mkdir /var/run/sshd
start-stop-daemon --start --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd -- -p 22 start-stop-daemon --start --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd -- -p 22
fi fi
nginx_start
exec /usr/local/bin/docker-entrypoint.sh "$@" exec /usr/local/bin/docker-entrypoint.sh "$@"

18
msmtprc Normal file
View File

@ -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

35
nginx-app.conf Normal file
View File

@ -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";
}
}

9
www.conf Normal file
View File

@ -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