Compare commits

...

5 Commits
0.5 ... 0.6

Author SHA1 Message Date
cytopia
3856e8d61a Merge pull request #7 from devilbox/release-0.6
Add option to customize PHP-FPM configuration
2018-04-07 19:55:06 +02:00
cytopia
116edfb3d2 Fix various broken PHP 7.0 extensions 2018-04-07 18:17:29 +02:00
cytopia
504d98b9c9 Properly handle return code after stripping libs 2018-04-07 17:18:13 +02:00
cytopia
2641449b43 Ajust php-fpm config tests 2018-04-07 15:39:45 +02:00
cytopia
69994acba3 Add option to customize PHP-FPM configuration 2018-04-07 13:49:38 +02:00
29 changed files with 273 additions and 33 deletions

View File

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

View File

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

View File

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

View File

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

View File

@@ -40,6 +40,7 @@ ENV BUILD_DEPS \
libib-util \
firebird-dev \
libicu-dev \
bison \
libldap2-dev \
libsasl2-dev \
libmcrypt-dev \
@@ -55,7 +56,6 @@ ENV BUILD_DEPS \
libpq-dev \
libsqlite3-dev \
libpq-dev \
libssl-dev \
libpspell-dev \
libedit-dev \
libreadline-dev \
@@ -174,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 \
@@ -189,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 \
@@ -244,7 +242,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"
###
@@ -325,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$' \
@@ -341,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$' \

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -97,16 +97,20 @@ Have a look at the following table to see all offered volumes for each Docker im
<thead>
<tr>
<th>Image</th>
<th width="200">Volumes</th>
<th width="220">Volumes</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td rowspan="4"><strong>prod</strong><br/><br/><strong>work</strong></td>
<td rowspan="5"><strong>prod</strong><br/><br/><strong>work</strong></td>
<td><code>/etc/php-custom.d</code></td>
<td>Mount this directory into your host computer and add custom <code>\*.ini</code> files in order to alter php behaviour.</td>
</tr>
<tr>
<td><code>/etc/php-fpm-custom.d</code></td>
<td>Mount this directory into your host computer and add custom PHP-FOM <code>\*.conf</code> files in order to alter PHP-FPM behaviour.</td>
</tr>
<tr>
<td><code>/etc/php-modules.d</code></td>
<td>Mount this directory into your host computer and add custo <code>\*.so</code> files in order to add your php modules.<br/><br/><strong>Note:</strong>Your should then also provide a custom <code>\*.ini</code> file in order to actually load your custom provided module.</td>

View File

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

View File

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

View File

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

View File

@@ -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:
@@ -704,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:
@@ -752,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]

View File

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

View File

@@ -0,0 +1,162 @@
#!/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"
printf "[www]\nphp_admin_value[memory_limit] = 17M\n" > "${PHP_CNF_HOST}/post.conf"
echo "<?php phpinfo();" > "${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 ! 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 | grep memory_limit" || 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}"