Skip to content

Commit a1092be

Browse files
authored
Merge pull request #26 from devilbox/release-0.18
Add Module: IonCube
2 parents 8ed060f + 42b811f commit a1092be

File tree

14 files changed

+169
-6
lines changed

14 files changed

+169
-6
lines changed

Dockerfiles/mods/Dockerfile-5.3

+10
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,16 @@ RUN set -x \
116116
${BUILD_DEPS} \
117117
\
118118
\
119+
&& EXTENSION_DIR="$( php -i | grep ^extension_dir | awk -F '=>' '{print $2}' | xargs )" \
120+
&& if [ ! -d "${EXTENSION_DIR}" ]; then mkdir -p "${EXTENSION_DIR}"; fi \
121+
&& curl https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz -L -o ioncube.tar.gz \
122+
&& tar xvfz ioncube.tar.gz \
123+
&& cd ioncube \
124+
&& cp "ioncube_loader_lin_5.3.so" "${EXTENSION_DIR}/ioncube.so" \
125+
&& cd ../ \
126+
&& rm -rf ioncube \
127+
&& rm -rf ioncube.tar.gz \
128+
\
119129
&& echo "/usr" | pecl install amqp \
120130
&& docker-php-ext-enable amqp \
121131
&& pecl install apcu-4.0.11 \

Dockerfiles/mods/Dockerfile-5.4

+10
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,16 @@ RUN set -x \
116116
${BUILD_DEPS} \
117117
\
118118
\
119+
&& EXTENSION_DIR="$( php -i | grep ^extension_dir | awk -F '=>' '{print $2}' | xargs )" \
120+
&& if [ ! -d "${EXTENSION_DIR}" ]; then mkdir -p "${EXTENSION_DIR}"; fi \
121+
&& curl https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz -L -o ioncube.tar.gz \
122+
&& tar xvfz ioncube.tar.gz \
123+
&& cd ioncube \
124+
&& cp "ioncube_loader_lin_5.4.so" "${EXTENSION_DIR}/ioncube.so" \
125+
&& cd ../ \
126+
&& rm -rf ioncube \
127+
&& rm -rf ioncube.tar.gz \
128+
\
119129
&& echo "/usr" | pecl install amqp \
120130
&& docker-php-ext-enable amqp \
121131
&& pecl install apcu-4.0.11 \

Dockerfiles/mods/Dockerfile-5.5

+10
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,16 @@ RUN set -x \
118118
${BUILD_DEPS} \
119119
\
120120
\
121+
&& EXTENSION_DIR="$( php -i | grep ^extension_dir | awk -F '=>' '{print $2}' | xargs )" \
122+
&& if [ ! -d "${EXTENSION_DIR}" ]; then mkdir -p "${EXTENSION_DIR}"; fi \
123+
&& curl https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz -L -o ioncube.tar.gz \
124+
&& tar xvfz ioncube.tar.gz \
125+
&& cd ioncube \
126+
&& cp "ioncube_loader_lin_5.5.so" "${EXTENSION_DIR}/ioncube.so" \
127+
&& cd ../ \
128+
&& rm -rf ioncube \
129+
&& rm -rf ioncube.tar.gz \
130+
\
121131
&& echo "/usr" | pecl install amqp \
122132
&& docker-php-ext-enable amqp \
123133
&& pecl install apcu-4.0.11 \

Dockerfiles/mods/Dockerfile-5.6

+10
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,16 @@ RUN set -x \
120120
${BUILD_DEPS} \
121121
\
122122
\
123+
&& EXTENSION_DIR="$( php -i | grep ^extension_dir | awk -F '=>' '{print $2}' | xargs )" \
124+
&& if [ ! -d "${EXTENSION_DIR}" ]; then mkdir -p "${EXTENSION_DIR}"; fi \
125+
&& curl https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz -L -o ioncube.tar.gz \
126+
&& tar xvfz ioncube.tar.gz \
127+
&& cd ioncube \
128+
&& cp "ioncube_loader_lin_5.6.so" "${EXTENSION_DIR}/ioncube.so" \
129+
&& cd ../ \
130+
&& rm -rf ioncube \
131+
&& rm -rf ioncube.tar.gz \
132+
\
123133
&& echo "/usr" | pecl install amqp \
124134
&& docker-php-ext-enable amqp \
125135
&& pecl install apcu-4.0.11 \

