commit bf162982c22d28fbd891a849f88d7fd990f9599d Author: Knut Ahlers Date: Sat May 11 21:20:19 2019 +0200 Initial version diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3933bfc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM luzifer/alpine-nginx-php + +ENV WP_VERSION=5.2 \ + WP_CHECKSUM=2666d749a08b1f863563bc23f87e86adf21e28490762afed0264cad687250bc3 + +COPY rootfs / +RUN set -ex && /usr/local/bin/container-setup diff --git a/rootfs/etc/cont-init.d/copy-wordpress.sh b/rootfs/etc/cont-init.d/copy-wordpress.sh new file mode 100755 index 0000000..62ab7a4 --- /dev/null +++ b/rootfs/etc/cont-init.d/copy-wordpress.sh @@ -0,0 +1,15 @@ +#!/usr/bin/with-contenv /bin/bash +set -euo pipefail + +if [[ -f wp-includes/version.php ]]; then + installed_version=$(grep '^\$wp_version' wp-includes/version.php | sed -E "s/.*'(.*)'.*/\\1/") + if [ -n "${installed_version}" ] && [[ ${installed_version} == ${WP_VERSION} ]]; then + echo "Wordpress installation is up-to-date." >&2 + exit 0 + fi +fi + +echo "No Wordpress installation found or not up-to-date" >&2 +echo "Installing bundled Wordpress version" >&2 + +tar -xvz -C /var/www --strip-components=1 -f /opt/wp.tgz diff --git a/rootfs/etc/php7/conf.d/10_opcache-recommended.ini b/rootfs/etc/php7/conf.d/10_opcache-recommended.ini new file mode 100644 index 0000000..0bb0c1b --- /dev/null +++ b/rootfs/etc/php7/conf.d/10_opcache-recommended.ini @@ -0,0 +1,6 @@ + opcache.memory_consumption=128 + opcache.interned_strings_buffer=8 + opcache.max_accelerated_files=4000 + opcache.revalidate_freq=2 + opcache.fast_shutdown=1 + opcache.enable_cli=1 diff --git a/rootfs/etc/php7/conf.d/error-logging.ini b/rootfs/etc/php7/conf.d/error-logging.ini new file mode 100644 index 0000000..8826fb5 --- /dev/null +++ b/rootfs/etc/php7/conf.d/error-logging.ini @@ -0,0 +1,9 @@ + error_reporting = 4339 + display_errors = Off + display_startup_errors = Off + log_errors = On + error_log = /dev/stderr + log_errors_max_len = 1024 + ignore_repeated_errors = On + ignore_repeated_source = Off + html_errors = Off diff --git a/rootfs/usr/local/bin/container-setup b/rootfs/usr/local/bin/container-setup new file mode 100755 index 0000000..8449578 --- /dev/null +++ b/rootfs/usr/local/bin/container-setup @@ -0,0 +1,27 @@ +#!/bin/bash +set -euxo pipefail + +url="https://github.com/WordPress/WordPress/archive/${WP_VERSION}.tar.gz" +packages=( + php7-gd + php7-mysqli + php7-opcache + php7-zip +) + +function cleanup() { + rm -rf \ + /tmp/wp.tgz +} +trap cleanup EXIT + +function step() { + echo "$@..." >&2 +} + +step "Downloading wordpress release ${WP_VERSION}" +curl -sSfLo /opt/wp.tgz "${url}" +echo "${WP_CHECKSUM} /opt/wp.tgz" | sha256sum -c + +step "Installing required packages" +apk --no-cache add "${packages[@]}" diff --git a/update.sh b/update.sh new file mode 100755 index 0000000..4143da2 --- /dev/null +++ b/update.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -euxo pipefail + +version=$(curl -s "https://lv.luzifer.io/catalog-api/wordpress/latest.txt?p=version") +grep -q "WP_VERSION=${version} " Dockerfile && exit 0 || echo "Update required" + +wphash=$(curl -sSfL "https://github.com/WordPress/WordPress/archive/${version}.tar.gz" | sha256sum | cut -d ' ' -f 1) + +sed -Ei \ + -e "s/WP_VERSION=[0-9.]+/WP_VERSION=${version}/" \ + -e "s/WP_CHECKSUM=[a-z0-9]+/WP_CHECKSUM=${wphash}/" \ + Dockerfile