Skip to content

Commit

Permalink
Merge pull request #26 from devilbox/release-0.18
Browse files Browse the repository at this point in the history
Add Module: IonCube
  • Loading branch information
cytopia authored May 21, 2018
2 parents 8ed060f + 42b811f commit a1092be
Show file tree
Hide file tree
Showing 14 changed files with 169 additions and 6 deletions.
10 changes: 10 additions & 0 deletions Dockerfiles/mods/Dockerfile-5.3
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ RUN set -x \
${BUILD_DEPS} \
\
\
&& EXTENSION_DIR="$( php -i | grep ^extension_dir | awk -F '=>' '{print $2}' | xargs )" \
&& if [ ! -d "${EXTENSION_DIR}" ]; then mkdir -p "${EXTENSION_DIR}"; fi \
&& curl https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz -L -o ioncube.tar.gz \
&& tar xvfz ioncube.tar.gz \
&& cd ioncube \
&& cp "ioncube_loader_lin_5.3.so" "${EXTENSION_DIR}/ioncube.so" \
&& cd ../ \
&& rm -rf ioncube \
&& rm -rf ioncube.tar.gz \
\
&& echo "/usr" | pecl install amqp \
&& docker-php-ext-enable amqp \
&& pecl install apcu-4.0.11 \
Expand Down
10 changes: 10 additions & 0 deletions Dockerfiles/mods/Dockerfile-5.4
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ RUN set -x \
${BUILD_DEPS} \
\
\
&& EXTENSION_DIR="$( php -i | grep ^extension_dir | awk -F '=>' '{print $2}' | xargs )" \
&& if [ ! -d "${EXTENSION_DIR}" ]; then mkdir -p "${EXTENSION_DIR}"; fi \
&& curl https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz -L -o ioncube.tar.gz \
&& tar xvfz ioncube.tar.gz \
&& cd ioncube \
&& cp "ioncube_loader_lin_5.4.so" "${EXTENSION_DIR}/ioncube.so" \
&& cd ../ \
&& rm -rf ioncube \
&& rm -rf ioncube.tar.gz \
\
&& echo "/usr" | pecl install amqp \
&& docker-php-ext-enable amqp \
&& pecl install apcu-4.0.11 \
Expand Down
10 changes: 10 additions & 0 deletions Dockerfiles/mods/Dockerfile-5.5
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,16 @@ RUN set -x \
${BUILD_DEPS} \
\
\
&& EXTENSION_DIR="$( php -i | grep ^extension_dir | awk -F '=>' '{print $2}' | xargs )" \
&& if [ ! -d "${EXTENSION_DIR}" ]; then mkdir -p "${EXTENSION_DIR}"; fi \
&& curl https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz -L -o ioncube.tar.gz \
&& tar xvfz ioncube.tar.gz \
&& cd ioncube \
&& cp "ioncube_loader_lin_5.5.so" "${EXTENSION_DIR}/ioncube.so" \
&& cd ../ \
&& rm -rf ioncube \
&& rm -rf ioncube.tar.gz \
\
&& echo "/usr" | pecl install amqp \
&& docker-php-ext-enable amqp \
&& pecl install apcu-4.0.11 \
Expand Down
10 changes: 10 additions & 0 deletions Dockerfiles/mods/Dockerfile-5.6
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ RUN set -x \
${BUILD_DEPS} \
\
\
&& EXTENSION_DIR="$( php -i | grep ^extension_dir | awk -F '=>' '{print $2}' | xargs )" \
&& if [ ! -d "${EXTENSION_DIR}" ]; then mkdir -p "${EXTENSION_DIR}"; fi \
&& curl https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz -L -o ioncube.tar.gz \
&& tar xvfz ioncube.tar.gz \
&& cd ioncube \
&& cp "ioncube_loader_lin_5.6.so" "${EXTENSION_DIR}/ioncube.so" \
&& cd ../ \
&& rm -rf ioncube \
&& rm -rf ioncube.tar.gz \
\
&& echo "/usr" | pecl install amqp \
&& docker-php-ext-enable amqp \
&& pecl install apcu-4.0.11 \
Expand Down
10 changes: 10 additions & 0 deletions Dockerfiles/mods/Dockerfile-7.0
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,16 @@ RUN set -x \
${BUILD_DEPS} \
\
\
&& EXTENSION_DIR="$( php -i | grep ^extension_dir | awk -F '=>' '{print $2}' | xargs )" \
&& if [ ! -d "${EXTENSION_DIR}" ]; then mkdir -p "${EXTENSION_DIR}"; fi \
&& curl https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz -L -o ioncube.tar.gz \
&& tar xvfz ioncube.tar.gz \
&& cd ioncube \
&& cp "ioncube_loader_lin_7.0.so" "${EXTENSION_DIR}/ioncube.so" \
&& cd ../ \
&& rm -rf ioncube \
&& rm -rf ioncube.tar.gz \
\
&& echo "/usr" | pecl install amqp \
&& docker-php-ext-enable amqp \
&& pecl install apcu \
Expand Down
10 changes: 10 additions & 0 deletions Dockerfiles/mods/Dockerfile-7.1
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,16 @@ RUN set -x \
${BUILD_DEPS} \
\
\
&& EXTENSION_DIR="$( php -i | grep ^extension_dir | awk -F '=>' '{print $2}' | xargs )" \
&& if [ ! -d "${EXTENSION_DIR}" ]; then mkdir -p "${EXTENSION_DIR}"; fi \
&& curl https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz -L -o ioncube.tar.gz \
&& tar xvfz ioncube.tar.gz \
&& cd ioncube \
&& cp "ioncube_loader_lin_7.1.so" "${EXTENSION_DIR}/ioncube.so" \
&& cd ../ \
&& rm -rf ioncube \
&& rm -rf ioncube.tar.gz \
\
&& echo "/usr" | pecl install amqp \
&& docker-php-ext-enable amqp \
&& pecl install apcu \
Expand Down
10 changes: 10 additions & 0 deletions Dockerfiles/mods/Dockerfile-7.2
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,16 @@ RUN set -x \
${BUILD_DEPS} \
\
\
&& EXTENSION_DIR="$( php -i | grep ^extension_dir | awk -F '=>' '{print $2}' | xargs )" \
&& if [ ! -d "${EXTENSION_DIR}" ]; then mkdir -p "${EXTENSION_DIR}"; fi \
&& curl https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz -L -o ioncube.tar.gz \
&& tar xvfz ioncube.tar.gz \
&& cd ioncube \
&& cp "ioncube_loader_lin_7.2.so" "${EXTENSION_DIR}/ioncube.so" \
&& cd ../ \
&& rm -rf ioncube \
&& rm -rf ioncube.tar.gz \
\
&& pecl install amqp \
&& docker-php-ext-enable amqp \
&& pecl install apcu \
Expand Down
51 changes: 51 additions & 0 deletions Dockerfiles/prod/data/docker-entrypoint.d/38-enable-modules.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env bash

