From 69994acba3593ab688fc5226ef975ab08ab32f2d Mon Sep 17 00:00:00 2001 From: cytopia Date: Sat, 7 Apr 2018 13:49:38 +0200 Subject: [PATCH 1/4] Add option to customize PHP-FPM configuration --- Dockerfiles/base/data/php-fpm.d/pool.conf | 13 -- Dockerfiles/prod/Dockerfile-5.4 | 1 + Dockerfiles/prod/Dockerfile-5.5 | 1 + Dockerfiles/prod/Dockerfile-5.6 | 1 + Dockerfiles/prod/Dockerfile-7.0 | 1 + Dockerfiles/prod/Dockerfile-7.1 | 1 + Dockerfiles/prod/Dockerfile-7.2 | 1 + .../36-custom-php-fpm-files.sh | 48 +++++ Dockerfiles/prod/data/docker-entrypoint.sh | 12 ++ Dockerfiles/work/Dockerfile-5.4 | 1 + Dockerfiles/work/Dockerfile-5.5 | 1 + Dockerfiles/work/Dockerfile-5.6 | 1 + Dockerfiles/work/Dockerfile-7.0 | 1 + Dockerfiles/work/Dockerfile-7.1 | 1 + Dockerfiles/work/Dockerfile-7.2 | 1 + Dockerfiles/work/data/docker-entrypoint.sh | 12 ++ README.md | 8 +- build/ansible/DOCKERFILES/Dockerfile-prod.j2 | 1 + build/ansible/DOCKERFILES/Dockerfile-work.j2 | 1 + tests/base/04-test-run_nginx.sh | 8 +- tests/prod/06-test-mount-custom_fpm_conf.sh | 181 ++++++++++++++++++ 21 files changed, 277 insertions(+), 19 deletions(-) create mode 100755 Dockerfiles/prod/data/docker-entrypoint.d/36-custom-php-fpm-files.sh create mode 100755 tests/prod/06-test-mount-custom_fpm_conf.sh diff --git a/Dockerfiles/base/data/php-fpm.d/pool.conf b/Dockerfiles/base/data/php-fpm.d/pool.conf index 1ed4f1ae..0d2f1991 100644 --- a/Dockerfiles/base/data/php-fpm.d/pool.conf +++ b/Dockerfiles/base/data/php-fpm.d/pool.conf @@ -1,18 +1,5 @@ [www] -; User and Group -user = devilbox -group = devilbox - -; Ensure to listen here -listen = 9000 - -; Keep env variables set by docker -clear_env = no - -; Ensure worker stdout and stderr are sent to the main error log. -catch_workers_output = yes - ; Pool config pm = dynamic pm.max_children = 5 diff --git a/Dockerfiles/prod/Dockerfile-5.4 b/Dockerfiles/prod/Dockerfile-5.4 index 53bad653..8ae68068 100644 --- a/Dockerfiles/prod/Dockerfile-5.4 +++ b/Dockerfiles/prod/Dockerfile-5.4 @@ -58,6 +58,7 @@ COPY ./data/supervisord.conf /etc/supervisor/supervisord.conf ### Volumes ### VOLUME /etc/php-custom.d +VOLUME /etc/php-fpm-custom.d VOLUME /etc/php-modules.d VOLUME /var/log/php VOLUME /var/mail diff --git a/Dockerfiles/prod/Dockerfile-5.5 b/Dockerfiles/prod/Dockerfile-5.5 index 530b6158..df204b87 100644 --- a/Dockerfiles/prod/Dockerfile-5.5 +++ b/Dockerfiles/prod/Dockerfile-5.5 @@ -58,6 +58,7 @@ COPY ./data/supervisord.conf /etc/supervisor/supervisord.conf ### Volumes ### VOLUME /etc/php-custom.d +VOLUME /etc/php-fpm-custom.d VOLUME /etc/php-modules.d VOLUME /var/log/php VOLUME /var/mail diff --git a/Dockerfiles/prod/Dockerfile-5.6 b/Dockerfiles/prod/Dockerfile-5.6 index e84ac603..c9206724 100644 --- a/Dockerfiles/prod/Dockerfile-5.6 +++ b/Dockerfiles/prod/Dockerfile-5.6 @@ -58,6 +58,7 @@ COPY ./data/supervisord.conf /etc/supervisor/supervisord.conf ### Volumes ### VOLUME /etc/php-custom.d +VOLUME /etc/php-fpm-custom.d VOLUME /etc/php-modules.d VOLUME /var/log/php VOLUME /var/mail diff --git a/Dockerfiles/prod/Dockerfile-7.0 b/Dockerfiles/prod/Dockerfile-7.0 index 6992be67..6d61515b 100644 --- a/Dockerfiles/prod/Dockerfile-7.0 +++ b/Dockerfiles/prod/Dockerfile-7.0 @@ -58,6 +58,7 @@ COPY ./data/supervisord.conf /etc/supervisor/supervisord.conf ### Volumes ### VOLUME /etc/php-custom.d +VOLUME /etc/php-fpm-custom.d VOLUME /etc/php-modules.d VOLUME /var/log/php VOLUME /var/mail diff --git a/Dockerfiles/prod/Dockerfile-7.1 b/Dockerfiles/prod/Dockerfile-7.1 index e44ca40e..ee4d98bb 100644 --- a/Dockerfiles/prod/Dockerfile-7.1 +++ b/Dockerfiles/prod/Dockerfile-7.1 @@ -58,6 +58,7 @@ COPY ./data/supervisord.conf /etc/supervisor/supervisord.conf ### Volumes ### VOLUME /etc/php-custom.d +VOLUME /etc/php-fpm-custom.d VOLUME /etc/php-modules.d VOLUME /var/log/php VOLUME /var/mail diff --git a/Dockerfiles/prod/Dockerfile-7.2 b/Dockerfiles/prod/Dockerfile-7.2 index 40f6f2c3..bae41cd0 100644 --- a/Dockerfiles/prod/Dockerfile-7.2 +++ b/Dockerfiles/prod/Dockerfile-7.2 @@ -58,6 +58,7 @@ COPY ./data/supervisord.conf /etc/supervisor/supervisord.conf ### Volumes ### VOLUME /etc/php-custom.d +VOLUME /etc/php-fpm-custom.d VOLUME /etc/php-modules.d VOLUME /var/log/php VOLUME /var/mail diff --git a/Dockerfiles/prod/data/docker-entrypoint.d/36-custom-php-fpm-files.sh b/Dockerfiles/prod/data/docker-entrypoint.d/36-custom-php-fpm-files.sh new file mode 100755 index 00000000..6536bedc --- /dev/null +++ b/Dockerfiles/prod/data/docker-entrypoint.d/36-custom-php-fpm-files.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash + +set -e +set -u +set -o pipefail + + +############################################################ +# Functions +############################################################ + +### +### Copy PHP-FPM *.conf files from source to destination with prefix +### +copy_fpm_files() { + local fpm_src="${1}" + local fpm_dst="${2}" + local debug="${3}" + + if [ ! -d "${fpm_src}" ]; then + run "mkdir -p ${fpm_src}" "${debug}" + fi + fpm_files="$( find "${fpm_src}" -type f -iname '*.conf' )" + + # loop over them line by line + IFS=' + ' + for fpm_f in ${fpm_files}; do + fpm_name="$( basename "${fpm_f}" )" + log "info" "PHP-FOM.conf: ${fpm_name} -> ${fpm_dst}/zzz-devilbox-${fpm_name}" "${debug}" + run "cp ${fpm_f} ${fpm_dst}/zzz-devilbox-${fpm_name}" "${debug}" + done + run "find ${fpm_dst} -type f -iname '*.conf' -exec chmod 0644 \"{}\" \;" "${debug}" +} + + +############################################################ +# Sanity Checks +############################################################ + +if ! command -v find >/dev/null 2>&1; then + echo "find not found, but required." + exit 1 +fi +if ! command -v basename >/dev/null 2>&1; then + echo "basename not found, but required." + exit 1 +fi diff --git a/Dockerfiles/prod/data/docker-entrypoint.sh b/Dockerfiles/prod/data/docker-entrypoint.sh index 09295492..130cdad3 100755 --- a/Dockerfiles/prod/data/docker-entrypoint.sh +++ b/Dockerfiles/prod/data/docker-entrypoint.sh @@ -21,6 +21,9 @@ CONFIG_DIR="/docker-entrypoint.d" # php.ini.d directory PHP_INI_DIR="/usr/local/etc/php/conf.d" +# php-fpm conf.d directory +PHP_FPM_DIR="/usr/local/etc/php-fpm.d" + # This is the log file for any mail related functions PHP_MAIL_LOG="/var/log/mail.log" @@ -33,6 +36,9 @@ FPM_LOG_DIR="/var/log/php" # Custom ini dir (to be copied to actual ini dir) PHP_CUST_INI_DIR="/etc/php-custom.d" +# Custom PHP-FPM dir (to be copied to actual FPM conf dir) +PHP_CUST_FPM_DIR="/etc/php-fpm-custom.d" + # Supervisord config directory SUPERVISOR_CONFD="/etc/supervisor/conf.d" @@ -140,6 +146,12 @@ supervisor_add_service "php-fpm" "/usr/local/sbin/php-fpm" "${SUPERVISOR_CONFD} copy_ini_files "${PHP_CUST_INI_DIR}" "${PHP_INI_DIR}" "${DEBUG_LEVEL}" +### +### Copy custom PHP-FPM *.conf files +### +copy_fpm_files "${PHP_CUST_FPM_DIR}" "${PHP_FPM_DIR}" "${DEBUG_LEVEL}" + + ### ### Startup ### diff --git a/Dockerfiles/work/Dockerfile-5.4 b/Dockerfiles/work/Dockerfile-5.4 index c5706fc2..c0e1ad84 100644 --- a/Dockerfiles/work/Dockerfile-5.4 +++ b/Dockerfiles/work/Dockerfile-5.4 @@ -303,6 +303,7 @@ COPY ./data/sudo-devilbox /etc/sudoers.d/devilbox ### VOLUME /etc/bash-custom.d VOLUME /etc/php-custom.d +VOLUME /etc/php-fpm-custom.d VOLUME /etc/php-modules.d VOLUME /shared/backups VOLUME /var/log/php diff --git a/Dockerfiles/work/Dockerfile-5.5 b/Dockerfiles/work/Dockerfile-5.5 index c64d3edd..9ec28608 100644 --- a/Dockerfiles/work/Dockerfile-5.5 +++ b/Dockerfiles/work/Dockerfile-5.5 @@ -307,6 +307,7 @@ COPY ./data/sudo-devilbox /etc/sudoers.d/devilbox ### VOLUME /etc/bash-custom.d VOLUME /etc/php-custom.d +VOLUME /etc/php-fpm-custom.d VOLUME /etc/php-modules.d VOLUME /shared/backups VOLUME /var/log/php diff --git a/Dockerfiles/work/Dockerfile-5.6 b/Dockerfiles/work/Dockerfile-5.6 index c23ecce9..9942a87b 100644 --- a/Dockerfiles/work/Dockerfile-5.6 +++ b/Dockerfiles/work/Dockerfile-5.6 @@ -307,6 +307,7 @@ COPY ./data/sudo-devilbox /etc/sudoers.d/devilbox ### VOLUME /etc/bash-custom.d VOLUME /etc/php-custom.d +VOLUME /etc/php-fpm-custom.d VOLUME /etc/php-modules.d VOLUME /shared/backups VOLUME /var/log/php diff --git a/Dockerfiles/work/Dockerfile-7.0 b/Dockerfiles/work/Dockerfile-7.0 index 2ff108ea..49cf24c1 100644 --- a/Dockerfiles/work/Dockerfile-7.0 +++ b/Dockerfiles/work/Dockerfile-7.0 @@ -307,6 +307,7 @@ COPY ./data/sudo-devilbox /etc/sudoers.d/devilbox ### VOLUME /etc/bash-custom.d VOLUME /etc/php-custom.d +VOLUME /etc/php-fpm-custom.d VOLUME /etc/php-modules.d VOLUME /shared/backups VOLUME /var/log/php diff --git a/Dockerfiles/work/Dockerfile-7.1 b/Dockerfiles/work/Dockerfile-7.1 index 1853520c..20ea6fc8 100644 --- a/Dockerfiles/work/Dockerfile-7.1 +++ b/Dockerfiles/work/Dockerfile-7.1 @@ -307,6 +307,7 @@ COPY ./data/sudo-devilbox /etc/sudoers.d/devilbox ### VOLUME /etc/bash-custom.d VOLUME /etc/php-custom.d +VOLUME /etc/php-fpm-custom.d VOLUME /etc/php-modules.d VOLUME /shared/backups VOLUME /var/log/php diff --git a/Dockerfiles/work/Dockerfile-7.2 b/Dockerfiles/work/Dockerfile-7.2 index e67d69ca..ff4e05b9 100644 --- a/Dockerfiles/work/Dockerfile-7.2 +++ b/Dockerfiles/work/Dockerfile-7.2 @@ -307,6 +307,7 @@ COPY ./data/sudo-devilbox /etc/sudoers.d/devilbox ### VOLUME /etc/bash-custom.d VOLUME /etc/php-custom.d +VOLUME /etc/php-fpm-custom.d VOLUME /etc/php-modules.d VOLUME /shared/backups VOLUME /var/log/php diff --git a/Dockerfiles/work/data/docker-entrypoint.sh b/Dockerfiles/work/data/docker-entrypoint.sh index 19a3d5b4..cc132623 100755 --- a/Dockerfiles/work/data/docker-entrypoint.sh +++ b/Dockerfiles/work/data/docker-entrypoint.sh @@ -21,6 +21,9 @@ CONFIG_DIR="/docker-entrypoint.d" # php.ini.d directory PHP_INI_DIR="/usr/local/etc/php/conf.d" +# php-fpm conf.d directory +PHP_FPM_DIR="/usr/local/etc/php-fpm.d" + # This is the log file for any mail related functions PHP_MAIL_LOG="/var/log/mail.log" @@ -33,6 +36,9 @@ FPM_LOG_DIR="/var/log/php" # Custom ini dir (to be copied to actual ini dir) PHP_CUST_INI_DIR="/etc/php-custom.d" +# Custom PHP-FPM dir (to be copied to actual FPM conf dir) +PHP_CUST_FPM_DIR="/etc/php-fpm-custom.d" + # Supervisord config directory SUPERVISOR_CONFD="/etc/supervisor/conf.d" @@ -140,6 +146,12 @@ supervisor_add_service "php-fpm" "/usr/local/sbin/php-fpm" "${SUPERVISOR_CONFD} copy_ini_files "${PHP_CUST_INI_DIR}" "${PHP_INI_DIR}" "${DEBUG_LEVEL}" +### +### Copy custom PHP-FPM *.conf files +### +copy_fpm_files "${PHP_CUST_FPM_DIR}" "${PHP_FPM_DIR}" "${DEBUG_LEVEL}" + + ### ### mysqldump-secure ### diff --git a/README.md b/README.md index 6e12d849..afb03483 100644 --- a/README.md +++ b/README.md @@ -97,16 +97,20 @@ Have a look at the following table to see all offered volumes for each Docker im Image - Volumes + Volumes Description - prod