Dockerfiles/mods/Dockerfile-7.0

+10
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,16 @@ RUN set -x \
118118
${BUILD_DEPS} \
119119
\
120120
\
121+
&& EXTENSION_DIR="$( php -i | grep ^extension_dir | awk -F '=>' '{print $2}' | xargs )" \
122+
&& if [ ! -d "${EXTENSION_DIR}" ]; then mkdir -p "${EXTENSION_DIR}"; fi \
123+
&& curl https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz -L -o ioncube.tar.gz \
124+
&& tar xvfz ioncube.tar.gz \
125+
&& cd ioncube \
126+
&& cp "ioncube_loader_lin_7.0.so" "${EXTENSION_DIR}/ioncube.so" \
127+
&& cd ../ \
128+
&& rm -rf ioncube \
129+
&& rm -rf ioncube.tar.gz \
130+
\
121131
&& echo "/usr" | pecl install amqp \
122132
&& docker-php-ext-enable amqp \
123133
&& pecl install apcu \

Dockerfiles/mods/Dockerfile-7.1

+10
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,16 @@ RUN set -x \
118118
${BUILD_DEPS} \
119119
\
120120
\
121+
&& EXTENSION_DIR="$( php -i | grep ^extension_dir | awk -F '=>' '{print $2}' | xargs )" \
122+
&& if [ ! -d "${EXTENSION_DIR}" ]; then mkdir -p "${EXTENSION_DIR}"; fi \
123+
&& curl https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz -L -o ioncube.tar.gz \
124+
&& tar xvfz ioncube.tar.gz \
125+
&& cd ioncube \
126+
&& cp "ioncube_loader_lin_7.1.so" "${EXTENSION_DIR}/ioncube.so" \
127+
&& cd ../ \
128+
&& rm -rf ioncube \
129+
&& rm -rf ioncube.tar.gz \
130+
\
121131
&& echo "/usr" | pecl install amqp \
122132
&& docker-php-ext-enable amqp \
123133
&& pecl install apcu \

Dockerfiles/mods/Dockerfile-7.2

