diff --git a/apache/Dockerfile b/apache/Dockerfile index bc86976f0e..0416898cb4 100644 --- a/apache/Dockerfile +++ b/apache/Dockerfile @@ -1,11 +1,15 @@ -FROM php:5.6-apache +FROM php:7.0-apache RUN a2enmod rewrite expires # install the PHP extensions we need -RUN apt-get update && apt-get install -y libpng12-dev libjpeg-dev && rm -rf /var/lib/apt/lists/* \ +RUN apt-get update && apt-get install -y libpng12-dev libjpeg-dev libxml2-dev && rm -rf /var/lib/apt/lists/* \ && docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \ - && docker-php-ext-install gd mysqli opcache + && docker-php-ext-install gd \ + && docker-php-ext-install soap \ + && docker-php-ext-install zip \ + && docker-php-ext-install mbstring +RUN docker-php-ext-install mysqli opcache # set recommended PHP.ini settings # see https://secure.php.net/manual/en/opcache.installation.php @@ -20,15 +24,19 @@ RUN { \ VOLUME /var/www/html -ENV WORDPRESS_VERSION 4.5.2 -ENV WORDPRESS_SHA1 bab94003a5d2285f6ae76407e7b1bbb75382c36e +ENV WORDPRESS_VERSION 4.5.3 +ENV WORDPRESS_SHA1 835b68748dae5a9d31c059313cd0150f03a49269 # upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress RUN curl -o wordpress.tar.gz -SL https://wordpress.org/wordpress-${WORDPRESS_VERSION}.tar.gz \ && echo "$WORDPRESS_SHA1 *wordpress.tar.gz" | sha1sum -c - \ && tar -xzf wordpress.tar.gz -C /usr/src/ \ - && rm wordpress.tar.gz \ - && chown -R www-data:www-data /usr/src/wordpress + && rm wordpress.tar.gz + +# install language files +RUN curl -s https://he.wordpress.org/wordpress-${WORDPRESS_VERSION}-he_IL.tar.gz | tar -zx -C /usr/src/ --wildcards 'wordpress/wp-content/languages/*' + +RUN chown -R www-data:www-data /usr/src/wordpress COPY docker-entrypoint.sh /entrypoint.sh diff --git a/apache/docker-entrypoint.sh b/apache/docker-entrypoint.sh index 44d67f2811..226b6a3601 100755 --- a/apache/docker-entrypoint.sh +++ b/apache/docker-entrypoint.sh @@ -35,9 +35,16 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] - RewriteCond %{REQUEST_FILENAME} !-f - RewriteCond %{REQUEST_FILENAME} !-d - RewriteRule . /index.php [L] + + # add a trailing slash to /wp-admin + RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] + + RewriteCond %{REQUEST_FILENAME} -f [OR] + RewriteCond %{REQUEST_FILENAME} -d + RewriteRule ^ - [L] + RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L] + RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L] + RewriteRule . index.php [L] # END WordPress EOF @@ -45,6 +52,20 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then fi fi + additional_config() { + cat <<-'EOPHP' + // If we're behind a proxy server and using HTTPS, we need to alert Wordpress of that fact + // see also http://codex.wordpress.org/Administration_Over_SSL#Using_a_Reverse_Proxy + if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { + $_SERVER['HTTPS'] = 'on'; + } + foreach (glob("/etc/wordpress/*.php") as $filename) + { + include $filename; + } + EOPHP + } + # TODO handle WordPress upgrades magically in the same way, but only if wp-includes/version.php's $wp_version is less than /usr/src/wordpress/wp-includes/version.php's $wp_version # version 4.4.1 decided to switch to windows line endings, that breaks our seds and awks @@ -53,14 +74,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then sed -ri 's/\r\n|\r/\n/g' wp-config* if [ ! -e wp-config.php ]; then - awk '/^\/\*.*stop editing.*\*\/$/ && c == 0 { c = 1; system("cat") } { print }' wp-config-sample.php > wp-config.php <<'EOPHP' -// If we're behind a proxy server and using HTTPS, we need to alert Wordpress of that fact -// see also http://codex.wordpress.org/Administration_Over_SSL#Using_a_Reverse_Proxy -if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { - $_SERVER['HTTPS'] = 'on'; -} - -EOPHP + awk '/^\/\*.*stop editing.*\*\/$/ && c == 0 { c = 1; system("cat") } { print }' wp-config-sample.php > wp-config.php < <(additional_config) chown www-data:www-data wp-config.php fi diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 44d67f2811..226b6a3601 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -35,9 +35,16 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] - RewriteCond %{REQUEST_FILENAME} !-f - RewriteCond %{REQUEST_FILENAME} !-d - RewriteRule . /index.php [L] + + # add a trailing slash to /wp-admin + RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] + + RewriteCond %{REQUEST_FILENAME} -f [OR] + RewriteCond %{REQUEST_FILENAME} -d + RewriteRule ^ - [L] + RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L] + RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L] + RewriteRule . index.php [L] # END WordPress EOF @@ -45,6 +52,20 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then fi fi + additional_config() { + cat <<-'EOPHP' + // If we're behind a proxy server and using HTTPS, we need to alert Wordpress of that fact + // see also http://codex.wordpress.org/Administration_Over_SSL#Using_a_Reverse_Proxy + if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { + $_SERVER['HTTPS'] = 'on'; + } + foreach (glob("/etc/wordpress/*.php") as $filename) + { + include $filename; + } + EOPHP + } + # TODO handle WordPress upgrades magically in the same way, but only if wp-includes/version.php's $wp_version is less than /usr/src/wordpress/wp-includes/version.php's $wp_version # version 4.4.1 decided to switch to windows line endings, that breaks our seds and awks @@ -53,14 +74,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then sed -ri 's/\r\n|\r/\n/g' wp-config* if [ ! -e wp-config.php ]; then - awk '/^\/\*.*stop editing.*\*\/$/ && c == 0 { c = 1; system("cat") } { print }' wp-config-sample.php > wp-config.php <<'EOPHP' -// If we're behind a proxy server and using HTTPS, we need to alert Wordpress of that fact -// see also http://codex.wordpress.org/Administration_Over_SSL#Using_a_Reverse_Proxy -if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { - $_SERVER['HTTPS'] = 'on'; -} - -EOPHP + awk '/^\/\*.*stop editing.*\*\/$/ && c == 0 { c = 1; system("cat") } { print }' wp-config-sample.php > wp-config.php < <(additional_config) chown www-data:www-data wp-config.php fi diff --git a/fpm/Dockerfile b/fpm/Dockerfile index 237174f6d1..caa166546a 100644 --- a/fpm/Dockerfile +++ b/fpm/Dockerfile @@ -1,8 +1,13 @@ -FROM php:5.6-fpm +FROM php:7.0-apache # install the PHP extensions we need -RUN apt-get update && apt-get install -y libpng12-dev libjpeg-dev && rm -rf /var/lib/apt/lists/* \ +RUN apt-get update && apt-get install -y libpng12-dev libjpeg-dev libxml2-dev && rm -rf /var/lib/apt/lists/* \ && docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \ + && docker-php-ext-install gd \ + && docker-php-ext-install soap \ + && docker-php-ext-install zip \ + && docker-php-ext-install mbstring +RUN docker-php-ext-install mysqli \ && docker-php-ext-install gd mysqli opcache # set recommended PHP.ini settings @@ -18,15 +23,20 @@ RUN { \ VOLUME /var/www/html -ENV WORDPRESS_VERSION 4.5.2 -ENV WORDPRESS_SHA1 bab94003a5d2285f6ae76407e7b1bbb75382c36e +ENV WORDPRESS_VERSION 4.5.3 +ENV WORDPRESS_SHA1 835b68748dae5a9d31c059313cd0150f03a49269 # upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress RUN curl -o wordpress.tar.gz -SL https://wordpress.org/wordpress-${WORDPRESS_VERSION}.tar.gz \ && echo "$WORDPRESS_SHA1 *wordpress.tar.gz" | sha1sum -c - \ && tar -xzf wordpress.tar.gz -C /usr/src/ \ - && rm wordpress.tar.gz \ - && chown -R www-data:www-data /usr/src/wordpress + && chown -R www-data:www-data /usr/src/wordpress \ + && rm wordpress.tar.gz + +# install language files +RUN curl -s https://he.wordpress.org/wordpress-${WORDPRESS_VERSION}-he_IL.tar.gz | tar -zx -C /usr/src/ --wildcards 'wordpress/wp-content/languages/*' + +RUN chown -R www-data:www-data /usr/src/wordpress COPY docker-entrypoint.sh /entrypoint.sh diff --git a/fpm/docker-entrypoint.sh b/fpm/docker-entrypoint.sh index 44d67f2811..226b6a3601 100755 --- a/fpm/docker-entrypoint.sh +++ b/fpm/docker-entrypoint.sh @@ -35,9 +35,16 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] - RewriteCond %{REQUEST_FILENAME} !-f - RewriteCond %{REQUEST_FILENAME} !-d - RewriteRule . /index.php [L] + + # add a trailing slash to /wp-admin + RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] + + RewriteCond %{REQUEST_FILENAME} -f [OR] + RewriteCond %{REQUEST_FILENAME} -d + RewriteRule ^ - [L] + RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L] + RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L] + RewriteRule . index.php [L] # END WordPress EOF @@ -45,6 +52,20 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then fi fi + additional_config() { + cat <<-'EOPHP' + // If we're behind a proxy server and using HTTPS, we need to alert Wordpress of that fact + // see also http://codex.wordpress.org/Administration_Over_SSL#Using_a_Reverse_Proxy + if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { + $_SERVER['HTTPS'] = 'on'; + } + foreach (glob("/etc/wordpress/*.php") as $filename) + { + include $filename; + } + EOPHP + } + # TODO handle WordPress upgrades magically in the same way, but only if wp-includes/version.php's $wp_version is less than /usr/src/wordpress/wp-includes/version.php's $wp_version # version 4.4.1 decided to switch to windows line endings, that breaks our seds and awks @@ -53,14 +74,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then sed -ri 's/\r\n|\r/\n/g' wp-config* if [ ! -e wp-config.php ]; then - awk '/^\/\*.*stop editing.*\*\/$/ && c == 0 { c = 1; system("cat") } { print }' wp-config-sample.php > wp-config.php <<'EOPHP' -// If we're behind a proxy server and using HTTPS, we need to alert Wordpress of that fact -// see also http://codex.wordpress.org/Administration_Over_SSL#Using_a_Reverse_Proxy -if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { - $_SERVER['HTTPS'] = 'on'; -} - -EOPHP + awk '/^\/\*.*stop editing.*\*\/$/ && c == 0 { c = 1; system("cat") } { print }' wp-config-sample.php > wp-config.php < <(additional_config) chown www-data:www-data wp-config.php fi