Skip to content

Commit

Permalink
Merge pull request #7 from devilbox/release-0.6
Browse files Browse the repository at this point in the history
Add option to customize PHP-FPM configuration
  • Loading branch information
cytopia authored Apr 7, 2018
2 parents 199efdc + 116edfb commit 3856e8d
Show file tree
Hide file tree
Showing 29 changed files with 273 additions and 33 deletions.
13 changes: 0 additions & 13 deletions Dockerfiles/base/data/php-fpm.d/pool.conf
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion Dockerfiles/mods/Dockerfile-5.4
Original file line number Diff line number Diff line change
Expand Up @@ -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"


###
Expand Down
2 changes: 1 addition & 1 deletion Dockerfiles/mods/Dockerfile-5.5
Original file line number Diff line number Diff line change
Expand Up @@ -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"


###
Expand Down
2 changes: 1 addition & 1 deletion Dockerfiles/mods/Dockerfile-5.6
Original file line number Diff line number Diff line change
Expand Up @@ -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"


###
Expand Down
10 changes: 2 additions & 8 deletions Dockerfiles/mods/Dockerfile-7.0
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ ENV BUILD_DEPS \
libib-util \
firebird-dev \
libicu-dev \
bison \
libldap2-dev \
libsasl2-dev \
libmcrypt-dev \
Expand All @@ -55,7 +56,6 @@ ENV BUILD_DEPS \
libpq-dev \
libsqlite3-dev \
libpq-dev \
libssl-dev \
libpspell-dev \
libedit-dev \
libreadline-dev \
Expand Down Expand Up @@ -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 \
Expand All @@ -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 \
Expand Down Expand Up @@ -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"


###
Expand Down Expand Up @@ -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$' \
Expand All @@ -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$' \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfiles/mods/Dockerfile-7.1
Original file line number Diff line number Diff line change
Expand Up @@ -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"


###
Expand Down
2 changes: 1 addition & 1 deletion Dockerfiles/mods/Dockerfile-7.2
Original file line number Diff line number Diff line change
Expand Up @@ -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"


###
Expand Down
1 change: 1 addition & 0 deletions Dockerfiles/prod/Dockerfile-5.4
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Dockerfiles/prod/Dockerfile-5.5
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Dockerfiles/prod/Dockerfile-5.6
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Dockerfiles/prod/Dockerfile-7.0
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Dockerfiles/prod/Dockerfile-7.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Dockerfiles/prod/Dockerfile-7.2
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions Dockerfiles/prod/data/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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"

Expand Down Expand Up @@ -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
###
Expand Down
1 change: 1 addition & 0 deletions Dockerfiles/work/Dockerfile-5.4
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Dockerfiles/work/Dockerfile-5.5
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Dockerfiles/work/Dockerfile-5.6
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Dockerfiles/work/Dockerfile-7.0
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Dockerfiles/work/Dockerfile-7.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Dockerfiles/work/Dockerfile-7.2
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions Dockerfiles/work/data/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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"

Expand Down Expand Up @@ -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
###
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion build/ansible/DOCKERFILES/Dockerfile-mods.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down
1 change: 1 addition & 0 deletions build/ansible/DOCKERFILES/Dockerfile-prod.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions build/ansible/DOCKERFILES/Dockerfile-work.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 3856e8d

Please sign in to comment.