Skip to content

Commit 9288cfa

Browse files
committed
add zts support
1 parent a5c680f commit 9288cfa

15 files changed

+660
-1
lines changed

5.5/zts/Dockerfile

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
FROM debian:jessie
2+
3+
# persistent / runtime deps
4+
RUN apt-get update && apt-get install -y ca-certificates curl librecode0 libsqlite3-0 libxml2 --no-install-recommends && rm -r /var/lib/apt/lists/*
5+
6+
# phpize deps
7+
RUN apt-get update && apt-get install -y autoconf file g++ gcc libc-dev make pkg-config re2c --no-install-recommends && rm -r /var/lib/apt/lists/*
8+
9+
ENV PHP_INI_DIR /usr/local/etc/php
10+
RUN mkdir -p $PHP_INI_DIR/conf.d
11+
12+
##<autogenerated>##
13+
ENV PHP_EXTRA_CONFIGURE_ARGS --enable-maintainer-zts
14+
##</autogenerated>##
15+
16+
ENV GPG_KEYS 0B96609E270F565C13292B24C13C70B87267B52D 0BD78B5F97500D450838F95DFE857D9A90D90EC1 F38252826ACD957EF380D39F2F7956BC5DA04B5D
17+
RUN set -xe \
18+
&& for key in $GPG_KEYS; do \
19+
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
20+
done
21+
22+
ENV PHP_VERSION 5.5.30
23+
ENV PHP_FILENAME php-5.5.30.tar.xz
24+
ENV PHP_SHA256 d00dc06fa5e0f3de048fb0cf940b3cc59b43b3f8cad825d4fffb35503cf2e8f2
25+
26+
# --enable-mysqlnd is included below because it's harder to compile after the fact the extensions are (since it's a plugin for several extensions, not an extension in itself)
27+
RUN buildDeps=" \
28+
$PHP_EXTRA_BUILD_DEPS \
29+
libcurl4-openssl-dev \
30+
libreadline6-dev \
31+
librecode-dev \
32+
libsqlite3-dev \
33+
libssl-dev \
34+
libxml2-dev \
35+
xz-utils \
36+
" \
37+
&& set -x \
38+
&& apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \
39+
&& curl -fSL "http://php.net/get/$PHP_FILENAME/from/this/mirror" -o "$PHP_FILENAME" \
40+
&& echo "$PHP_SHA256 *$PHP_FILENAME" | sha256sum -c - \
41+
&& curl -fSL "http://php.net/get/$PHP_FILENAME.asc/from/this/mirror" -o "$PHP_FILENAME.asc" \
42+
&& gpg --verify "$PHP_FILENAME.asc" \
43+
&& mkdir -p /usr/src/php \
44+
&& tar -xf "$PHP_FILENAME" -C /usr/src/php --strip-components=1 \
45+
&& rm "$PHP_FILENAME"* \
46+
&& cd /usr/src/php \
47+
&& ./configure \
48+
--with-config-file-path="$PHP_INI_DIR" \
49+
--with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \
50+
$PHP_EXTRA_CONFIGURE_ARGS \
51+
--disable-cgi \
52+
--enable-mysqlnd \
53+
--with-curl \
54+
--with-openssl \
55+
--with-readline \
56+
--with-recode \
57+
--with-zlib \
58+
&& make -j"$(nproc)" \
59+
&& make install \
60+
&& { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \
61+
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps \
62+
&& make clean
63+
64+
COPY docker-php-ext-* /usr/local/bin/
65+
66+
##<autogenerated>##
67+
CMD ["php", "-a"]
68+
##</autogenerated>##

5.5/zts/docker-php-ext-configure

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
set -e
3+
4+
ext="$1"
5+
extDir="/usr/src/php/ext/$ext"
6+
if [ -z "$ext" -o ! -d "$extDir" ]; then
7+
echo >&2 "usage: $0 ext-name [configure flags]"
8+
echo >&2 " ie: $0 gd --with-jpeg-dir=/usr/local/something"
9+
echo >&2
10+
echo >&2 'Possible values for ext-name:'
11+
echo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)
12+
exit 1
13+
fi
14+
shift
15+
16+
set -x
17+
cd "$extDir"
18+
phpize
19+
./configure "$@"

5.5/zts/docker-php-ext-enable

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/bash
2+
set -e
3+
4+
cd "$(php -r 'echo ini_get("extension_dir");')"
5+
6+
usage() {
7+
echo "usage: $0 module-name [module-name ...]"
8+
echo " ie: $0 gd mysqli"
9+
echo " $0 pdo pdo_mysql"
10+
echo
11+
echo 'Possible values for module-name:'
12+
echo $(find -maxdepth 1 -type f -name '*.so' -exec basename '{}' ';' | sort)
13+
}
14+
15+
modules=()
16+
while [ $# -gt 0 ]; do
17+
module="$1"
18+
shift
19+
if [ -z "$module" ]; then
20+
continue
21+
fi
22+
if [ -f "$module.so" -a ! -f "$module" ]; then
23+
# allow ".so" to be optional
24+
module+='.so'
25+
fi
26+
if [ ! -f "$module" ]; then
27+
echo >&2 "error: $(readlink -f "$module") does not exist"
28+
echo >&2
29+
usage >&2
30+
exit 1
31+
fi
32+
modules+=( "$module" )
33+
done
34+
35+
if [ "${#modules[@]}" -eq 0 ]; then
36+
usage >&2
37+
exit 1
38+
fi
39+
40+
for module in "${modules[@]}"; do
41+
if grep -q zend_extension_entry "$module"; then
42+
# https://wiki.php.net/internals/extensions#loading_zend_extensions
43+
line="zend_extension=$(readlink -f "$module")"
44+
else
45+
line="extension=$module"
46+
fi
47+
48+
ext="$(basename "$module")"
49+
ext="${ext%.*}"
50+
if php -r 'exit(extension_loaded("'"$ext"'") ? 0 : 1);'; then
51+
# this isn't perfect, but it's better than nothing
52+
# (for example, 'opcache.so' presents inside PHP as 'Zend OPcache', not 'opcache')
53+
echo >&2
54+
echo >&2 "warning: $ext ($module) is already loaded!"
55+
echo >&2
56+
continue
57+
fi
58+
59+
ini="/usr/local/etc/php/conf.d/docker-php-ext-$ext.ini"
60+
if ! grep -q "$line" "$ini" 2>/dev/null; then
61+
echo "$line" >> "$ini"
62+
fi
63+
done

5.5/zts/docker-php-ext-install

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/bash
2+
set -e
3+
4+
cd /usr/src/php/ext
5+
6+
usage() {
7+
echo "usage: $0 [-jN] ext-name [ext-name ...]"
8+
echo " ie: $0 gd mysqli"
9+
echo " $0 pdo pdo_mysql"
10+
echo " $0 -j5 gd mbstring mysqli pdo pdo_mysql shmop"
11+
echo
12+
echo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'
13+
echo
14+
echo 'Possible values for ext-name:'
15+
echo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)
16+
}
17+
18+
opts="$(getopt -o 'h?j:' --long 'help,jobs:' -- "$@" || { usage >&2 && false; })"
19+
eval set -- "$opts"
20+
21+
j=1
22+
while true; do
23+
flag="$1"
24+
shift
25+
case "$flag" in
26+
--help|-h|'-?') usage && exit 0 ;;
27+
--jobs|-j) j="$1" && shift ;;
28+
--) break ;;
29+
*)
30+
{
31+
echo "error: unknown flag: $flag"
32+
usage
33+
} >&2
34+
exit 1
35+
;;
36+
esac
37+
done
38+
39+
exts=()
40+
while [ $# -gt 0 ]; do
41+
ext="$1"
42+
shift
43+
if [ -z "$ext" ]; then
44+
continue
45+
fi
46+
if [ ! -d "$ext" ]; then
47+
echo >&2 "error: $(pwd -P)/$ext does not exist"
48+
echo >&2
49+
usage >&2
50+
exit 1
51+
fi
52+
exts+=( "$ext" )
53+
done
54+
55+
if [ "${#exts[@]}" -eq 0 ]; then
56+
usage >&2
57+
exit 1
58+
fi
59+
60+
for ext in "${exts[@]}"; do
61+
(
62+
cd "$ext"
63+
[ -e Makefile ] || docker-php-ext-configure "$ext"
64+
make -j"$j"
65+
make -j"$j" install
66+
find modules -maxdepth 1 -name '*.so' -exec basename '{}' ';' | xargs --no-run-if-empty --verbose docker-php-ext-enable
67+
make -j"$j" clean
68+
)
69+
done

5.6/zts/Dockerfile

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
FROM debian:jessie
2+
3+
# persistent / runtime deps
4+
RUN apt-get update && apt-get install -y ca-certificates curl librecode0 libsqlite3-0 libxml2 --no-install-recommends && rm -r /var/lib/apt/lists/*
5+
6+
# phpize deps
7+
RUN apt-get update && apt-get install -y autoconf file g++ gcc libc-dev make pkg-config re2c --no-install-recommends && rm -r /var/lib/apt/lists/*
8+
9+
ENV PHP_INI_DIR /usr/local/etc/php
10+
RUN mkdir -p $PHP_INI_DIR/conf.d
11+
12+
##<autogenerated>##
13+
ENV PHP_EXTRA_CONFIGURE_ARGS --enable-maintainer-zts
14+
##</autogenerated>##
15+
16+
ENV GPG_KEYS 0BD78B5F97500D450838F95DFE857D9A90D90EC1 6E4F6AB321FDC07F2C332E3AC2BF0BC433CFC8B3
17+
RUN set -xe \
18+
&& for key in $GPG_KEYS; do \
19+
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
20+
done
21+
22+
ENV PHP_VERSION 5.6.16
23+
ENV PHP_FILENAME php-5.6.16.tar.xz
24+
ENV PHP_SHA256 8ef43271d9bd8cc8f8d407d3ba569de9fa14a28985ae97c76085bb50d597de98
25+
26+
# --enable-mysqlnd is included below because it's harder to compile after the fact the extensions are (since it's a plugin for several extensions, not an extension in itself)
27+
RUN buildDeps=" \
28+
$PHP_EXTRA_BUILD_DEPS \
29+
libcurl4-openssl-dev \
30+
libreadline6-dev \
31+
librecode-dev \
32+
libsqlite3-dev \
33+
libssl-dev \
34+
libxml2-dev \
35+
xz-utils \
36+
" \
37+
&& set -x \
38+
&& apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \
39+
&& curl -fSL "http://php.net/get/$PHP_FILENAME/from/this/mirror" -o "$PHP_FILENAME" \
40+
&& echo "$PHP_SHA256 *$PHP_FILENAME" | sha256sum -c - \
41+
&& curl -fSL "http://php.net/get/$PHP_FILENAME.asc/from/this/mirror" -o "$PHP_FILENAME.asc" \
42+
&& gpg --verify "$PHP_FILENAME.asc" \
43+
&& mkdir -p /usr/src/php \
44+
&& tar -xf "$PHP_FILENAME" -C /usr/src/php --strip-components=1 \
45+
&& rm "$PHP_FILENAME"* \
46+
&& cd /usr/src/php \
47+
&& ./configure \
48+
--with-config-file-path="$PHP_INI_DIR" \
49+
--with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \
50+
$PHP_EXTRA_CONFIGURE_ARGS \
51+
--disable-cgi \
52+
--enable-mysqlnd \
53+
--with-curl \
54+
--with-openssl \
55+
--with-readline \
56+
--with-recode \
57+
--with-zlib \
58+
&& make -j"$(nproc)" \
59+
&& make install \
60+
&& { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \
61+
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps \
62+
&& make clean
63+
64+
COPY docker-php-ext-* /usr/local/bin/
65+
66+
##<autogenerated>##
67+
CMD ["php", "-a"]
68+
##</autogenerated>##

5.6/zts/docker-php-ext-configure

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
set -e
3+
4+
ext="$1"
5+
extDir="/usr/src/php/ext/$ext"
6+
if [ -z "$ext" -o ! -d "$extDir" ]; then
7+
echo >&2 "usage: $0 ext-name [configure flags]"
8+
echo >&2 " ie: $0 gd --with-jpeg-dir=/usr/local/something"
9+
echo >&2
10+
echo >&2 'Possible values for ext-name:'
11+
echo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)
12+
exit 1
13+
fi
14+
shift
15+
16+
set -x
17+
cd "$extDir"
18+
phpize
19+
./configure "$@"

5.6/zts/docker-php-ext-enable

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/bash
2+
set -e
3+
4+
cd "$(php -r 'echo ini_get("extension_dir");')"
5+
6+
usage() {
7+
echo "usage: $0 module-name [module-name ...]"
8+
echo " ie: $0 gd mysqli"
9+
echo " $0 pdo pdo_mysql"
10+
echo
11+
echo 'Possible values for module-name:'
12+
echo $(find -maxdepth 1 -type f -name '*.so' -exec basename '{}' ';' | sort)
13+
}
14+
15+
modules=()
16+
while [ $# -gt 0 ]; do
17+
module="$1"
18+
shift
19+
if [ -z "$module" ]; then
20+
continue
21+
fi
22+
if [ -f "$module.so" -a ! -f "$module" ]; then
23+
# allow ".so" to be optional
24+
module+='.so'
25+
fi
26+
if [ ! -f "$module" ]; then
27+
echo >&2 "error: $(readlink -f "$module") does not exist"
28+
echo >&2
29+
usage >&2
30+
exit 1
31+
fi
32+
modules+=( "$module" )
33+
done
34+
35+
if [ "${#modules[@]}" -eq 0 ]; then
36+
usage >&2
37+
exit 1
38+
fi
39+
40+
for module in "${modules[@]}"; do
41+
if grep -q zend_extension_entry "$module"; then
42+
# https://wiki.php.net/internals/extensions#loading_zend_extensions
43+
line="zend_extension=$(readlink -f "$module")"
44+
else
45+
line="extension=$module"
46+
fi
47+
48+
ext="$(basename "$module")"
49+
ext="${ext%.*}"
50+
if php -r 'exit(extension_loaded("'"$ext"'") ? 0 : 1);'; then
51+
# this isn't perfect, but it's better than nothing
52+
# (for example, 'opcache.so' presents inside PHP as 'Zend OPcache', not 'opcache')
53+
echo >&2
54+
echo >&2 "warning: $ext ($module) is already loaded!"
55+
echo >&2
56+
continue
57+
fi
58+
59+
ini="/usr/local/etc/php/conf.d/docker-php-ext-$ext.ini"
60+
if ! grep -q "$line" "$ini" 2>/dev/null; then
61+
echo "$line" >> "$ini"
62+
fi
63+
done

0 commit comments

Comments
 (0)