set -e
set -u
set -o pipefail


############################################################
# Functions
############################################################

###
### Enable PHP Modules
###
enable_modules() {
local mod_varname="${1}"
local debug="${2}"
local cfg_path="/usr/local/etc/php/conf.d"
local mod_path=
mod_path="$( php -i | grep ^extension_dir | awk -F '=>' '{print $2}' | xargs )"


if ! env_set "${mod_varname}"; then
log "info" "\$${mod_varname} not set. Not enabling any PHP modules." "${debug}"
else
mods="$( env_get "${mod_varname}" )"

if [ -z "${mods}" ]; then
log "info" "\$${mod_varname} set, but empty. Not enabling any PHP modules." "${debug}"
else
log "info" "Enabling the following PHP modules: ${mods}" "${debug}"
fi

while read -r mod; do
mod="$( echo "${mod}" | xargs )" # trim

# Does the module exist?
if [ -f "${mod_path}/${mod}.so" ]; then
# Exceptions to load speficially
if [ "${mod}" = "ioncube" ]; then
run "eche 'zend_extension=${mod_path}/ioncube.so' > '${cfg_path}/docker-ext-php-ext-ioncube.ini'" "${debug}"
# Generic Load
else
run "docker-php-ext-enable ${mod} || true" "${debug}"
fi
else
log "warn" "Enabling PHP Module: '${mod}' does not exist" "${debug}"
fi
done <<< "$( echo "${mods}" | tr ',' '\n' )"
fi
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,24 @@ set -o pipefail
disable_modules() {
local mod_varname="${1}"
local debug="${2}"
local mod_path="/usr/local/etc/php/conf.d"
local cfg_path="/usr/local/etc/php/conf.d"

if ! env_set "${mod_varname}"; then
log "info" "\$${mod_varname} not set. Not disabling any PHP modules." "${debug}"
else
mods="$( env_get "${mod_varname}" )"

if [ -z "${mods}" ]; then
log "warn" "\$${mod_varname} set, but empty. Not disabling any PHP modules." "${debug}"
log "info" "\$${mod_varname} set, but empty. Not disabling any PHP modules." "${debug}"
else
log "info" "Disabling the following PHP modules: ${mods}" "${debug}"
fi

while read -r mod; do
#for mod in ${mods//,/ }; do
mod="$( echo "${mod}" | xargs )" # trim

# Find all config files that enable that module
files="$( grep -Er "^(zend_)?extension.*(=|/)${mod}\.so" "${mod_path}" || true )"
files="$( grep -Er "^(zend_)?extension.*(=|/)${mod}\.so" "${cfg_path}" || true )"

if [ -n "${files}" ]; then
while read -r f; do
Expand All @@ -44,6 +43,5 @@ disable_modules() {
done <<< "${files}"
fi
done <<< "$( echo "${mods}" | tr ',' '\n' )"
#done
fi
}
6 changes: 6 additions & 0 deletions Dockerfiles/prod/data/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ copy_ini_files "${PHP_CUST_INI_DIR}" "${PHP_INI_DIR}" "${DEBUG_LEVEL}"
copy_fpm_files "${PHP_CUST_FPM_DIR}" "${PHP_FPM_DIR}" "${DEBUG_LEVEL}"


###
### Enable PHP Modules
###
enable_modules "ENABLE_MODULES" "${DEBUG_LEVEL}"


###
### Disable PHP Modules
###
Expand Down
6 changes: 6 additions & 0 deletions Dockerfiles/work/data/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ copy_ini_files "${PHP_CUST_INI_DIR}" "${PHP_INI_DIR}" "${DEBUG_LEVEL}"
copy_fpm_files "${PHP_CUST_FPM_DIR}" "${PHP_FPM_DIR}" "${DEBUG_LEVEL}"


###
### Enable PHP Modules
###
enable_modules "ENABLE_MODULES" "${DEBUG_LEVEL}"


###
### Disable PHP Modules
###
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ Have a look at the following table to see all supported environment variables fo
<td colspan="5"></td>
</tr>
<tr>
<td rowspan="5"><strong>prod</strong><br/><br/><strong>work</strong></td>
<td rowspan="6"><strong>prod</strong><br/><br/><strong>work</strong></td>
<td><code>TIMEZONE</code></td>
<td>string</td>
<td><code>UTC</code></td>
Expand All @@ -622,6 +622,12 @@ Have a look at the following table to see all supported environment variables fo
<td><code>1</code></td>
<td>By default all Docker images are configured to output their PHP-FPM access and error logs to stdout and stderr. Those which support it can change the behaviour to log into files inside the container. Their respective directories are available as volumes that can be mounted to the host computer. This feature might help developer who are more comfortable with tailing or searching through actual files instead of using docker logs.<br/><br/>Set this variable to <code>0</code> in order to enable logging to files. Log files are avilable under <code>/var/log/php/</code> which is also a docker volume that can be mounted locally.</td>
</tr>
<tr>
<td><code>ENABLE_MODULES</code></td>
<td>string</td>
<td><code>''</code></td>
<td>Comma separated list of PHP modules to enable, which are not enabled by default.<br/><strong>Example:</strong><br/><code>ENABLE_MODULES=ioncube</code></td>
</tr>
<tr>
<td><code>DISABLE_MODULES</code></td>
<td>string</td>
Expand Down
8 changes: 8 additions & 0 deletions build/ansible/DOCKERFILES/Dockerfile-mods.j2
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ RUN set -x \
{% endif %}
&& docker-php-ext-enable {{ ext }} \
&& cd / && rm -rf /tmp/{{ ext }} \
{# ---- 4.) CUSTOM ---- #}
{% elif extensions_available[ext][php_version]['type'] == 'custom' %}
&& {{ extensions_available[ext][php_version]['command'] }} \
{% endif %}
{# ---------- Installation (generic) ---------- #}
{% elif 'all' in extensions_available[ext] and 'type' in extensions_available[ext]['all'] %}
Expand Down Expand Up @@ -147,6 +150,9 @@ RUN set -x \
{% endif %}
&& docker-php-ext-enable {{ ext }} \
&& cd / && rm -rf /tmp/{{ ext }} \
{# ---- 4.) CUSTOM ---- #}
{% elif extensions_available[ext]['all']['type'] == 'custom' %}
&& {{ extensions_available[ext]['all']['command'] }} \
{% endif %}
{% endif %}
{% endif %}
Expand Down Expand Up @@ -181,6 +187,8 @@ RUN set -x \
{% if ext == 'opcache' %}
&& php -m | grep -oiE '^Zend Opcache$' \
&& php-fpm -m | grep -oiE '^Zend Opcache$' \
{% elif ext == 'ioncube' %}
{# Not enabled #}
{% else %}
&& php -m | grep -oiE '^{{ ext }}$' \
&& php-fpm -m | grep -oiE '^{{ ext }}$' \
Expand Down
18 changes: 18 additions & 0 deletions build/ansible/group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,8 @@ software_available:
### Extensions to actually enable
###
extensions_enabled:
# ioncube must be loaded first
- ioncube
- amqp
- apcu
- bcmath
Expand Down Expand Up @@ -505,6 +507,8 @@ extensions_enabled:
# git_ref: [optional] Tag, branch, commit to checkout
# configure: [optional] Add './configure' arguments
# command: [optional] Overwrite default command (phpize && ./configure && make && make install)
# type: custom
# command: [required] Custom command to install and enable a module
extensions_available:
amqp:
disabled: [7.3]
Expand Down Expand Up @@ -663,6 +667,20 @@ extensions_available:
type: builtin
build_dep: [libicu-dev]
run_dep: [libicu52]
ioncube:
disabled: [7.3]
all:
type: custom
command: |
EXTENSION_DIR="$( php -i | grep ^extension_dir | awk -F '=>' '{print $2}' | xargs )" \
&& if [ ! -d "${EXTENSION_DIR}" ]; then mkdir -p "${EXTENSION_DIR}"; fi \
&& curl https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz -L -o ioncube.tar.gz \
&& tar xvfz ioncube.tar.gz \
&& cd ioncube \
&& cp "ioncube_loader_lin_{{ php_version }}.so" "${EXTENSION_DIR}/ioncube.so" \
&& cd ../ \
&& rm -rf ioncube \
&& rm -rf ioncube.tar.gz \
json:
7.0:
type: builtin
Expand Down

0 comments on commit a1092be

Please sign in to comment.