+10
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,16 @@ RUN set -x \
119119
${BUILD_DEPS} \
120120
\
121121
\
122+
&& EXTENSION_DIR="$( php -i | grep ^extension_dir | awk -F '=>' '{print $2}' | xargs )" \
123+
&& if [ ! -d "${EXTENSION_DIR}" ]; then mkdir -p "${EXTENSION_DIR}"; fi \
124+
&& curl https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz -L -o ioncube.tar.gz \
125+
&& tar xvfz ioncube.tar.gz \
126+
&& cd ioncube \
127+
&& cp "ioncube_loader_lin_7.2.so" "${EXTENSION_DIR}/ioncube.so" \
128+
&& cd ../ \
129+
&& rm -rf ioncube \
130+
&& rm -rf ioncube.tar.gz \
131+
\
122132
&& pecl install amqp \
123133
&& docker-php-ext-enable amqp \
124134
&& pecl install apcu \
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
set -u
5+
set -o pipefail
6+
7+
8+
############################################################
9+
# Functions
10+
############################################################
11+
12+
###
13+
### Enable PHP Modules
14+
###
15+
enable_modules() {
16+
local mod_varname="${1}"
17+
local debug="${2}"
18+
local cfg_path="/usr/local/etc/php/conf.d"
19+
local mod_path=
20+
mod_path="$( php -i | grep ^extension_dir | awk -F '=>' '{print $2}' | xargs )"
21+
22+
23+
if ! env_set "${mod_varname}"; then
24+
log "info" "\$${mod_varname} not set. Not enabling any PHP modules." "${debug}"
25+
else
26+
mods="$( env_get "${mod_varname}" )"
27+
28+
if [ -z "${mods}" ]; then
29+
log "info" "\$${mod_varname} set, but empty. Not enabling any PHP modules." "${debug}"
30+
else
31+
log "info" "Enabling the following PHP modules: ${mods}" "${debug}"
32+
fi
33+
34+
while read -r mod; do
35+
mod="$( echo "${mod}" | xargs )" # trim
36+
37+
# Does the module exist?
38+
if [ -f "${mod_path}/${mod}.so" ]; then
39+
# Exceptions to load speficially
40+
if [ "${mod}" = "ioncube" ]; then
41+
run "eche 'zend_extension=${mod_path}/ioncube.so' > '${cfg_path}/docker-ext-php-ext-ioncube.ini'" "${debug}"
42+
# Generic Load
43+
else
44+
run "docker-php-ext-enable ${mod} || true" "${debug}"
45+
fi
46+
else
47+
log "warn" "Enabling PHP Module: '${mod}' does not exist" "${debug}"
48+
fi
49+
done <<< "$( echo "${mods}" | tr ',' '\n' )"
50+
fi
51+
}

Dockerfiles/prod/data/docker-entrypoint.d/38-disable-modules.sh renamed to Dockerfiles/prod/data/docker-entrypoint.d/39-disable-modules.sh