work + prod

work /etc/php-custom.d Mount this directory into your host computer and add custom \*.ini files in order to alter php behaviour. + + /etc/php-fpm-custom.d + Mount this directory into your host computer and add custom PHP-FOM \*.conf files in order to alter PHP-FPM behaviour. + /etc/php-modules.d Mount this directory into your host computer and add custo \*.so files in order to add your php modules.

Note:Your should then also provide a custom \*.ini file in order to actually load your custom provided module. diff --git a/build/ansible/DOCKERFILES/Dockerfile-prod.j2 b/build/ansible/DOCKERFILES/Dockerfile-prod.j2 index 10153824..95bb84a8 100644 --- a/build/ansible/DOCKERFILES/Dockerfile-prod.j2 +++ b/build/ansible/DOCKERFILES/Dockerfile-prod.j2 @@ -60,6 +60,7 @@ COPY ./data/supervisord.conf /etc/supervisor/supervisord.conf ### Volumes ### VOLUME /etc/php-custom.d +VOLUME /etc/php-fpm-custom.d VOLUME /etc/php-modules.d VOLUME /var/log/php VOLUME /var/mail diff --git a/build/ansible/DOCKERFILES/Dockerfile-work.j2 b/build/ansible/DOCKERFILES/Dockerfile-work.j2 index 3e4c5f28..e546ca57 100644 --- a/build/ansible/DOCKERFILES/Dockerfile-work.j2 +++ b/build/ansible/DOCKERFILES/Dockerfile-work.j2 @@ -194,6 +194,7 @@ COPY ./data/sudo-devilbox /etc/sudoers.d/devilbox ### VOLUME /etc/bash-custom.d VOLUME /etc/php-custom.d +VOLUME /etc/php-fpm-custom.d VOLUME /etc/php-modules.d VOLUME /shared/backups VOLUME /var/log/php diff --git a/tests/base/04-test-run_nginx.sh b/tests/base/04-test-run_nginx.sh index 83d0ab67..cc735394 100755 --- a/tests/base/04-test-run_nginx.sh +++ b/tests/base/04-test-run_nginx.sh @@ -71,8 +71,8 @@ run "sleep 10" ### ### Check correct PHP-FPM user ### -if ! docker_exec "${did}" "ps aux | grep 'php-fpm: pool' | grep -v grep | awk '{ print \$1 }' | head -1 | grep devilbox"; then - docker_exec "${did}" "ps aux" +if ! docker_exec "${did}" "ps auxw | grep 'php-fpm: pool' | grep -v grep | awk '{ print \$1 }' | head -1 | grep devilbox"; then + docker_exec "${did}" "ps auxw" # Shutdown docker_stop "${ndid}" || true @@ -82,8 +82,8 @@ if ! docker_exec "${did}" "ps aux | grep 'php-fpm: pool' | grep -v grep | awk '{ echo "Failed" exit 1 fi -if ! docker_exec "${did}" "ps aux | grep 'php-fpm: pool' | grep -v grep | awk '{ print \$1 }' | tail -1 | grep devilbox"; then - docker_exec "${did}" "ps aux" +if ! docker_exec "${did}" "ps auxw | grep 'php-fpm: pool' | grep -v grep | awk '{ print \$1 }' | tail -1 | grep devilbox"; then + docker_exec "${did}" "ps auxw" # Shutdown docker_stop "${ndid}" || true diff --git a/tests/prod/06-test-mount-custom_fpm_conf.sh b/tests/prod/06-test-mount-custom_fpm_conf.sh new file mode 100755 index 00000000..9eb34c06 --- /dev/null +++ b/tests/prod/06-test-mount-custom_fpm_conf.sh @@ -0,0 +1,181 @@ +#!/usr/bin/env bash + +set -e +set -u +set -o pipefail + +CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)" + +IMAGE="${1}" +VERSION="${2}" +FLAVOUR="${3}" + +# shellcheck disable=SC1090 +. "${CWD}/../.lib.sh" + + + +############################################################ +# Tests +############################################################ + +### +### Test Nginx with PHP-FPM +### +WWW_PORT="23254" +DOC_ROOT_HOST="$( mktemp -d )" +DOC_ROOT_CONT="/var/www/default" + +CONFIG_HOST="$( mktemp -d )" +CONFIG_CONT="/etc/nginx/conf.d" + +PHP_CNF_HOST="$( mktemp -d )" +PHP_CNF_CONT="/etc/php-fpm-custom.d" + +CONTAINER="nginx:stable" + +echo "php_admin_value[post_max_size] = 17M" > "${PHP_CNF_HOST}/post.conf" +echo " "${DOC_ROOT_HOST}/index.php" + +# Fix mount permissions +chmod 0777 "${CONFIG_HOST}" +chmod 0777 "${PHP_CNF_HOST}" +chmod 0777 "${DOC_ROOT_HOST}" +chmod 0644 "${DOC_ROOT_HOST}/index.php" + +# Pull container +run "docker pull ${CONTAINER}" + +# Start PHP-FPM +did="$( docker_run "${IMAGE}:${VERSION}-${FLAVOUR}" "-e DEBUG_ENTRYPOINT=2 -e NEW_UID=$(id -u) -e NEW_GID=$(id -g) -v ${DOC_ROOT_HOST}:${DOC_ROOT_CONT} -v ${PHP_CNF_HOST}:${PHP_CNF_CONT}" )" +name="$( docker_name "${did}" )" + +# Nginx.conf +{ + echo "server {" + echo " server_name _;" + echo " listen 80;" + echo " root ${DOC_ROOT_CONT};" + echo " index index.php;" + echo " location ~* \.php\$ {" + echo " fastcgi_index index.php;" + echo " fastcgi_pass ${name}:9000;" + echo " include fastcgi_params;" + echo " fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;" + echo " fastcgi_param SCRIPT_NAME \$fastcgi_script_name;" + echo " }" + echo "}" +} > "${CONFIG_HOST}/php.conf" + + +# Start Nginx +ndid="$( docker_run "${CONTAINER}" "-v ${DOC_ROOT_HOST}:${DOC_ROOT_CONT} -v ${CONFIG_HOST}:${CONFIG_CONT} -p ${WWW_PORT}:80 --link ${name}" )" + +# Wait for both containers to be up and running +run "sleep 10" + +# Check entrypoint +if ! run "docker logs ${did} | grep 'post.conf'"; then + docker_logs "${ndid}" || true + docker_logs "${did}" || true + docker_stop "${ndid}" || true + docker_stop "${did}" || true + rm -rf "${DOC_ROOT_HOST}" + rm -rf "${CONFIG_HOST}" + rm -rf "${PHP_CNF_HOST}" + echo "Failed" + exit 1 +fi + +# Check PHP connectivity +if ! run "curl -q -4 http://127.0.0.1:${WWW_PORT}/index.php >/dev/null 2>&1"; then + # Info + run "netstat -tuln" + run "curl -4 http://127.0.0.1:${WWW_PORT}/index.php" || true + run "curl -6 http://127.0.0.1:${WWW_PORT}/index.php" || true + run "docker ps --no-trunc" + docker_exec "${ndid}" "nginx -t" + + # Show logs + docker_logs "${ndid}" || true + docker_logs "${did}" || true + + # Ensure file is available + docker_exec "${ndid}" "ls -la ${DOC_ROOT_CONT}/" + docker_exec "${did}" "ls -la ${DOC_ROOT_CONT}/" + + docker_exec "${ndid}" "cat ${DOC_ROOT_CONT}/index.php" + docker_exec "${did}" "cat ${DOC_ROOT_CONT}/index.php" + + # Nginx configuration + docker_exec "${ndid}" "cat ${CONFIG_CONT}/php.conf" + + # Shutdown + docker_stop "${ndid}" || true + docker_stop "${did}" || true + rm -rf "${DOC_ROOT_HOST}" + rm -rf "${CONFIG_HOST}" + rm -rf "${PHP_CNF_HOST}" + echo "Failed" + exit 1 +fi + +# Check modified php-fpm.conf +if ! docker_exec "${did}" "php -r \"echo ini_get('post_max_size');\" | grep '17M'"; then + # Info + docker_exec "${did}" "php -r \"echo ini_get('post_max_size');\"" + + # Show logs + docker_logs "${ndid}" || true + docker_logs "${did}" || true + + # Shutdown + docker_stop "${ndid}" || true + docker_stop "${did}" || true + rm -rf "${DOC_ROOT_HOST}" + rm -rf "${CONFIG_HOST}" + rm -rf "${PHP_CNF_HOST}" + echo "Failed" + exit 1 +fi + +# Check modified php-fpm.conf +if ! run "curl -q -4 http://127.0.0.1:${WWW_PORT}/index.php 2>/dev/null | grep post_max_size | grep '17M'"; then + # Info + run "netstat -tuln" + run "curl -4 http://127.0.0.1:${WWW_PORT}/index.php" || true + run "curl -6 http://127.0.0.1:${WWW_PORT}/index.php" || true + run "docker ps --no-trunc" + docker_exec "${ndid}" "nginx -t" + + # Show logs + docker_logs "${ndid}" || true + docker_logs "${did}" || true + + # Ensure file is available + docker_exec "${ndid}" "ls -la ${DOC_ROOT_CONT}/" + docker_exec "${did}" "ls -la ${DOC_ROOT_CONT}/" + + docker_exec "${ndid}" "cat ${DOC_ROOT_CONT}/index.php" + docker_exec "${did}" "cat ${DOC_ROOT_CONT}/index.php" + + # Nginx configuration + docker_exec "${ndid}" "cat ${CONFIG_CONT}/php.conf" + + # Shutdown + docker_stop "${ndid}" || true + docker_stop "${did}" || true + rm -rf "${DOC_ROOT_HOST}" + rm -rf "${CONFIG_HOST}" + rm -rf "${PHP_CNF_HOST}" + echo "Failed" + exit 1 +fi + + +# Cleanup +docker_stop "${did}" +docker_stop "${ndid}" +rm -rf "${DOC_ROOT_HOST}" +rm -rf "${CONFIG_HOST}" +rm -rf "${PHP_CNF_HOST}" From 2641449b433adf49d30200dd06196359ab89e51a Mon Sep 17 00:00:00 2001 From: cytopia Date: Sat, 7 Apr 2018 15:39:45 +0200 Subject: [PATCH 2/4] Ajust php-fpm config tests --- tests/prod/06-test-mount-custom_fpm_conf.sh | 25 +++------------------ 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/tests/prod/06-test-mount-custom_fpm_conf.sh b/tests/prod/06-test-mount-custom_fpm_conf.sh index 9eb34c06..98a75817 100755 --- a/tests/prod/06-test-mount-custom_fpm_conf.sh +++ b/tests/prod/06-test-mount-custom_fpm_conf.sh @@ -34,7 +34,7 @@ PHP_CNF_CONT="/etc/php-fpm-custom.d" CONTAINER="nginx:stable" -echo "php_admin_value[post_max_size] = 17M" > "${PHP_CNF_HOST}/post.conf" +printf "[www]\nphp_admin_value[memory_limit] = 17M\n" > "${PHP_CNF_HOST}/post.conf" echo " "${DOC_ROOT_HOST}/index.php" # Fix mount permissions @@ -120,31 +120,12 @@ if ! run "curl -q -4 http://127.0.0.1:${WWW_PORT}/index.php >/dev/null 2>&1"; th exit 1 fi -# Check modified php-fpm.conf -if ! docker_exec "${did}" "php -r \"echo ini_get('post_max_size');\" | grep '17M'"; then - # Info - docker_exec "${did}" "php -r \"echo ini_get('post_max_size');\"" - - # Show logs - docker_logs "${ndid}" || true - docker_logs "${did}" || true - - # Shutdown - docker_stop "${ndid}" || true - docker_stop "${did}" || true - rm -rf "${DOC_ROOT_HOST}" - rm -rf "${CONFIG_HOST}" - rm -rf "${PHP_CNF_HOST}" - echo "Failed" - exit 1 -fi # Check modified php-fpm.conf -if ! run "curl -q -4 http://127.0.0.1:${WWW_PORT}/index.php 2>/dev/null | grep post_max_size | grep '17M'"; then +if ! run "curl -q -4 http://127.0.0.1:${WWW_PORT}/index.php 2>/dev/null | grep memory_limit | grep '17M'"; then # Info run "netstat -tuln" - run "curl -4 http://127.0.0.1:${WWW_PORT}/index.php" || true - run "curl -6 http://127.0.0.1:${WWW_PORT}/index.php" || true + run "curl -4 http://127.0.0.1:${WWW_PORT}/index.php | grep memory_limit" || true run "docker ps --no-trunc" docker_exec "${ndid}" "nginx -t" From 504d98b9c9cf8fad6b47b30c4d97647acb7b63ec Mon Sep 17 00:00:00 2001 From: cytopia Date: Sat, 7 Apr 2018 17:18:13 +0200 Subject: [PATCH 3/4] Properly handle return code after stripping libs --- Dockerfiles/mods/Dockerfile-5.4 | 2 +- Dockerfiles/mods/Dockerfile-5.5 | 2 +- Dockerfiles/mods/Dockerfile-5.6 | 2 +- Dockerfiles/mods/Dockerfile-7.0 | 3 ++- Dockerfiles/mods/Dockerfile-7.1 | 2 +- Dockerfiles/mods/Dockerfile-7.2 | 2 +- build/ansible/DOCKERFILES/Dockerfile-mods.j2 | 2 +- build/ansible/group_vars/all.yml | 3 +++ 8 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Dockerfiles/mods/Dockerfile-5.4 b/Dockerfiles/mods/Dockerfile-5.4 index b5ab496a..34f259dd 100644 --- a/Dockerfiles/mods/Dockerfile-5.4 +++ b/Dockerfiles/mods/Dockerfile-5.4 @@ -234,7 +234,7 @@ RUN set -x \ ${RUN_DEPS} \ && rm -rf /var/lib/apt/lists/* \ && update-ca-certificates \ - && find /usr/local -type f -perm /u+x -exec strip --strip-all '{}' + || true + && sh -c "find /usr/local -type f -perm /u+x -exec strip --strip-all '{}' + || true" ### diff --git a/Dockerfiles/mods/Dockerfile-5.5 b/Dockerfiles/mods/Dockerfile-5.5 index 613f1af8..ca887618 100644 --- a/Dockerfiles/mods/Dockerfile-5.5 +++ b/Dockerfiles/mods/Dockerfile-5.5 @@ -236,7 +236,7 @@ RUN set -x \ ${RUN_DEPS} \ && rm -rf /var/lib/apt/lists/* \ && update-ca-certificates \ - && find /usr/local -type f -perm /u+x -exec strip --strip-all '{}' + || true + && sh -c "find /usr/local -type f -perm /u+x -exec strip --strip-all '{}' + || true" ### diff --git a/Dockerfiles/mods/Dockerfile-5.6 b/Dockerfiles/mods/Dockerfile-5.6 index 20a06dbf..9a95f920 100644 --- a/Dockerfiles/mods/Dockerfile-5.6 +++ b/Dockerfiles/mods/Dockerfile-5.6 @@ -238,7 +238,7 @@ RUN set -x \ ${RUN_DEPS} \ && rm -rf /var/lib/apt/lists/* \ && update-ca-certificates \ - && find /usr/local -type f -perm /u+x -exec strip --strip-all '{}' + || true + && sh -c "find /usr/local -type f -perm /u+x -exec strip --strip-all '{}' + || true" ### diff --git a/Dockerfiles/mods/Dockerfile-7.0 b/Dockerfiles/mods/Dockerfile-7.0 index fa63b3a4..73e99f89 100644 --- a/Dockerfiles/mods/Dockerfile-7.0 +++ b/Dockerfiles/mods/Dockerfile-7.0 @@ -40,6 +40,7 @@ ENV BUILD_DEPS \ libib-util \ firebird-dev \ libicu-dev \ + bison \ libldap2-dev \ libsasl2-dev \ libmcrypt-dev \ @@ -244,7 +245,7 @@ RUN set -x \ ${RUN_DEPS} \ && rm -rf /var/lib/apt/lists/* \ && update-ca-certificates \ - && find /usr/local -type f -perm /u+x -exec strip --strip-all '{}' + || true + && sh -c "find /usr/local -type f -perm /u+x -exec strip --strip-all '{}' + || true" ### diff --git a/Dockerfiles/mods/Dockerfile-7.1 b/Dockerfiles/mods/Dockerfile-7.1 index 083f5d53..3a8f60c4 100644 --- a/Dockerfiles/mods/Dockerfile-7.1 +++ b/Dockerfiles/mods/Dockerfile-7.1 @@ -244,7 +244,7 @@ RUN set -x \ ${RUN_DEPS} \ && rm -rf /var/lib/apt/lists/* \ && update-ca-certificates \ - && find /usr/local -type f -perm /u+x -exec strip --strip-all '{}' + || true + && sh -c "find /usr/local -type f -perm /u+x -exec strip --strip-all '{}' + || true" ### diff --git a/Dockerfiles/mods/Dockerfile-7.2 b/Dockerfiles/mods/Dockerfile-7.2 index 4be81324..b901b042 100644 --- a/Dockerfiles/mods/Dockerfile-7.2 +++ b/Dockerfiles/mods/Dockerfile-7.2 @@ -246,7 +246,7 @@ RUN set -x \ ${RUN_DEPS} \ && rm -rf /var/lib/apt/lists/* \ && update-ca-certificates \ - && find /usr/local -type f -perm /u+x -exec strip --strip-all '{}' + || true + && sh -c "find /usr/local -type f -perm /u+x -exec strip --strip-all '{}' + || true" ### diff --git a/build/ansible/DOCKERFILES/Dockerfile-mods.j2 b/build/ansible/DOCKERFILES/Dockerfile-mods.j2 index 46383db2..c770d7a4 100644 --- a/build/ansible/DOCKERFILES/Dockerfile-mods.j2 +++ b/build/ansible/DOCKERFILES/Dockerfile-mods.j2 @@ -161,7 +161,7 @@ RUN set -x \ ${RUN_DEPS} \ && rm -rf /var/lib/apt/lists/* \ && update-ca-certificates \ - && find /usr/local -type f -perm /u+x -exec strip --strip-all '{}' + || true + && sh -c "find /usr/local -type f -perm /u+x -exec strip --strip-all '{}' + || true" {% if debug %} diff --git a/build/ansible/group_vars/all.yml b/build/ansible/group_vars/all.yml index 253eca16..040f8ee5 100644 --- a/build/ansible/group_vars/all.yml +++ b/build/ansible/group_vars/all.yml @@ -601,6 +601,9 @@ extensions_available: build_dep: [libicu-dev] run_dep: [libicu52] json: + 7.0: + type: builtin + build_dep: [bison] all: type: builtin ldap: From 116edfb3d2f36d1d2d37440fd0b1f1bee7a1374e Mon Sep 17 00:00:00 2001 From: cytopia Date: Sat, 7 Apr 2018 18:17:29 +0200 Subject: [PATCH 4/4] Fix various broken PHP 7.0 extensions --- Dockerfiles/mods/Dockerfile-7.0 | 7 ------- build/ansible/group_vars/all.yml | 4 ++++ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Dockerfiles/mods/Dockerfile-7.0 b/Dockerfiles/mods/Dockerfile-7.0 index 73e99f89..196b3506 100644 --- a/Dockerfiles/mods/Dockerfile-7.0 +++ b/Dockerfiles/mods/Dockerfile-7.0 @@ -56,7 +56,6 @@ ENV BUILD_DEPS \ libpq-dev \ libsqlite3-dev \ libpq-dev \ - libssl-dev \ libpspell-dev \ libedit-dev \ libreadline-dev \ @@ -175,7 +174,6 @@ RUN set -x \ && /usr/local/bin/docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) mysqli \ && /usr/local/bin/docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) opcache \ && /usr/local/bin/docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) pcntl \ - && /usr/local/bin/docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) pdo \ && ln -s /usr/lib/x86_64-linux-gnu/libsybdb.* /usr/lib/ \ && /usr/local/bin/docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) pdo_dblib \ && /usr/local/bin/docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) pdo_firebird \ @@ -190,7 +188,6 @@ RUN set -x \ && cd build && ./install \ && docker-php-ext-enable phalcon \ && cd / && rm -rf /tmp/phalcon \ - && /usr/local/bin/docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) phar \ && /usr/local/bin/docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) posix \ && /usr/local/bin/docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) pspell \ && /usr/local/bin/docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) readline \ @@ -326,8 +323,6 @@ RUN set -x \ && php-fpm -m | grep -oiE '^Zend Opcache$' \ && php -m | grep -oiE '^pcntl$' \ && php-fpm -m | grep -oiE '^pcntl$' \ - && php -m | grep -oiE '^pdo$' \ - && php-fpm -m | grep -oiE '^pdo$' \ && php -m | grep -oiE '^pdo_dblib$' \ && php-fpm -m | grep -oiE '^pdo_dblib$' \ && php -m | grep -oiE '^pdo_firebird$' \ @@ -342,8 +337,6 @@ RUN set -x \ && php-fpm -m | grep -oiE '^pgsql$' \ && php -m | grep -oiE '^phalcon$' \ && php-fpm -m | grep -oiE '^phalcon$' \ - && php -m | grep -oiE '^phar$' \ - && php-fpm -m | grep -oiE '^phar$' \ && php -m | grep -oiE '^posix$' \ && php-fpm -m | grep -oiE '^posix$' \ && php -m | grep -oiE '^pspell$' \ diff --git a/build/ansible/group_vars/all.yml b/build/ansible/group_vars/all.yml index 040f8ee5..33abf969 100644 --- a/build/ansible/group_vars/all.yml +++ b/build/ansible/group_vars/all.yml @@ -707,6 +707,8 @@ extensions_available: pcre: disabled: "{{ php_all_versions }}" # Available by default pdo: + # https://github.com/docker-library/php/issues/618 + disabled: [7.0] # TODO: Currently disabled due to bug in built all: type: builtin pdo_dblib: @@ -755,6 +757,8 @@ extensions_available: git_ref: $(git for-each-ref --format='%(*creatordate:raw)%(creatordate:raw) %(refname)' refs/tags | sort -n | tail -1 | sed 's/^.*tags\///g') command: cd build && ./install phar: + # https://github.com/docker-library/php/issues/618 + disabled: [7.0] # TODO: Currently disabled due to bug in built all: type: builtin build_dep: [libssl-dev]