From 2857ebd27298667dcef6d1ad75c745028e300c1c Mon Sep 17 00:00:00 2001 From: Adrian Manikowski Date: Fri, 15 Dec 2023 10:44:20 +0000 Subject: [PATCH 1/3] [wordpress] Docker images updates - 2023-12-15-104420 --- 5/php7/debian11/apache/5.9/Dockerfile | 61 ++++ .../debian11/apache/5.9}/docker-entrypoint.sh | 0 6/php7/debian11/apache/6.2/Dockerfile | 2 +- .../debian11/apache/6.3/Dockerfile | 2 +- .../debian11/apache/6.3/docker-entrypoint.sh | 268 ++++++++++++++++++ exporter/Dockerfile | 4 +- versions.yaml | 44 ++- 7 files changed, 365 insertions(+), 16 deletions(-) create mode 100644 5/php7/debian11/apache/5.9/Dockerfile rename {6/php8/debian11/apache/6.3 => 5/php7/debian11/apache/5.9}/docker-entrypoint.sh (100%) rename 6/{php8 => php7}/debian11/apache/6.3/Dockerfile (97%) create mode 100755 6/php7/debian11/apache/6.3/docker-entrypoint.sh diff --git a/5/php7/debian11/apache/5.9/Dockerfile b/5/php7/debian11/apache/5.9/Dockerfile new file mode 100644 index 0000000..4f1d862 --- /dev/null +++ b/5/php7/debian11/apache/5.9/Dockerfile @@ -0,0 +1,61 @@ +FROM marketplace.gcr.io/google/php7-apache2:7.4 + +# install the PHP extensions we need +RUN set -ex; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + libjpeg-dev \ + libpng-dev \ + libzip-dev \ + ; \ + \ + docker-php-ext-configure gd --with-jpeg=/usr; \ + docker-php-ext-install gd mysqli opcache zip; \ + \ +# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark; \ + ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \ + | awk '/=>/ { print $3 }' \ + | sort -u \ + | xargs -r realpath | xargs -r dpkg-query --search \ + | cut -d: -f1 \ + | sort -u \ + | xargs -rt apt-mark manual; \ + \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/* + +# set recommended PHP.ini settings +# see https://secure.php.net/manual/en/opcache.installation.php +RUN { \ + echo 'opcache.memory_consumption=128'; \ + echo 'opcache.interned_strings_buffer=8'; \ + echo 'opcache.max_accelerated_files=4000'; \ + echo 'opcache.revalidate_freq=2'; \ + echo 'opcache.fast_shutdown=1'; \ + echo 'opcache.enable_cli=1'; \ + } > /usr/local/etc/php/conf.d/opcache-recommended.ini + +RUN a2enmod rewrite expires + +VOLUME /var/www/html + +ENV WORDPRESS_VERSION 5.9.7 + +ENV C2D_RELEASE 5.9.7 + +RUN set -ex; \ + curl -o wordpress.tar.gz -fSL "https://wordpress.org/wordpress-${WORDPRESS_VERSION}.tar.gz"; \ +# upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress + tar -xzf wordpress.tar.gz -C /usr/src/; \ + rm wordpress.tar.gz; \ + chown -R www-data:www-data /usr/src/wordpress + +COPY docker-entrypoint.sh /usr/local/bin/ + +ENTRYPOINT ["docker-entrypoint.sh"] +CMD ["apache2-foreground"] diff --git a/6/php8/debian11/apache/6.3/docker-entrypoint.sh b/5/php7/debian11/apache/5.9/docker-entrypoint.sh similarity index 100% rename from 6/php8/debian11/apache/6.3/docker-entrypoint.sh rename to 5/php7/debian11/apache/5.9/docker-entrypoint.sh diff --git a/6/php7/debian11/apache/6.2/Dockerfile b/6/php7/debian11/apache/6.2/Dockerfile index d52de4c..b79103f 100644 --- a/6/php7/debian11/apache/6.2/Dockerfile +++ b/6/php7/debian11/apache/6.2/Dockerfile @@ -1,4 +1,4 @@ -FROM marketplace.gcr.io/google/php8-apache2:8.1 +FROM marketplace.gcr.io/google/php7-apache2:7.4 # install the PHP extensions we need RUN set -ex; \ diff --git a/6/php8/debian11/apache/6.3/Dockerfile b/6/php7/debian11/apache/6.3/Dockerfile similarity index 97% rename from 6/php8/debian11/apache/6.3/Dockerfile rename to 6/php7/debian11/apache/6.3/Dockerfile index 1b086f8..0366b40 100644 --- a/6/php8/debian11/apache/6.3/Dockerfile +++ b/6/php7/debian11/apache/6.3/Dockerfile @@ -1,4 +1,4 @@ -FROM marketplace.gcr.io/google/php8-apache2:8.2 +FROM marketplace.gcr.io/google/php7-apache2:7.4 # install the PHP extensions we need RUN set -ex; \ diff --git a/6/php7/debian11/apache/6.3/docker-entrypoint.sh b/6/php7/debian11/apache/6.3/docker-entrypoint.sh new file mode 100755 index 0000000..a2d1daa --- /dev/null +++ b/6/php7/debian11/apache/6.3/docker-entrypoint.sh @@ -0,0 +1,268 @@ +#!/bin/bash +# +# Copyright (C) 2017 Google Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +set -euo pipefail + +# usage: file_env VAR [DEFAULT] +# ie: file_env 'XYZ_DB_PASSWORD' 'example' +# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of +# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature) +file_env() { + local var="$1" + local fileVar="${var}_FILE" + local def="${2:-}" + if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then + echo >&2 "error: both $var and $fileVar are set (but are exclusive)" + exit 1 + fi + local val="$def" + if [ "${!var:-}" ]; then + val="${!var}" + elif [ "${!fileVar:-}" ]; then + val="$(< "${!fileVar}")" + fi + export "$var"="$val" + unset "$fileVar" +} + +if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then + if [ "$(id -u)" = '0' ]; then + case "$1" in + apache2*) + user="${APACHE_RUN_USER:-www-data}" + group="${APACHE_RUN_GROUP:-www-data}" + ;; + *) # php-fpm + user='www-data' + group='www-data' + ;; + esac + else + user="$(id -u)" + group="$(id -g)" + fi + + if ! [ -e index.php -a -e wp-includes/version.php ]; then + echo >&2 "WordPress not found in $PWD - copying now..." + if [ "$(ls -A)" ]; then + echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!" + ( set -x; ls -A; sleep 10 ) + fi + tar --create \ + --file - \ + --one-file-system \ + --directory /usr/src/wordpress \ + --owner "$user" --group "$group" \ + . | tar --extract --file - + echo >&2 "Complete! WordPress has been successfully copied to $PWD" + sed -i "/That's all, stop editing!/ i\ +/*\\ + * WP_SITEURL and WP_HOME are configured to allow access from any hostname.\\ + */\\ +define('WP_SITEURL', 'http://' . \$_SERVER['HTTP_HOST'] . '/');\\ +define('WP_HOME', 'http://' . \$_SERVER['HTTP_HOST'] . '/');\\ +" wp-config-sample.php + if [ ! -e .htaccess ]; then + # NOTE: The "Indexes" option is disabled in the php:apache base image + cat > .htaccess <<-'EOF' + # BEGIN WordPress + + RewriteEngine On + RewriteBase / + RewriteRule ^index\.php$ - [L] + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule . /index.php [L] + + # END WordPress + EOF + chown "$user:$group" .htaccess + fi + fi + + # 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 + + # allow any of these "Authentication Unique Keys and Salts." to be specified via + # environment variables with a "WORDPRESS_" prefix (ie, "WORDPRESS_AUTH_KEY") + uniqueEnvs=( + AUTH_KEY + SECURE_AUTH_KEY + LOGGED_IN_KEY + NONCE_KEY + AUTH_SALT + SECURE_AUTH_SALT + LOGGED_IN_SALT + NONCE_SALT + ) + envs=( + WORDPRESS_DB_HOST + WORDPRESS_DB_USER + WORDPRESS_DB_PASSWORD + WORDPRESS_DB_NAME + "${uniqueEnvs[@]/#/WORDPRESS_}" + WORDPRESS_TABLE_PREFIX + WORDPRESS_DEBUG + ) + haveConfig= + for e in "${envs[@]}"; do + file_env "$e" + if [ -z "$haveConfig" ] && [ -n "${!e}" ]; then + haveConfig=1 + fi + done + + # linking backwards-compatibility + if [ -n "${!MYSQL_ENV_MYSQL_*}" ]; then + haveConfig=1 + # host defaults to "mysql" below if unspecified + : "${WORDPRESS_DB_USER:=${MYSQL_ENV_MYSQL_USER:-root}}" + if [ "$WORDPRESS_DB_USER" = 'root' ]; then + : "${WORDPRESS_DB_PASSWORD:=${MYSQL_ENV_MYSQL_ROOT_PASSWORD:-}}" + else + : "${WORDPRESS_DB_PASSWORD:=${MYSQL_ENV_MYSQL_PASSWORD:-}}" + fi + : "${WORDPRESS_DB_NAME:=${MYSQL_ENV_MYSQL_DATABASE:-}}" + fi + + # only touch "wp-config.php" if we have environment-supplied configuration values + if [ "$haveConfig" ]; then + : "${WORDPRESS_DB_HOST:=mysql}" + : "${WORDPRESS_DB_USER:=root}" + : "${WORDPRESS_DB_PASSWORD:=}" + : "${WORDPRESS_DB_NAME:=wordpress}" + + # version 4.4.1 decided to switch to windows line endings, that breaks our seds and awks + # https://github.com/docker-library/wordpress/issues/116 + # https://github.com/WordPress/WordPress/commit/1acedc542fba2482bab88ec70d4bea4b997a92e4 + sed -ri -e 's/\r$//' 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 + chown "$user:$group" wp-config.php + fi + + # see http://stackoverflow.com/a/2705678/433558 + sed_escape_lhs() { + echo "$@" | sed -e 's/[]\/$*.^|[]/\\&/g' + } + sed_escape_rhs() { + echo "$@" | sed -e 's/[\/&]/\\&/g' + } + php_escape() { + local escaped="$(php -r 'var_export(('"$2"') $argv[1]);' -- "$1")" + if [ "$2" = 'string' ] && [ "${escaped:0:1}" = "'" ]; then + escaped="${escaped//$'\n'/"' + \"\\n\" + '"}" + fi + echo "$escaped" + } + set_config() { + key="$1" + value="$2" + var_type="${3:-string}" + start="(['\"])$(sed_escape_lhs "$key")\2\s*," + end="\);" + if [ "${key:0:1}" = '$' ]; then + start="^(\s*)$(sed_escape_lhs "$key")\s*=" + end=";" + fi + sed -ri -e "s/($start\s*).*($end)$/\1$(sed_escape_rhs "$(php_escape "$value" "$var_type")")\3/" wp-config.php + } + + set_config 'DB_HOST' "$WORDPRESS_DB_HOST" + set_config 'DB_USER' "$WORDPRESS_DB_USER" + set_config 'DB_PASSWORD' "$WORDPRESS_DB_PASSWORD" + set_config 'DB_NAME' "$WORDPRESS_DB_NAME" + + for unique in "${uniqueEnvs[@]}"; do + uniqVar="WORDPRESS_$unique" + if [ -n "${!uniqVar}" ]; then + set_config "$unique" "${!uniqVar}" + else + # if not specified, let's generate a random value + currentVal="$(sed -rn -e "s/define\((([\'\"])$unique\2\s*,\s*)(['\"])(.*)\3\);/\4/p" wp-config.php)" + if [ "$currentVal" = 'put your unique phrase here' ]; then + set_config "$unique" "$(head -c1m /dev/urandom | sha1sum | cut -d' ' -f1)" + fi + fi + done + + if [ "$WORDPRESS_TABLE_PREFIX" ]; then + set_config '$table_prefix' "$WORDPRESS_TABLE_PREFIX" + fi + + if [ "$WORDPRESS_DEBUG" ]; then + set_config 'WP_DEBUG' 1 boolean + fi + + TERM=dumb php -- <<'EOPHP' +connect_error) { + fwrite($stderr, "\n" . 'MySQL Connection Error: (' . $mysql->connect_errno . ') ' . $mysql->connect_error . "\n"); + --$maxTries; + if ($maxTries <= 0) { + exit(1); + } + sleep(3); + } +} while ($mysql->connect_error); + +if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($dbName) . '`')) { + fwrite($stderr, "\n" . 'MySQL "CREATE DATABASE" Error: ' . $mysql->error . "\n"); + $mysql->close(); + exit(1); +} + +$mysql->close(); +EOPHP + fi + + # now that we're definitely done writing configuration, let's clear out the relevant envrionment variables (so that stray "phpinfo()" calls don't leak secrets from our code) + for e in "${envs[@]}"; do + unset "$e" + done +fi + +exec "$@" diff --git a/exporter/Dockerfile b/exporter/Dockerfile index 774cf50..b271785 100644 --- a/exporter/Dockerfile +++ b/exporter/Dockerfile @@ -2,9 +2,9 @@ FROM marketplace.gcr.io/google/debian11 as exporter-builder ENV GOPATH /usr/local ENV GOROOT /usr/local/go -ENV GO_VERSION 1.20 +ENV GO_VERSION 1.16 ENV PATH=${GOPATH}/bin:${GOROOT}/bin:${PATH} -ENV EXPORTER_VERSION 0.13.4 +ENV EXPORTER_VERSION 0.10.0 # Installs packages RUN set -eux \ diff --git a/versions.yaml b/versions.yaml index b1ca283..4c0e752 100644 --- a/versions.yaml +++ b/versions.yaml @@ -18,14 +18,14 @@ cloudbuild: enable_parallel: true versions: -- dir: 6/php8/debian11/apache/6.3 +- dir: 6/php7/debian11/apache/6.3 excludeTests: - tests/functional_tests/apache_exporter_test.yaml - from: marketplace.gcr.io/google/php8-apache2:8.2 + from: marketplace.gcr.io/google/php7-apache2:7.4 packages: wordpress: version: 6.3.1 - repo: wordpress6-php8-apache + repo: wordpress6-php7-apache tags: - 6.3.1-debian11 - 6.3-debian11 @@ -41,7 +41,7 @@ versions: - dir: 6/php7/debian11/apache/6.2 excludeTests: - tests/functional_tests/apache_exporter_test.yaml - from: marketplace.gcr.io/google/php8-apache2:8.1 + from: marketplace.gcr.io/google/php7-apache2:7.4 packages: wordpress: version: 6.2.2 @@ -51,24 +51,44 @@ versions: - 6.2-debian11 - 6.2.2 - '6.2' - - latest templateArgs: c2dRelease: 6.2.2 cmd: apache2-foreground templateSubDir: debian11 +- dir: 5/php7/debian11/apache/5.9 + excludeTests: + - tests/functional_tests/apache_exporter_test.yaml + from: marketplace.gcr.io/google/php7-apache2:7.4 + packages: + wordpress: + version: 5.9.7 + repo: wordpress5-php7-apache + tags: + - 5.9.7-debian11 + - 5.9-debian11 + - 5-debian11 + - 5.9.7 + - '5.9' + - '5' + - latest + templateArgs: + c2dRelease: 5.9.7 + cmd: apache2-foreground + templateSubDir: debian11 - dir: exporter excludeTests: - tests/functional_tests/running_test.yaml from: marketplace.gcr.io/google/debian11 packages: apache_exporter: - version: 0.13.4 + version: 0.10.0 golang: - version: '1.20' - repo: apache-exporter0 + version: '1.16' + repo: wordpress6-php7-apache tags: - - 0.13.4 - - '0.13' - - '0' - - latest + - exporter-0.10.0 + - exporter-0.10 + - exporter-0 + - exporter templateSubDir: exporter + From b7f1da1915609e4b1cdddcf362cded30387dcfe3 Mon Sep 17 00:00:00 2001 From: Adrian Manikowski Date: Thu, 28 Dec 2023 09:37:06 +0000 Subject: [PATCH 2/3] php version upgraded to 8.1 and 8.2/ exporter version updated to 0.13.4 --- 5/php7/debian11/apache/5.9/Dockerfile | 61 ---- .../debian11/apache/5.9/docker-entrypoint.sh | 268 ------------------ 6/php7/debian11/apache/6.2/Dockerfile | 2 +- 6/php7/debian11/apache/6.3/Dockerfile | 2 +- exporter/Dockerfile | 4 +- versions.yaml | 38 +-- 6 files changed, 13 insertions(+), 362 deletions(-) delete mode 100644 5/php7/debian11/apache/5.9/Dockerfile delete mode 100755 5/php7/debian11/apache/5.9/docker-entrypoint.sh diff --git a/5/php7/debian11/apache/5.9/Dockerfile b/5/php7/debian11/apache/5.9/Dockerfile deleted file mode 100644 index 4f1d862..0000000 --- a/5/php7/debian11/apache/5.9/Dockerfile +++ /dev/null @@ -1,61 +0,0 @@ -FROM marketplace.gcr.io/google/php7-apache2:7.4 - -# install the PHP extensions we need -RUN set -ex; \ - \ - savedAptMark="$(apt-mark showmanual)"; \ - \ - apt-get update; \ - apt-get install -y --no-install-recommends \ - libjpeg-dev \ - libpng-dev \ - libzip-dev \ - ; \ - \ - docker-php-ext-configure gd --with-jpeg=/usr; \ - docker-php-ext-install gd mysqli opcache zip; \ - \ -# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies - apt-mark auto '.*' > /dev/null; \ - apt-mark manual $savedAptMark; \ - ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \ - | awk '/=>/ { print $3 }' \ - | sort -u \ - | xargs -r realpath | xargs -r dpkg-query --search \ - | cut -d: -f1 \ - | sort -u \ - | xargs -rt apt-mark manual; \ - \ - apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ - rm -rf /var/lib/apt/lists/* - -# set recommended PHP.ini settings -# see https://secure.php.net/manual/en/opcache.installation.php -RUN { \ - echo 'opcache.memory_consumption=128'; \ - echo 'opcache.interned_strings_buffer=8'; \ - echo 'opcache.max_accelerated_files=4000'; \ - echo 'opcache.revalidate_freq=2'; \ - echo 'opcache.fast_shutdown=1'; \ - echo 'opcache.enable_cli=1'; \ - } > /usr/local/etc/php/conf.d/opcache-recommended.ini - -RUN a2enmod rewrite expires - -VOLUME /var/www/html - -ENV WORDPRESS_VERSION 5.9.7 - -ENV C2D_RELEASE 5.9.7 - -RUN set -ex; \ - curl -o wordpress.tar.gz -fSL "https://wordpress.org/wordpress-${WORDPRESS_VERSION}.tar.gz"; \ -# upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress - tar -xzf wordpress.tar.gz -C /usr/src/; \ - rm wordpress.tar.gz; \ - chown -R www-data:www-data /usr/src/wordpress - -COPY docker-entrypoint.sh /usr/local/bin/ - -ENTRYPOINT ["docker-entrypoint.sh"] -CMD ["apache2-foreground"] diff --git a/5/php7/debian11/apache/5.9/docker-entrypoint.sh b/5/php7/debian11/apache/5.9/docker-entrypoint.sh deleted file mode 100755 index a2d1daa..0000000 --- a/5/php7/debian11/apache/5.9/docker-entrypoint.sh +++ /dev/null @@ -1,268 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2017 Google Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -set -euo pipefail - -# usage: file_env VAR [DEFAULT] -# ie: file_env 'XYZ_DB_PASSWORD' 'example' -# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of -# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature) -file_env() { - local var="$1" - local fileVar="${var}_FILE" - local def="${2:-}" - if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then - echo >&2 "error: both $var and $fileVar are set (but are exclusive)" - exit 1 - fi - local val="$def" - if [ "${!var:-}" ]; then - val="${!var}" - elif [ "${!fileVar:-}" ]; then - val="$(< "${!fileVar}")" - fi - export "$var"="$val" - unset "$fileVar" -} - -if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then - if [ "$(id -u)" = '0' ]; then - case "$1" in - apache2*) - user="${APACHE_RUN_USER:-www-data}" - group="${APACHE_RUN_GROUP:-www-data}" - ;; - *) # php-fpm - user='www-data' - group='www-data' - ;; - esac - else - user="$(id -u)" - group="$(id -g)" - fi - - if ! [ -e index.php -a -e wp-includes/version.php ]; then - echo >&2 "WordPress not found in $PWD - copying now..." - if [ "$(ls -A)" ]; then - echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!" - ( set -x; ls -A; sleep 10 ) - fi - tar --create \ - --file - \ - --one-file-system \ - --directory /usr/src/wordpress \ - --owner "$user" --group "$group" \ - . | tar --extract --file - - echo >&2 "Complete! WordPress has been successfully copied to $PWD" - sed -i "/That's all, stop editing!/ i\ -/*\\ - * WP_SITEURL and WP_HOME are configured to allow access from any hostname.\\ - */\\ -define('WP_SITEURL', 'http://' . \$_SERVER['HTTP_HOST'] . '/');\\ -define('WP_HOME', 'http://' . \$_SERVER['HTTP_HOST'] . '/');\\ -" wp-config-sample.php - if [ ! -e .htaccess ]; then - # NOTE: The "Indexes" option is disabled in the php:apache base image - cat > .htaccess <<-'EOF' - # BEGIN WordPress - - RewriteEngine On - RewriteBase / - RewriteRule ^index\.php$ - [L] - RewriteCond %{REQUEST_FILENAME} !-f - RewriteCond %{REQUEST_FILENAME} !-d - RewriteRule . /index.php [L] - - # END WordPress - EOF - chown "$user:$group" .htaccess - fi - fi - - # 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 - - # allow any of these "Authentication Unique Keys and Salts." to be specified via - # environment variables with a "WORDPRESS_" prefix (ie, "WORDPRESS_AUTH_KEY") - uniqueEnvs=( - AUTH_KEY - SECURE_AUTH_KEY - LOGGED_IN_KEY - NONCE_KEY - AUTH_SALT - SECURE_AUTH_SALT - LOGGED_IN_SALT - NONCE_SALT - ) - envs=( - WORDPRESS_DB_HOST - WORDPRESS_DB_USER - WORDPRESS_DB_PASSWORD - WORDPRESS_DB_NAME - "${uniqueEnvs[@]/#/WORDPRESS_}" - WORDPRESS_TABLE_PREFIX - WORDPRESS_DEBUG - ) - haveConfig= - for e in "${envs[@]}"; do - file_env "$e" - if [ -z "$haveConfig" ] && [ -n "${!e}" ]; then - haveConfig=1 - fi - done - - # linking backwards-compatibility - if [ -n "${!MYSQL_ENV_MYSQL_*}" ]; then - haveConfig=1 - # host defaults to "mysql" below if unspecified - : "${WORDPRESS_DB_USER:=${MYSQL_ENV_MYSQL_USER:-root}}" - if [ "$WORDPRESS_DB_USER" = 'root' ]; then - : "${WORDPRESS_DB_PASSWORD:=${MYSQL_ENV_MYSQL_ROOT_PASSWORD:-}}" - else - : "${WORDPRESS_DB_PASSWORD:=${MYSQL_ENV_MYSQL_PASSWORD:-}}" - fi - : "${WORDPRESS_DB_NAME:=${MYSQL_ENV_MYSQL_DATABASE:-}}" - fi - - # only touch "wp-config.php" if we have environment-supplied configuration values - if [ "$haveConfig" ]; then - : "${WORDPRESS_DB_HOST:=mysql}" - : "${WORDPRESS_DB_USER:=root}" - : "${WORDPRESS_DB_PASSWORD:=}" - : "${WORDPRESS_DB_NAME:=wordpress}" - - # version 4.4.1 decided to switch to windows line endings, that breaks our seds and awks - # https://github.com/docker-library/wordpress/issues/116 - # https://github.com/WordPress/WordPress/commit/1acedc542fba2482bab88ec70d4bea4b997a92e4 - sed -ri -e 's/\r$//' 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 - chown "$user:$group" wp-config.php - fi - - # see http://stackoverflow.com/a/2705678/433558 - sed_escape_lhs() { - echo "$@" | sed -e 's/[]\/$*.^|[]/\\&/g' - } - sed_escape_rhs() { - echo "$@" | sed -e 's/[\/&]/\\&/g' - } - php_escape() { - local escaped="$(php -r 'var_export(('"$2"') $argv[1]);' -- "$1")" - if [ "$2" = 'string' ] && [ "${escaped:0:1}" = "'" ]; then - escaped="${escaped//$'\n'/"' + \"\\n\" + '"}" - fi - echo "$escaped" - } - set_config() { - key="$1" - value="$2" - var_type="${3:-string}" - start="(['\"])$(sed_escape_lhs "$key")\2\s*," - end="\);" - if [ "${key:0:1}" = '$' ]; then - start="^(\s*)$(sed_escape_lhs "$key")\s*=" - end=";" - fi - sed -ri -e "s/($start\s*).*($end)$/\1$(sed_escape_rhs "$(php_escape "$value" "$var_type")")\3/" wp-config.php - } - - set_config 'DB_HOST' "$WORDPRESS_DB_HOST" - set_config 'DB_USER' "$WORDPRESS_DB_USER" - set_config 'DB_PASSWORD' "$WORDPRESS_DB_PASSWORD" - set_config 'DB_NAME' "$WORDPRESS_DB_NAME" - - for unique in "${uniqueEnvs[@]}"; do - uniqVar="WORDPRESS_$unique" - if [ -n "${!uniqVar}" ]; then - set_config "$unique" "${!uniqVar}" - else - # if not specified, let's generate a random value - currentVal="$(sed -rn -e "s/define\((([\'\"])$unique\2\s*,\s*)(['\"])(.*)\3\);/\4/p" wp-config.php)" - if [ "$currentVal" = 'put your unique phrase here' ]; then - set_config "$unique" "$(head -c1m /dev/urandom | sha1sum | cut -d' ' -f1)" - fi - fi - done - - if [ "$WORDPRESS_TABLE_PREFIX" ]; then - set_config '$table_prefix' "$WORDPRESS_TABLE_PREFIX" - fi - - if [ "$WORDPRESS_DEBUG" ]; then - set_config 'WP_DEBUG' 1 boolean - fi - - TERM=dumb php -- <<'EOPHP' -connect_error) { - fwrite($stderr, "\n" . 'MySQL Connection Error: (' . $mysql->connect_errno . ') ' . $mysql->connect_error . "\n"); - --$maxTries; - if ($maxTries <= 0) { - exit(1); - } - sleep(3); - } -} while ($mysql->connect_error); - -if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($dbName) . '`')) { - fwrite($stderr, "\n" . 'MySQL "CREATE DATABASE" Error: ' . $mysql->error . "\n"); - $mysql->close(); - exit(1); -} - -$mysql->close(); -EOPHP - fi - - # now that we're definitely done writing configuration, let's clear out the relevant envrionment variables (so that stray "phpinfo()" calls don't leak secrets from our code) - for e in "${envs[@]}"; do - unset "$e" - done -fi - -exec "$@" diff --git a/6/php7/debian11/apache/6.2/Dockerfile b/6/php7/debian11/apache/6.2/Dockerfile index b79103f..d52de4c 100644 --- a/6/php7/debian11/apache/6.2/Dockerfile +++ b/6/php7/debian11/apache/6.2/Dockerfile @@ -1,4 +1,4 @@ -FROM marketplace.gcr.io/google/php7-apache2:7.4 +FROM marketplace.gcr.io/google/php8-apache2:8.1 # install the PHP extensions we need RUN set -ex; \ diff --git a/6/php7/debian11/apache/6.3/Dockerfile b/6/php7/debian11/apache/6.3/Dockerfile index 0366b40..1b086f8 100644 --- a/6/php7/debian11/apache/6.3/Dockerfile +++ b/6/php7/debian11/apache/6.3/Dockerfile @@ -1,4 +1,4 @@ -FROM marketplace.gcr.io/google/php7-apache2:7.4 +FROM marketplace.gcr.io/google/php8-apache2:8.2 # install the PHP extensions we need RUN set -ex; \ diff --git a/exporter/Dockerfile b/exporter/Dockerfile index b271785..774cf50 100644 --- a/exporter/Dockerfile +++ b/exporter/Dockerfile @@ -2,9 +2,9 @@ FROM marketplace.gcr.io/google/debian11 as exporter-builder ENV GOPATH /usr/local ENV GOROOT /usr/local/go -ENV GO_VERSION 1.16 +ENV GO_VERSION 1.20 ENV PATH=${GOPATH}/bin:${GOROOT}/bin:${PATH} -ENV EXPORTER_VERSION 0.10.0 +ENV EXPORTER_VERSION 0.13.4 # Installs packages RUN set -eux \ diff --git a/versions.yaml b/versions.yaml index 4c0e752..0eb779d 100644 --- a/versions.yaml +++ b/versions.yaml @@ -21,11 +21,11 @@ versions: - dir: 6/php7/debian11/apache/6.3 excludeTests: - tests/functional_tests/apache_exporter_test.yaml - from: marketplace.gcr.io/google/php7-apache2:7.4 + from: marketplace.gcr.io/google/php8-apache2:8.2 packages: wordpress: version: 6.3.1 - repo: wordpress6-php7-apache + repo: wordpress6-php8-apache tags: - 6.3.1-debian11 - 6.3-debian11 @@ -41,11 +41,11 @@ versions: - dir: 6/php7/debian11/apache/6.2 excludeTests: - tests/functional_tests/apache_exporter_test.yaml - from: marketplace.gcr.io/google/php7-apache2:7.4 + from: marketplace.gcr.io/google/php8-apache2:8.1 packages: wordpress: version: 6.2.2 - repo: wordpress6-php7-apache + repo: wordpress6-php8-apache tags: - 6.2.2-debian11 - 6.2-debian11 @@ -55,39 +55,19 @@ versions: c2dRelease: 6.2.2 cmd: apache2-foreground templateSubDir: debian11 -- dir: 5/php7/debian11/apache/5.9 - excludeTests: - - tests/functional_tests/apache_exporter_test.yaml - from: marketplace.gcr.io/google/php7-apache2:7.4 - packages: - wordpress: - version: 5.9.7 - repo: wordpress5-php7-apache - tags: - - 5.9.7-debian11 - - 5.9-debian11 - - 5-debian11 - - 5.9.7 - - '5.9' - - '5' - - latest - templateArgs: - c2dRelease: 5.9.7 - cmd: apache2-foreground - templateSubDir: debian11 - dir: exporter excludeTests: - tests/functional_tests/running_test.yaml from: marketplace.gcr.io/google/debian11 packages: apache_exporter: - version: 0.10.0 + version: 0.13.4 golang: - version: '1.16' - repo: wordpress6-php7-apache + version: '1.20' + repo: apache-exporter0 tags: - - exporter-0.10.0 - - exporter-0.10 + - exporter-0.13.4 + - exporter-0.13 - exporter-0 - exporter templateSubDir: exporter From 73e6e5870d14099626929c05268d03acbbcd9e97 Mon Sep 17 00:00:00 2001 From: Adrian Manikowski Date: Thu, 28 Dec 2023 12:55:12 +0000 Subject: [PATCH 3/3] Added new directory for php8 --- 6/{php7 => php8}/debian11/apache/6.2/Dockerfile | 0 6/{php7 => php8}/debian11/apache/6.2/docker-entrypoint.sh | 0 6/{php7 => php8}/debian11/apache/6.3/Dockerfile | 0 6/{php7 => php8}/debian11/apache/6.3/docker-entrypoint.sh | 0 versions.yaml | 4 ++-- 5 files changed, 2 insertions(+), 2 deletions(-) rename 6/{php7 => php8}/debian11/apache/6.2/Dockerfile (100%) rename 6/{php7 => php8}/debian11/apache/6.2/docker-entrypoint.sh (100%) rename 6/{php7 => php8}/debian11/apache/6.3/Dockerfile (100%) rename 6/{php7 => php8}/debian11/apache/6.3/docker-entrypoint.sh (100%) diff --git a/6/php7/debian11/apache/6.2/Dockerfile b/6/php8/debian11/apache/6.2/Dockerfile similarity index 100% rename from 6/php7/debian11/apache/6.2/Dockerfile rename to 6/php8/debian11/apache/6.2/Dockerfile diff --git a/6/php7/debian11/apache/6.2/docker-entrypoint.sh b/6/php8/debian11/apache/6.2/docker-entrypoint.sh similarity index 100% rename from 6/php7/debian11/apache/6.2/docker-entrypoint.sh rename to 6/php8/debian11/apache/6.2/docker-entrypoint.sh diff --git a/6/php7/debian11/apache/6.3/Dockerfile b/6/php8/debian11/apache/6.3/Dockerfile similarity index 100% rename from 6/php7/debian11/apache/6.3/Dockerfile rename to 6/php8/debian11/apache/6.3/Dockerfile diff --git a/6/php7/debian11/apache/6.3/docker-entrypoint.sh b/6/php8/debian11/apache/6.3/docker-entrypoint.sh similarity index 100% rename from 6/php7/debian11/apache/6.3/docker-entrypoint.sh rename to 6/php8/debian11/apache/6.3/docker-entrypoint.sh diff --git a/versions.yaml b/versions.yaml index 0eb779d..e6177bc 100644 --- a/versions.yaml +++ b/versions.yaml @@ -18,7 +18,7 @@ cloudbuild: enable_parallel: true versions: -- dir: 6/php7/debian11/apache/6.3 +- dir: 6/php8/debian11/apache/6.3 excludeTests: - tests/functional_tests/apache_exporter_test.yaml from: marketplace.gcr.io/google/php8-apache2:8.2 @@ -38,7 +38,7 @@ versions: c2dRelease: 6.3.1 cmd: apache2-foreground templateSubDir: debian11 -- dir: 6/php7/debian11/apache/6.2 +- dir: 6/php8/debian11/apache/6.2 excludeTests: - tests/functional_tests/apache_exporter_test.yaml from: marketplace.gcr.io/google/php8-apache2:8.1