+3-5
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,24 @@ set -o pipefail
1515
disable_modules() {
1616
local mod_varname="${1}"
1717
local debug="${2}"
18-
local mod_path="/usr/local/etc/php/conf.d"
18+
local cfg_path="/usr/local/etc/php/conf.d"
1919

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

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

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

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

3837
if [ -n "${files}" ]; then
3938
while read -r f; do
@@ -44,6 +43,5 @@ disable_modules() {
4443
done <<< "${files}"
4544
fi
4645
done <<< "$( echo "${mods}" | tr ',' '\n' )"
47-
#done
4846
fi
4947
}

Dockerfiles/prod/data/docker-entrypoint.sh

+6
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,12 @@ copy_ini_files "${PHP_CUST_INI_DIR}" "${PHP_INI_DIR}" "${DEBUG_LEVEL}"
160160
copy_fpm_files "${PHP_CUST_FPM_DIR}" "${PHP_FPM_DIR}" "${DEBUG_LEVEL}"
161161

162162

163+
###
164+
### Enable PHP Modules
165+
###
166+
enable_modules "ENABLE_MODULES" "${DEBUG_LEVEL}"
167+
168+
163169
###
164170
### Disable PHP Modules
165171
###

Dockerfiles/work/data/docker-entrypoint.sh

+6
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,12 @@ copy_ini_files "${PHP_CUST_INI_DIR}" "${PHP_INI_DIR}" "${DEBUG_LEVEL}"
160160
copy_fpm_files "${PHP_CUST_FPM_DIR}" "${PHP_FPM_DIR}" "${DEBUG_LEVEL}"
161161

162162

163+
###
164+
### Enable PHP Modules
165+
###
166+
enable_modules "ENABLE_MODULES" "${DEBUG_LEVEL}"
167+
168+
163169
###
164170
### Disable PHP Modules
165171
###

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ Have a look at the following table to see all supported environment variables fo
610610
<td colspan="5"></td>
611611
</tr>
612612
<tr>
613-
<td rowspan="5"><strong>prod</strong><br/><br/><strong>work</strong></td>
613+
<td rowspan="6"><strong>prod</strong><br/><br/><strong>work</strong></td>
614614
<td><code>TIMEZONE</code></td>
615615
<td>string</td>
616616
<td><code>UTC</code></td>
@@ -622,6 +622,12 @@ Have a look at the following table to see all supported environment variables fo
622622
<td><code>1</code></td>
623623
<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>
624624
</tr>
625+
<tr>
626+
<td><code>ENABLE_MODULES</code></td>
627+
<td>string</td>
628+
<td><code>''</code></td>
629+
<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>
630+
</tr>
625631
<tr>
626632
<td><code>DISABLE_MODULES</code></td>
627633
<td>string</td>

build/ansible/DOCKERFILES/Dockerfile-mods.j2

+8
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ RUN set -x \
113113
{% endif %}
114114
&& docker-php-ext-enable {{ ext }} \
115115
&& cd / && rm -rf /tmp/{{ ext }} \
116+
{# ---- 4.) CUSTOM ---- #}
117+
{% elif extensions_available[ext][php_version]['type'] == 'custom' %}
118+
&& {{ extensions_available[ext][php_version]['command'] }} \
116119
{% endif %}
117120
{# ---------- Installation (generic) ---------- #}
118121
{% elif 'all' in extensions_available[ext] and 'type' in extensions_available[ext]['all'] %}
@@ -147,6 +150,9 @@ RUN set -x \
147150
{% endif %}
148151
&& docker-php-ext-enable {{ ext }} \
149152
&& cd / && rm -rf /tmp/{{ ext }} \
153+
{# ---- 4.) CUSTOM ---- #}
154+
{% elif extensions_available[ext]['all']['type'] == 'custom' %}
155+
&& {{ extensions_available[ext]['all']['command'] }} \
150156
{% endif %}
151157
{% endif %}
152158
{% endif %}
@@ -181,6 +187,8 @@ RUN set -x \
181187
{% if ext == 'opcache' %}
182188
&& php -m | grep -oiE '^Zend Opcache$' \
183189
&& php-fpm -m | grep -oiE '^Zend Opcache$' \
190+
{% elif ext == 'ioncube' %}
191+
{# Not enabled #}
184192
{% else %}
185193
&& php -m | grep -oiE '^{{ ext }}$' \
186194
&& php-fpm -m | grep -oiE '^{{ ext }}$' \

build/ansible/group_vars/all.yml

+18
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,8 @@ software_available:
398398
### Extensions to actually enable
399399
###
400400
extensions_enabled:
401+
# ioncube must be loaded first
402+
- ioncube
401403
- amqp
402404
- apcu
403405
- bcmath
@@ -505,6 +507,8 @@ extensions_enabled:
505507
# git_ref: [optional] Tag, branch, commit to checkout
506508
# configure: [optional] Add './configure' arguments
507509
# command: [optional] Overwrite default command (phpize && ./configure && make && make install)
510+
# type: custom
511+
# command: [required] Custom command to install and enable a module
508512
extensions_available:
509513
amqp:
510514
disabled: [7.3]
@@ -663,6 +667,20 @@ extensions_available:
663667
type: builtin
664668
build_dep: [libicu-dev]
665669
run_dep: [libicu52]
670+
ioncube:
671+
disabled: [7.3]
672+
all:
673+
type: custom
674+
command: |
675+
EXTENSION_DIR="$( php -i | grep ^extension_dir | awk -F '=>' '{print $2}' | xargs )" \
676+
&& if [ ! -d "${EXTENSION_DIR}" ]; then mkdir -p "${EXTENSION_DIR}"; fi \
677+
&& curl https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz -L -o ioncube.tar.gz \
678+
&& tar xvfz ioncube.tar.gz \
679+
&& cd ioncube \
680+
&& cp "ioncube_loader_lin_{{ php_version }}.so" "${EXTENSION_DIR}/ioncube.so" \
681+
&& cd ../ \
682+
&& rm -rf ioncube \
683+
&& rm -rf ioncube.tar.gz \
666684
json:
667685
7.0:
668686
type: builtin

0 commit comments

Comments
 (0)