From 0d23b3d08770889c6cb31e8e5374334879103f92 Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Fri, 18 Mar 2016 10:52:43 -0700 Subject: [PATCH] Apply update.sh --- 5.5/Dockerfile | 50 +++++---- 5.5/alpine/Dockerfile | 91 ++++++++++++++++ 5.5/alpine/docker-php-ext-configure | 19 ++++ 5.5/alpine/docker-php-ext-enable | 83 +++++++++++++++ 5.5/alpine/docker-php-ext-install | 71 +++++++++++++ 5.5/apache/Dockerfile | 50 +++++---- 5.5/apache/docker-php-ext-configure | 4 +- 5.5/apache/docker-php-ext-enable | 20 ++-- 5.5/apache/docker-php-ext-install | 20 ++-- 5.5/docker-php-ext-configure | 4 +- 5.5/docker-php-ext-enable | 20 ++-- 5.5/docker-php-ext-install | 20 ++-- 5.5/fpm/Dockerfile | 50 +++++---- 5.5/fpm/alpine/Dockerfile | 131 ++++++++++++++++++++++++ 5.5/fpm/alpine/docker-php-ext-configure | 19 ++++ 5.5/fpm/alpine/docker-php-ext-enable | 83 +++++++++++++++ 5.5/fpm/alpine/docker-php-ext-install | 71 +++++++++++++ 5.5/fpm/docker-php-ext-configure | 4 +- 5.5/fpm/docker-php-ext-enable | 20 ++-- 5.5/fpm/docker-php-ext-install | 20 ++-- 5.5/zts/Dockerfile | 50 +++++---- 5.5/zts/alpine/Dockerfile | 92 +++++++++++++++++ 5.5/zts/alpine/docker-php-ext-configure | 19 ++++ 5.5/zts/alpine/docker-php-ext-enable | 83 +++++++++++++++ 5.5/zts/alpine/docker-php-ext-install | 71 +++++++++++++ 5.5/zts/docker-php-ext-configure | 4 +- 5.5/zts/docker-php-ext-enable | 20 ++-- 5.5/zts/docker-php-ext-install | 20 ++-- 5.6/Dockerfile | 50 +++++---- 5.6/alpine/Dockerfile | 57 +++++++---- 5.6/alpine/docker-php-ext-enable | 32 +++++- 5.6/alpine/docker-php-ext-install | 6 +- 5.6/apache/Dockerfile | 50 +++++---- 5.6/apache/docker-php-ext-configure | 4 +- 5.6/apache/docker-php-ext-enable | 20 ++-- 5.6/apache/docker-php-ext-install | 20 ++-- 5.6/docker-php-ext-configure | 4 +- 5.6/docker-php-ext-enable | 20 ++-- 5.6/docker-php-ext-install | 20 ++-- 5.6/fpm/Dockerfile | 50 +++++---- 5.6/fpm/alpine/Dockerfile | 60 +++++++---- 5.6/fpm/alpine/docker-php-ext-enable | 32 +++++- 5.6/fpm/alpine/docker-php-ext-install | 6 +- 5.6/fpm/docker-php-ext-configure | 4 +- 5.6/fpm/docker-php-ext-enable | 20 ++-- 5.6/fpm/docker-php-ext-install | 20 ++-- 5.6/zts/Dockerfile | 50 +++++---- 5.6/zts/alpine/Dockerfile | 92 +++++++++++++++++ 5.6/zts/alpine/docker-php-ext-configure | 19 ++++ 5.6/zts/alpine/docker-php-ext-enable | 83 +++++++++++++++ 5.6/zts/alpine/docker-php-ext-install | 71 +++++++++++++ 5.6/zts/docker-php-ext-configure | 4 +- 5.6/zts/docker-php-ext-enable | 20 ++-- 5.6/zts/docker-php-ext-install | 20 ++-- 7.0/Dockerfile | 50 +++++---- 7.0/alpine/Dockerfile | 57 +++++++---- 7.0/alpine/docker-php-ext-enable | 32 +++++- 7.0/alpine/docker-php-ext-install | 6 +- 7.0/apache/Dockerfile | 50 +++++---- 7.0/apache/docker-php-ext-configure | 4 +- 7.0/apache/docker-php-ext-enable | 20 ++-- 7.0/apache/docker-php-ext-install | 20 ++-- 7.0/docker-php-ext-configure | 4 +- 7.0/docker-php-ext-enable | 20 ++-- 7.0/docker-php-ext-install | 20 ++-- 7.0/fpm/Dockerfile | 50 +++++---- 7.0/fpm/alpine/Dockerfile | 60 +++++++---- 7.0/fpm/alpine/docker-php-ext-enable | 32 +++++- 7.0/fpm/alpine/docker-php-ext-install | 6 +- 7.0/fpm/docker-php-ext-configure | 4 +- 7.0/fpm/docker-php-ext-enable | 20 ++-- 7.0/fpm/docker-php-ext-install | 20 ++-- 7.0/zts/Dockerfile | 50 +++++---- 7.0/zts/alpine/Dockerfile | 92 +++++++++++++++++ 7.0/zts/alpine/docker-php-ext-configure | 19 ++++ 7.0/zts/alpine/docker-php-ext-enable | 83 +++++++++++++++ 7.0/zts/alpine/docker-php-ext-install | 71 +++++++++++++ 7.0/zts/docker-php-ext-configure | 4 +- 7.0/zts/docker-php-ext-enable | 20 ++-- 7.0/zts/docker-php-ext-install | 20 ++-- 80 files changed, 2295 insertions(+), 582 deletions(-) create mode 100644 5.5/alpine/Dockerfile create mode 100755 5.5/alpine/docker-php-ext-configure create mode 100755 5.5/alpine/docker-php-ext-enable create mode 100755 5.5/alpine/docker-php-ext-install create mode 100644 5.5/fpm/alpine/Dockerfile create mode 100755 5.5/fpm/alpine/docker-php-ext-configure create mode 100755 5.5/fpm/alpine/docker-php-ext-enable create mode 100755 5.5/fpm/alpine/docker-php-ext-install create mode 100644 5.5/zts/alpine/Dockerfile create mode 100755 5.5/zts/alpine/docker-php-ext-configure create mode 100755 5.5/zts/alpine/docker-php-ext-enable create mode 100755 5.5/zts/alpine/docker-php-ext-install create mode 100644 5.6/zts/alpine/Dockerfile create mode 100755 5.6/zts/alpine/docker-php-ext-configure create mode 100755 5.6/zts/alpine/docker-php-ext-enable create mode 100755 5.6/zts/alpine/docker-php-ext-install create mode 100644 7.0/zts/alpine/Dockerfile create mode 100755 7.0/zts/alpine/docker-php-ext-configure create mode 100755 7.0/zts/alpine/docker-php-ext-enable create mode 100755 7.0/zts/alpine/docker-php-ext-install diff --git a/5.5/Dockerfile b/5.5/Dockerfile index a414dde3..75f9a0fc 100644 --- a/5.5/Dockerfile +++ b/5.5/Dockerfile @@ -1,10 +1,25 @@ FROM debian:jessie -# persistent / runtime deps -RUN apt-get update && apt-get install -y ca-certificates curl librecode0 libsqlite3-0 libxml2 --no-install-recommends && rm -r /var/lib/apt/lists/* - # phpize deps -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/* +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/* + +# persistent / runtime deps +RUN apt-get update && apt-get install -y \ + ca-certificates \ + curl \ + libedit2 \ + libsqlite3-0 \ + libxml2 \ + --no-install-recommends && rm -r /var/lib/apt/lists/* ENV PHP_INI_DIR /usr/local/etc/php RUN mkdir -p $PHP_INI_DIR/conf.d @@ -13,52 +28,51 @@ RUN mkdir -p $PHP_INI_DIR/conf.d #### ENV GPG_KEYS 0B96609E270F565C13292B24C13C70B87267B52D 0BD78B5F97500D450838F95DFE857D9A90D90EC1 F38252826ACD957EF380D39F2F7956BC5DA04B5D -RUN set -xe \ - && for key in $GPG_KEYS; do \ - gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ - done ENV PHP_VERSION 5.5.33 ENV PHP_FILENAME php-5.5.33.tar.xz ENV PHP_SHA256 b91dbd3c53f9895e8f7b29e5fed25a64dd3a76b454f6ef7265e73c96b4303f30 -# --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) -RUN buildDeps=" \ +RUN set -xe \ + && buildDeps=" \ $PHP_EXTRA_BUILD_DEPS \ libcurl4-openssl-dev \ - libreadline6-dev \ - librecode-dev \ + libedit-dev \ libsqlite3-dev \ libssl-dev \ libxml2-dev \ xz-utils \ " \ - && set -x \ && apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \ && curl -fSL "http://php.net/get/$PHP_FILENAME/from/this/mirror" -o "$PHP_FILENAME" \ && echo "$PHP_SHA256 *$PHP_FILENAME" | sha256sum -c - \ && curl -fSL "http://php.net/get/$PHP_FILENAME.asc/from/this/mirror" -o "$PHP_FILENAME.asc" \ + && export GNUPGHOME="$(mktemp -d)" \ + && for key in $GPG_KEYS; do \ + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ + done \ && gpg --batch --verify "$PHP_FILENAME.asc" "$PHP_FILENAME" \ + && rm -r "$GNUPGHOME" "$PHP_FILENAME.asc" \ && mkdir -p /usr/src/php \ && tar -xf "$PHP_FILENAME" -C /usr/src/php --strip-components=1 \ - && rm "$PHP_FILENAME"* \ + && rm "$PHP_FILENAME" \ && cd /usr/src/php \ && ./configure \ --with-config-file-path="$PHP_INI_DIR" \ --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \ $PHP_EXTRA_CONFIGURE_ARGS \ --disable-cgi \ +# --enable-mysqlnd is included here because it's harder to compile after the fact than extensions are (since it's a plugin for several extensions, not an extension in itself) --enable-mysqlnd \ --with-curl \ + --with-libedit \ --with-openssl \ - --with-readline \ - --with-recode \ --with-zlib \ && make -j"$(nproc)" \ && make install \ && { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \ - && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps \ - && make clean + && make clean \ + && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps COPY docker-php-ext-* /usr/local/bin/ diff --git a/5.5/alpine/Dockerfile b/5.5/alpine/Dockerfile new file mode 100644 index 00000000..271a616f --- /dev/null +++ b/5.5/alpine/Dockerfile @@ -0,0 +1,91 @@ +FROM alpine:3.3 + +# phpize deps +RUN apk add --no-cache --virtual .phpize-deps \ + autoconf \ + file \ + g++ \ + gcc \ + libc-dev \ + make \ + pkgconf \ + re2c + +# persistent / runtime deps +RUN apk add --no-cache --virtual .persistent-deps \ + ca-certificates \ + curl + +# ensure www-data user exists +RUN set -x \ + && addgroup -g 82 -S www-data \ + && adduser -u 82 -D -S -G www-data www-data +# 82 is the standard uid/gid for "www-data" in Alpine +# http://git.alpinelinux.org/cgit/aports/tree/main/apache2/apache2.pre-install?h=v3.3.2 +# http://git.alpinelinux.org/cgit/aports/tree/main/lighttpd/lighttpd.pre-install?h=v3.3.2 +# http://git.alpinelinux.org/cgit/aports/tree/main/nginx-initscripts/nginx-initscripts.pre-install?h=v3.3.2 + +ENV PHP_INI_DIR /usr/local/etc/php +RUN mkdir -p $PHP_INI_DIR/conf.d + +#### +#### + +ENV GPG_KEYS 0B96609E270F565C13292B24C13C70B87267B52D 0BD78B5F97500D450838F95DFE857D9A90D90EC1 F38252826ACD957EF380D39F2F7956BC5DA04B5D + +ENV PHP_VERSION 5.5.33 +ENV PHP_FILENAME php-5.5.33.tar.xz +ENV PHP_SHA256 b91dbd3c53f9895e8f7b29e5fed25a64dd3a76b454f6ef7265e73c96b4303f30 + +RUN set -xe \ + && apk add --no-cache --virtual .build-deps \ + curl-dev \ + gnupg \ + libedit-dev \ + libxml2-dev \ + openssl-dev \ + sqlite-dev \ + && curl -fSL "http://php.net/get/$PHP_FILENAME/from/this/mirror" -o "$PHP_FILENAME" \ + && echo "$PHP_SHA256 *$PHP_FILENAME" | sha256sum -c - \ + && curl -fSL "http://php.net/get/$PHP_FILENAME.asc/from/this/mirror" -o "$PHP_FILENAME.asc" \ + && export GNUPGHOME="$(mktemp -d)" \ + && for key in $GPG_KEYS; do \ + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ + done \ + && gpg --batch --verify "$PHP_FILENAME.asc" "$PHP_FILENAME" \ + && rm -r "$GNUPGHOME" "$PHP_FILENAME.asc" \ + && mkdir -p /usr/src \ + && tar -Jxf "$PHP_FILENAME" -C /usr/src \ + && mv "/usr/src/php-$PHP_VERSION" /usr/src/php \ + && rm "$PHP_FILENAME" \ + && cd /usr/src/php \ + && ./configure \ + --with-config-file-path="$PHP_INI_DIR" \ + --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \ + $PHP_EXTRA_CONFIGURE_ARGS \ + --disable-cgi \ +# --enable-mysqlnd is included here because it's harder to compile after the fact than extensions are (since it's a plugin for several extensions, not an extension in itself) + --enable-mysqlnd \ + --with-curl \ + --with-libedit \ + --with-openssl \ + --with-zlib \ + && make -j"$(getconf _NPROCESSORS_ONLN)" \ + && make install \ + && { find /usr/local/bin /usr/local/sbin -type f -perm +0111 -exec strip --strip-all '{}' + || true; } \ + && make clean \ + && runDeps="$( \ + scanelf --needed --nobanner --recursive /usr/local \ + | awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \ + | sort -u \ + | xargs -r apk info --installed \ + | sort -u \ + )" \ + && apk add --virtual .php-rundeps $runDeps \ + && apk del .build-deps + +COPY docker-php-ext-* /usr/local/bin/ + +#### +CMD ["php", "-a"] +#### diff --git a/5.5/alpine/docker-php-ext-configure b/5.5/alpine/docker-php-ext-configure new file mode 100755 index 00000000..39947c8f --- /dev/null +++ b/5.5/alpine/docker-php-ext-configure @@ -0,0 +1,19 @@ +#!/bin/sh +set -e + +ext="$1" +extDir="/usr/src/php/ext/$ext" +if [ -z "$ext" ] || ! [ -d "$extDir" ]; then + echo >&2 "usage: $0 ext-name [configure flags]" + echo >&2 " ie: $0 gd --with-jpeg-dir=/usr/local/something" + echo >&2 + echo >&2 'Possible values for ext-name:' + echo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort) + exit 1 +fi +shift + +set -x +cd "$extDir" +phpize +./configure "$@" diff --git a/5.5/alpine/docker-php-ext-enable b/5.5/alpine/docker-php-ext-enable new file mode 100755 index 00000000..367aaf2b --- /dev/null +++ b/5.5/alpine/docker-php-ext-enable @@ -0,0 +1,83 @@ +#!/bin/sh +set -e + +cd "$(php -r 'echo ini_get("extension_dir");')" + +usage() { + echo "usage: $0 [options] module-name [module-name ...]" + echo " ie: $0 gd mysqli" + echo " $0 pdo pdo_mysql" + echo " $0 --ini-name 0-apc.ini apcu apc" + echo + echo 'Possible values for module-name:' + echo $(find -maxdepth 1 -type f -name '*.so' -exec basename '{}' ';' | sort) +} + +opts="$(getopt -o 'h?' --long 'help,ini-name:' -- "$@" || { usage >&2 && false; })" +eval set -- "$opts" + +iniName= +while true; do + flag="$1" + shift + case "$flag" in + --help|-h|'-?') usage && exit 0 ;; + --ini-name) iniName="$1" && shift ;; + --) break ;; + *) + { + echo "error: unknown flag: $flag" + usage + } >&2 + exit 1 + ;; + esac +done + +modules= +for module; do + if [ -z "$module" ]; then + continue + fi + if [ -f "$module.so" ] && ! [ -f "$module" ]; then + # allow ".so" to be optional + module="$module.so" + fi + if ! [ -f "$module" ]; then + echo >&2 "error: $(readlink -f "$module") does not exist" + echo >&2 + usage >&2 + exit 1 + fi + modules="$modules $module" +done + +if [ -z "$modules" ]; then + usage >&2 + exit 1 +fi + +for module in $modules; do + if nm -g "$module" | grep -q ' zend_extension_entry$'; then + # https://wiki.php.net/internals/extensions#loading_zend_extensions + line="zend_extension=$(readlink -f "$module")" + else + line="extension=$module" + fi + + ext="$(basename "$module")" + ext="${ext%.*}" + if php -r 'exit(extension_loaded("'"$ext"'") ? 0 : 1);'; then + # this isn't perfect, but it's better than nothing + # (for example, 'opcache.so' presents inside PHP as 'Zend OPcache', not 'opcache') + echo >&2 + echo >&2 "warning: $ext ($module) is already loaded!" + echo >&2 + continue + fi + + ini="/usr/local/etc/php/conf.d/${iniName:-"docker-php-ext-$ext.ini"}" + if ! grep -q "$line" "$ini" 2>/dev/null; then + echo "$line" >> "$ini" + fi +done diff --git a/5.5/alpine/docker-php-ext-install b/5.5/alpine/docker-php-ext-install new file mode 100755 index 00000000..67180a86 --- /dev/null +++ b/5.5/alpine/docker-php-ext-install @@ -0,0 +1,71 @@ +#!/bin/sh +set -e + +cd /usr/src/php/ext + +usage() { + echo "usage: $0 [-jN] ext-name [ext-name ...]" + echo " ie: $0 gd mysqli" + echo " $0 pdo pdo_mysql" + echo " $0 -j5 gd mbstring mysqli pdo pdo_mysql shmop" + echo + echo 'if custom ./configure arguments are necessary, see docker-php-ext-configure' + echo + echo 'Possible values for ext-name:' + echo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort) +} + +opts="$(getopt -o 'h?j:' --long 'help,jobs:' -- "$@" || { usage >&2 && false; })" +eval set -- "$opts" + +j=1 +while true; do + flag="$1" + shift + case "$flag" in + --help|-h|'-?') usage && exit 0 ;; + --jobs|-j) j="$1" && shift ;; + --) break ;; + *) + { + echo "error: unknown flag: $flag" + usage + } >&2 + exit 1 + ;; + esac +done + +exts= +for ext; do + if [ -z "$ext" ]; then + continue + fi + if [ ! -d "$ext" ]; then + echo >&2 "error: $(pwd -P)/$ext does not exist" + echo >&2 + usage >&2 + exit 1 + fi + exts="$exts $ext" +done + +if [ -z "$exts" ]; then + usage >&2 + exit 1 +fi + +for ext in $exts; do + ( + cd "$ext" + [ -e Makefile ] || docker-php-ext-configure "$ext" + make -j"$j" + make -j"$j" install + find modules \ + -maxdepth 1 \ + -name '*.so' \ + -exec basename '{}' ';' \ + | xargs -r docker-php-ext-enable + make -j"$j" clean + ) +done diff --git a/5.5/apache/Dockerfile b/5.5/apache/Dockerfile index 44cf3a71..94881d08 100644 --- a/5.5/apache/Dockerfile +++ b/5.5/apache/Dockerfile @@ -1,10 +1,25 @@ FROM debian:jessie -# persistent / runtime deps -RUN apt-get update && apt-get install -y ca-certificates curl librecode0 libsqlite3-0 libxml2 --no-install-recommends && rm -r /var/lib/apt/lists/* - # phpize deps -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/* +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/* + +# persistent / runtime deps +RUN apt-get update && apt-get install -y \ + ca-certificates \ + curl \ + libedit2 \ + libsqlite3-0 \ + libxml2 \ + --no-install-recommends && rm -r /var/lib/apt/lists/* ENV PHP_INI_DIR /usr/local/etc/php RUN mkdir -p $PHP_INI_DIR/conf.d @@ -26,52 +41,51 @@ ENV PHP_EXTRA_CONFIGURE_ARGS --with-apxs2 #### ENV GPG_KEYS 0B96609E270F565C13292B24C13C70B87267B52D 0BD78B5F97500D450838F95DFE857D9A90D90EC1 F38252826ACD957EF380D39F2F7956BC5DA04B5D -RUN set -xe \ - && for key in $GPG_KEYS; do \ - gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ - done ENV PHP_VERSION 5.5.33 ENV PHP_FILENAME php-5.5.33.tar.xz ENV PHP_SHA256 b91dbd3c53f9895e8f7b29e5fed25a64dd3a76b454f6ef7265e73c96b4303f30 -# --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) -RUN buildDeps=" \ +RUN set -xe \ + && buildDeps=" \ $PHP_EXTRA_BUILD_DEPS \ libcurl4-openssl-dev \ - libreadline6-dev \ - librecode-dev \ + libedit-dev \ libsqlite3-dev \ libssl-dev \ libxml2-dev \ xz-utils \ " \ - && set -x \ && apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \ && curl -fSL "http://php.net/get/$PHP_FILENAME/from/this/mirror" -o "$PHP_FILENAME" \ && echo "$PHP_SHA256 *$PHP_FILENAME" | sha256sum -c - \ && curl -fSL "http://php.net/get/$PHP_FILENAME.asc/from/this/mirror" -o "$PHP_FILENAME.asc" \ + && export GNUPGHOME="$(mktemp -d)" \ + && for key in $GPG_KEYS; do \ + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ + done \ && gpg --batch --verify "$PHP_FILENAME.asc" "$PHP_FILENAME" \ + && rm -r "$GNUPGHOME" "$PHP_FILENAME.asc" \ && mkdir -p /usr/src/php \ && tar -xf "$PHP_FILENAME" -C /usr/src/php --strip-components=1 \ - && rm "$PHP_FILENAME"* \ + && rm "$PHP_FILENAME" \ && cd /usr/src/php \ && ./configure \ --with-config-file-path="$PHP_INI_DIR" \ --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \ $PHP_EXTRA_CONFIGURE_ARGS \ --disable-cgi \ +# --enable-mysqlnd is included here because it's harder to compile after the fact than extensions are (since it's a plugin for several extensions, not an extension in itself) --enable-mysqlnd \ --with-curl \ + --with-libedit \ --with-openssl \ - --with-readline \ - --with-recode \ --with-zlib \ && make -j"$(nproc)" \ && make install \ && { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \ - && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps \ - && make clean + && make clean \ + && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps COPY docker-php-ext-* /usr/local/bin/ diff --git a/5.5/apache/docker-php-ext-configure b/5.5/apache/docker-php-ext-configure index 3d21b5bb..39947c8f 100755 --- a/5.5/apache/docker-php-ext-configure +++ b/5.5/apache/docker-php-ext-configure @@ -1,9 +1,9 @@ -#!/bin/bash +#!/bin/sh set -e ext="$1" extDir="/usr/src/php/ext/$ext" -if [ -z "$ext" -o ! -d "$extDir" ]; then +if [ -z "$ext" ] || ! [ -d "$extDir" ]; then echo >&2 "usage: $0 ext-name [configure flags]" echo >&2 " ie: $0 gd --with-jpeg-dir=/usr/local/something" echo >&2 diff --git a/5.5/apache/docker-php-ext-enable b/5.5/apache/docker-php-ext-enable index edb07ed8..367aaf2b 100755 --- a/5.5/apache/docker-php-ext-enable +++ b/5.5/apache/docker-php-ext-enable @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -e cd "$(php -r 'echo ini_get("extension_dir");')" @@ -34,32 +34,30 @@ while true; do esac done -modules=() -while [ $# -gt 0 ]; do - module="$1" - shift +modules= +for module; do if [ -z "$module" ]; then continue fi - if [ -f "$module.so" -a ! -f "$module" ]; then + if [ -f "$module.so" ] && ! [ -f "$module" ]; then # allow ".so" to be optional - module+='.so' + module="$module.so" fi - if [ ! -f "$module" ]; then + if ! [ -f "$module" ]; then echo >&2 "error: $(readlink -f "$module") does not exist" echo >&2 usage >&2 exit 1 fi - modules+=( "$module" ) + modules="$modules $module" done -if [ "${#modules[@]}" -eq 0 ]; then +if [ -z "$modules" ]; then usage >&2 exit 1 fi -for module in "${modules[@]}"; do +for module in $modules; do if nm -g "$module" | grep -q ' zend_extension_entry$'; then # https://wiki.php.net/internals/extensions#loading_zend_extensions line="zend_extension=$(readlink -f "$module")" diff --git a/5.5/apache/docker-php-ext-install b/5.5/apache/docker-php-ext-install index 2c488cce..67180a86 100755 --- a/5.5/apache/docker-php-ext-install +++ b/5.5/apache/docker-php-ext-install @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -e cd /usr/src/php/ext @@ -36,10 +36,8 @@ while true; do esac done -exts=() -while [ $# -gt 0 ]; do - ext="$1" - shift +exts= +for ext; do if [ -z "$ext" ]; then continue fi @@ -49,21 +47,25 @@ while [ $# -gt 0 ]; do usage >&2 exit 1 fi - exts+=( "$ext" ) + exts="$exts $ext" done -if [ "${#exts[@]}" -eq 0 ]; then +if [ -z "$exts" ]; then usage >&2 exit 1 fi -for ext in "${exts[@]}"; do +for ext in $exts; do ( cd "$ext" [ -e Makefile ] || docker-php-ext-configure "$ext" make -j"$j" make -j"$j" install - find modules -maxdepth 1 -name '*.so' -exec basename '{}' ';' | xargs --no-run-if-empty --verbose docker-php-ext-enable + find modules \ + -maxdepth 1 \ + -name '*.so' \ + -exec basename '{}' ';' \ + | xargs -r docker-php-ext-enable make -j"$j" clean ) done diff --git a/5.5/docker-php-ext-configure b/5.5/docker-php-ext-configure index 3d21b5bb..39947c8f 100755 --- a/5.5/docker-php-ext-configure +++ b/5.5/docker-php-ext-configure @@ -1,9 +1,9 @@ -#!/bin/bash +#!/bin/sh set -e ext="$1" extDir="/usr/src/php/ext/$ext" -if [ -z "$ext" -o ! -d "$extDir" ]; then +if [ -z "$ext" ] || ! [ -d "$extDir" ]; then echo >&2 "usage: $0 ext-name [configure flags]" echo >&2 " ie: $0 gd --with-jpeg-dir=/usr/local/something" echo >&2 diff --git a/5.5/docker-php-ext-enable b/5.5/docker-php-ext-enable index edb07ed8..367aaf2b 100755 --- a/5.5/docker-php-ext-enable +++ b/5.5/docker-php-ext-enable @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -e cd "$(php -r 'echo ini_get("extension_dir");')" @@ -34,32 +34,30 @@ while true; do esac done -modules=() -while [ $# -gt 0 ]; do - module="$1" - shift +modules= +for module; do if [ -z "$module" ]; then continue fi - if [ -f "$module.so" -a ! -f "$module" ]; then + if [ -f "$module.so" ] && ! [ -f "$module" ]; then # allow ".so" to be optional - module+='.so' + module="$module.so" fi - if [ ! -f "$module" ]; then + if ! [ -f "$module" ]; then echo >&2 "error: $(readlink -f "$module") does not exist" echo >&2 usage >&2 exit 1 fi - modules+=( "$module" ) + modules="$modules $module" done -if [ "${#modules[@]}" -eq 0 ]; then +if [ -z "$modules" ]; then usage >&2 exit 1 fi -for module in "${modules[@]}"; do +for module in $modules; do if nm -g "$module" | grep -q ' zend_extension_entry$'; then # https://wiki.php.net/internals/extensions#loading_zend_extensions line="zend_extension=$(readlink -f "$module")" diff --git a/5.5/docker-php-ext-install b/5.5/docker-php-ext-install index 2c488cce..67180a86 100755 --- a/5.5/docker-php-ext-install +++ b/5.5/docker-php-ext-install @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -e cd /usr/src/php/ext @@ -36,10 +36,8 @@ while true; do esac done -exts=() -while [ $# -gt 0 ]; do - ext="$1" - shift +exts= +for ext; do if [ -z "$ext" ]; then continue fi @@ -49,21 +47,25 @@ while [ $# -gt 0 ]; do usage >&2 exit 1 fi - exts+=( "$ext" ) + exts="$exts $ext" done -if [ "${#exts[@]}" -eq 0 ]; then +if [ -z "$exts" ]; then usage >&2 exit 1 fi -for ext in "${exts[@]}"; do +for ext in $exts; do ( cd "$ext" [ -e Makefile ] || docker-php-ext-configure "$ext" make -j"$j" make -j"$j" install - find modules -maxdepth 1 -name '*.so' -exec basename '{}' ';' | xargs --no-run-if-empty --verbose docker-php-ext-enable + find modules \ + -maxdepth 1 \ + -name '*.so' \ + -exec basename '{}' ';' \ + | xargs -r docker-php-ext-enable make -j"$j" clean ) done diff --git a/5.5/fpm/Dockerfile b/5.5/fpm/Dockerfile index 15257ea4..93363a27 100644 --- a/5.5/fpm/Dockerfile +++ b/5.5/fpm/Dockerfile @@ -1,10 +1,25 @@ FROM debian:jessie -# persistent / runtime deps -RUN apt-get update && apt-get install -y ca-certificates curl librecode0 libsqlite3-0 libxml2 --no-install-recommends && rm -r /var/lib/apt/lists/* - # phpize deps -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/* +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/* + +# persistent / runtime deps +RUN apt-get update && apt-get install -y \ + ca-certificates \ + curl \ + libedit2 \ + libsqlite3-0 \ + libxml2 \ + --no-install-recommends && rm -r /var/lib/apt/lists/* ENV PHP_INI_DIR /usr/local/etc/php RUN mkdir -p $PHP_INI_DIR/conf.d @@ -14,52 +29,51 @@ ENV PHP_EXTRA_CONFIGURE_ARGS --enable-fpm --with-fpm-user=www-data --with-fpm-gr #### ENV GPG_KEYS 0B96609E270F565C13292B24C13C70B87267B52D 0BD78B5F97500D450838F95DFE857D9A90D90EC1 F38252826ACD957EF380D39F2F7956BC5DA04B5D -RUN set -xe \ - && for key in $GPG_KEYS; do \ - gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ - done ENV PHP_VERSION 5.5.33 ENV PHP_FILENAME php-5.5.33.tar.xz ENV PHP_SHA256 b91dbd3c53f9895e8f7b29e5fed25a64dd3a76b454f6ef7265e73c96b4303f30 -# --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) -RUN buildDeps=" \ +RUN set -xe \ + && buildDeps=" \ $PHP_EXTRA_BUILD_DEPS \ libcurl4-openssl-dev \ - libreadline6-dev \ - librecode-dev \ + libedit-dev \ libsqlite3-dev \ libssl-dev \ libxml2-dev \ xz-utils \ " \ - && set -x \ && apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \ && curl -fSL "http://php.net/get/$PHP_FILENAME/from/this/mirror" -o "$PHP_FILENAME" \ && echo "$PHP_SHA256 *$PHP_FILENAME" | sha256sum -c - \ && curl -fSL "http://php.net/get/$PHP_FILENAME.asc/from/this/mirror" -o "$PHP_FILENAME.asc" \ + && export GNUPGHOME="$(mktemp -d)" \ + && for key in $GPG_KEYS; do \ + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ + done \ && gpg --batch --verify "$PHP_FILENAME.asc" "$PHP_FILENAME" \ + && rm -r "$GNUPGHOME" "$PHP_FILENAME.asc" \ && mkdir -p /usr/src/php \ && tar -xf "$PHP_FILENAME" -C /usr/src/php --strip-components=1 \ - && rm "$PHP_FILENAME"* \ + && rm "$PHP_FILENAME" \ && cd /usr/src/php \ && ./configure \ --with-config-file-path="$PHP_INI_DIR" \ --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \ $PHP_EXTRA_CONFIGURE_ARGS \ --disable-cgi \ +# --enable-mysqlnd is included here because it's harder to compile after the fact than extensions are (since it's a plugin for several extensions, not an extension in itself) --enable-mysqlnd \ --with-curl \ + --with-libedit \ --with-openssl \ - --with-readline \ - --with-recode \ --with-zlib \ && make -j"$(nproc)" \ && make install \ && { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \ - && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps \ - && make clean + && make clean \ + && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps COPY docker-php-ext-* /usr/local/bin/ diff --git a/5.5/fpm/alpine/Dockerfile b/5.5/fpm/alpine/Dockerfile new file mode 100644 index 00000000..3813e2d7 --- /dev/null +++ b/5.5/fpm/alpine/Dockerfile @@ -0,0 +1,131 @@ +FROM alpine:3.3 + +# phpize deps +RUN apk add --no-cache --virtual .phpize-deps \ + autoconf \ + file \ + g++ \ + gcc \ + libc-dev \ + make \ + pkgconf \ + re2c + +# persistent / runtime deps +RUN apk add --no-cache --virtual .persistent-deps \ + ca-certificates \ + curl + +# ensure www-data user exists +RUN set -x \ + && addgroup -g 82 -S www-data \ + && adduser -u 82 -D -S -G www-data www-data +# 82 is the standard uid/gid for "www-data" in Alpine +# http://git.alpinelinux.org/cgit/aports/tree/main/apache2/apache2.pre-install?h=v3.3.2 +# http://git.alpinelinux.org/cgit/aports/tree/main/lighttpd/lighttpd.pre-install?h=v3.3.2 +# http://git.alpinelinux.org/cgit/aports/tree/main/nginx-initscripts/nginx-initscripts.pre-install?h=v3.3.2 + +ENV PHP_INI_DIR /usr/local/etc/php +RUN mkdir -p $PHP_INI_DIR/conf.d + +#### +ENV PHP_EXTRA_CONFIGURE_ARGS --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data +#### + +ENV GPG_KEYS 0B96609E270F565C13292B24C13C70B87267B52D 0BD78B5F97500D450838F95DFE857D9A90D90EC1 F38252826ACD957EF380D39F2F7956BC5DA04B5D + +ENV PHP_VERSION 5.5.33 +ENV PHP_FILENAME php-5.5.33.tar.xz +ENV PHP_SHA256 b91dbd3c53f9895e8f7b29e5fed25a64dd3a76b454f6ef7265e73c96b4303f30 + +RUN set -xe \ + && apk add --no-cache --virtual .build-deps \ + curl-dev \ + gnupg \ + libedit-dev \ + libxml2-dev \ + openssl-dev \ + sqlite-dev \ + && curl -fSL "http://php.net/get/$PHP_FILENAME/from/this/mirror" -o "$PHP_FILENAME" \ + && echo "$PHP_SHA256 *$PHP_FILENAME" | sha256sum -c - \ + && curl -fSL "http://php.net/get/$PHP_FILENAME.asc/from/this/mirror" -o "$PHP_FILENAME.asc" \ + && export GNUPGHOME="$(mktemp -d)" \ + && for key in $GPG_KEYS; do \ + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ + done \ + && gpg --batch --verify "$PHP_FILENAME.asc" "$PHP_FILENAME" \ + && rm -r "$GNUPGHOME" "$PHP_FILENAME.asc" \ + && mkdir -p /usr/src \ + && tar -Jxf "$PHP_FILENAME" -C /usr/src \ + && mv "/usr/src/php-$PHP_VERSION" /usr/src/php \ + && rm "$PHP_FILENAME" \ + && cd /usr/src/php \ + && ./configure \ + --with-config-file-path="$PHP_INI_DIR" \ + --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \ + $PHP_EXTRA_CONFIGURE_ARGS \ + --disable-cgi \ +# --enable-mysqlnd is included here because it's harder to compile after the fact than extensions are (since it's a plugin for several extensions, not an extension in itself) + --enable-mysqlnd \ + --with-curl \ + --with-libedit \ + --with-openssl \ + --with-zlib \ + && make -j"$(getconf _NPROCESSORS_ONLN)" \ + && make install \ + && { find /usr/local/bin /usr/local/sbin -type f -perm +0111 -exec strip --strip-all '{}' + || true; } \ + && make clean \ + && runDeps="$( \ + scanelf --needed --nobanner --recursive /usr/local \ + | awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \ + | sort -u \ + | xargs -r apk info --installed \ + | sort -u \ + )" \ + && apk add --virtual .php-rundeps $runDeps \ + && apk del .build-deps + +COPY docker-php-ext-* /usr/local/bin/ + +#### +WORKDIR /var/www/html + +RUN set -ex \ + && cd /usr/local/etc \ + && if [ -d php-fpm.d ]; then \ + # for some reason, upstream's php-fpm.conf.default has "include=NONE/etc/php-fpm.d/*.conf" + sed 's!=NONE/!=!g' php-fpm.conf.default | tee php-fpm.conf > /dev/null; \ + cp php-fpm.d/www.conf.default php-fpm.d/www.conf; \ + else \ + # PHP 5.x don't use "include=" by default, so we'll create our own simple config that mimics PHP 7+ for consistency + mkdir php-fpm.d; \ + cp php-fpm.conf.default php-fpm.d/www.conf; \ + { \ + echo '[global]'; \ + echo 'include=etc/php-fpm.d/*.conf'; \ + } | tee php-fpm.conf; \ + fi \ + && { \ + echo '[global]'; \ + echo 'error_log = /proc/self/fd/2'; \ + echo; \ + echo '[www]'; \ + echo '; if we send this to /proc/self/fd/1, it never appears'; \ + echo 'access.log = /proc/self/fd/2'; \ + echo; \ + echo 'clear_env = no'; \ + echo; \ + echo '; Ensure worker stdout and stderr are sent to the main error log.'; \ + echo 'catch_workers_output = yes'; \ + } | tee php-fpm.d/docker.conf \ + && { \ + echo '[global]'; \ + echo 'daemonize = no'; \ + echo; \ + echo '[www]'; \ + echo 'listen = [::]:9000'; \ + } | tee php-fpm.d/zz-docker.conf + +EXPOSE 9000 +CMD ["php-fpm"] +#### diff --git a/5.5/fpm/alpine/docker-php-ext-configure b/5.5/fpm/alpine/docker-php-ext-configure new file mode 100755 index 00000000..39947c8f --- /dev/null +++ b/5.5/fpm/alpine/docker-php-ext-configure @@ -0,0 +1,19 @@ +#!/bin/sh +set -e + +ext="$1" +extDir="/usr/src/php/ext/$ext" +if [ -z "$ext" ] || ! [ -d "$extDir" ]; then + echo >&2 "usage: $0 ext-name [configure flags]" + echo >&2 " ie: $0 gd --with-jpeg-dir=/usr/local/something" + echo >&2 + echo >&2 'Possible values for ext-name:' + echo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort) + exit 1 +fi +shift + +set -x +cd "$extDir" +phpize +./configure "$@" diff --git a/5.5/fpm/alpine/docker-php-ext-enable b/5.5/fpm/alpine/docker-php-ext-enable new file mode 100755 index 00000000..367aaf2b --- /dev/null +++ b/5.5/fpm/alpine/docker-php-ext-enable @@ -0,0 +1,83 @@ +#!/bin/sh +set -e + +cd "$(php -r 'echo ini_get("extension_dir");')" + +usage() { + echo "usage: $0 [options] module-name [module-name ...]" + echo " ie: $0 gd mysqli" + echo " $0 pdo pdo_mysql" + echo " $0 --ini-name 0-apc.ini apcu apc" + echo + echo 'Possible values for module-name:' + echo $(find -maxdepth 1 -type f -name '*.so' -exec basename '{}' ';' | sort) +} + +opts="$(getopt -o 'h?' --long 'help,ini-name:' -- "$@" || { usage >&2 && false; })" +eval set -- "$opts" + +iniName= +while true; do + flag="$1" + shift + case "$flag" in + --help|-h|'-?') usage && exit 0 ;; + --ini-name) iniName="$1" && shift ;; + --) break ;; + *) + { + echo "error: unknown flag: $flag" + usage + } >&2 + exit 1 + ;; + esac +done + +modules= +for module; do + if [ -z "$module" ]; then + continue + fi + if [ -f "$module.so" ] && ! [ -f "$module" ]; then + # allow ".so" to be optional + module="$module.so" + fi + if ! [ -f "$module" ]; then + echo >&2 "error: $(readlink -f "$module") does not exist" + echo >&2 + usage >&2 + exit 1 + fi + modules="$modules $module" +done + +if [ -z "$modules" ]; then + usage >&2 + exit 1 +fi + +for module in $modules; do + if nm -g "$module" | grep -q ' zend_extension_entry$'; then + # https://wiki.php.net/internals/extensions#loading_zend_extensions + line="zend_extension=$(readlink -f "$module")" + else + line="extension=$module" + fi + + ext="$(basename "$module")" + ext="${ext%.*}" + if php -r 'exit(extension_loaded("'"$ext"'") ? 0 : 1);'; then + # this isn't perfect, but it's better than nothing + # (for example, 'opcache.so' presents inside PHP as 'Zend OPcache', not 'opcache') + echo >&2 + echo >&2 "warning: $ext ($module) is already loaded!" + echo >&2 + continue + fi + + ini="/usr/local/etc/php/conf.d/${iniName:-"docker-php-ext-$ext.ini"}" + if ! grep -q "$line" "$ini" 2>/dev/null; then + echo "$line" >> "$ini" + fi +done diff --git a/5.5/fpm/alpine/docker-php-ext-install b/5.5/fpm/alpine/docker-php-ext-install new file mode 100755 index 00000000..67180a86 --- /dev/null +++ b/5.5/fpm/alpine/docker-php-ext-install @@ -0,0 +1,71 @@ +#!/bin/sh +set -e + +cd /usr/src/php/ext + +usage() { + echo "usage: $0 [-jN] ext-name [ext-name ...]" + echo " ie: $0 gd mysqli" + echo " $0 pdo pdo_mysql" + echo " $0 -j5 gd mbstring mysqli pdo pdo_mysql shmop" + echo + echo 'if custom ./configure arguments are necessary, see docker-php-ext-configure' + echo + echo 'Possible values for ext-name:' + echo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort) +} + +opts="$(getopt -o 'h?j:' --long 'help,jobs:' -- "$@" || { usage >&2 && false; })" +eval set -- "$opts" + +j=1 +while true; do + flag="$1" + shift + case "$flag" in + --help|-h|'-?') usage && exit 0 ;; + --jobs|-j) j="$1" && shift ;; + --) break ;; + *) + { + echo "error: unknown flag: $flag" + usage + } >&2 + exit 1 + ;; + esac +done + +exts= +for ext; do + if [ -z "$ext" ]; then + continue + fi + if [ ! -d "$ext" ]; then + echo >&2 "error: $(pwd -P)/$ext does not exist" + echo >&2 + usage >&2 + exit 1 + fi + exts="$exts $ext" +done + +if [ -z "$exts" ]; then + usage >&2 + exit 1 +fi + +for ext in $exts; do + ( + cd "$ext" + [ -e Makefile ] || docker-php-ext-configure "$ext" + make -j"$j" + make -j"$j" install + find modules \ + -maxdepth 1 \ + -name '*.so' \ + -exec basename '{}' ';' \ + | xargs -r docker-php-ext-enable + make -j"$j" clean + ) +done diff --git a/5.5/fpm/docker-php-ext-configure b/5.5/fpm/docker-php-ext-configure index 3d21b5bb..39947c8f 100755 --- a/5.5/fpm/docker-php-ext-configure +++ b/5.5/fpm/docker-php-ext-configure @@ -1,9 +1,9 @@ -#!/bin/bash +#!/bin/sh set -e ext="$1" extDir="/usr/src/php/ext/$ext" -if [ -z "$ext" -o ! -d "$extDir" ]; then +if [ -z "$ext" ] || ! [ -d "$extDir" ]; then echo >&2 "usage: $0 ext-name [configure flags]" echo >&2 " ie: $0 gd --with-jpeg-dir=/usr/local/something" echo >&2 diff --git a/5.5/fpm/docker-php-ext-enable b/5.5/fpm/docker-php-ext-enable index edb07ed8..367aaf2b 100755 --- a/5.5/fpm/docker-php-ext-enable +++ b/5.5/fpm/docker-php-ext-enable @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -e cd "$(php -r 'echo ini_get("extension_dir");')" @@ -34,32 +34,30 @@ while true; do esac done -modules=() -while [ $# -gt 0 ]; do - module="$1" - shift +modules= +for module; do if [ -z "$module" ]; then continue fi - if [ -f "$module.so" -a ! -f "$module" ]; then + if [ -f "$module.so" ] && ! [ -f "$module" ]; then # allow ".so" to be optional - module+='.so' + module="$module.so" fi - if [ ! -f "$module" ]; then + if ! [ -f "$module" ]; then echo >&2 "error: $(readlink -f "$module") does not exist" echo >&2 usage >&2 exit 1 fi - modules+=( "$module" ) + modules="$modules $module" done -if [ "${#modules[@]}" -eq 0 ]; then +if [ -z "$modules" ]; then usage >&2 exit 1 fi -for module in "${modules[@]}"; do +for module in $modules; do if nm -g "$module" | grep -q ' zend_extension_entry$'; then # https://wiki.php.net/internals/extensions#loading_zend_extensions line="zend_extension=$(readlink -f "$module")" diff --git a/5.5/fpm/docker-php-ext-install b/5.5/fpm/docker-php-ext-install index 2c488cce..67180a86 100755 --- a/5.5/fpm/docker-php-ext-install +++ b/5.5/fpm/docker-php-ext-install @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -e cd /usr/src/php/ext @@ -36,10 +36,8 @@ while true; do esac done -exts=() -while [ $# -gt 0 ]; do - ext="$1" - shift +exts= +for ext; do if [ -z "$ext" ]; then continue fi @@ -49,21 +47,25 @@ while [ $# -gt 0 ]; do usage >&2 exit 1 fi - exts+=( "$ext" ) + exts="$exts $ext" done -if [ "${#exts[@]}" -eq 0 ]; then +if [ -z "$exts" ]; then usage >&2 exit 1 fi -for ext in "${exts[@]}"; do +for ext in $exts; do ( cd "$ext" [ -e Makefile ] || docker-php-ext-configure "$ext" make -j"$j" make -j"$j" install - find modules -maxdepth 1 -name '*.so' -exec basename '{}' ';' | xargs --no-run-if-empty --verbose docker-php-ext-enable + find modules \ + -maxdepth 1 \ + -name '*.so' \ + -exec basename '{}' ';' \ + | xargs -r docker-php-ext-enable make -j"$j" clean ) done diff --git a/5.5/zts/Dockerfile b/5.5/zts/Dockerfile index ed13a814..42981dc7 100644 --- a/5.5/zts/Dockerfile +++ b/5.5/zts/Dockerfile @@ -1,10 +1,25 @@ FROM debian:jessie -# persistent / runtime deps -RUN apt-get update && apt-get install -y ca-certificates curl librecode0 libsqlite3-0 libxml2 --no-install-recommends && rm -r /var/lib/apt/lists/* - # phpize deps -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/* +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/* + +# persistent / runtime deps +RUN apt-get update && apt-get install -y \ + ca-certificates \ + curl \ + libedit2 \ + libsqlite3-0 \ + libxml2 \ + --no-install-recommends && rm -r /var/lib/apt/lists/* ENV PHP_INI_DIR /usr/local/etc/php RUN mkdir -p $PHP_INI_DIR/conf.d @@ -14,52 +29,51 @@ ENV PHP_EXTRA_CONFIGURE_ARGS --enable-maintainer-zts #### ENV GPG_KEYS 0B96609E270F565C13292B24C13C70B87267B52D 0BD78B5F97500D450838F95DFE857D9A90D90EC1 F38252826ACD957EF380D39F2F7956BC5DA04B5D -RUN set -xe \ - && for key in $GPG_KEYS; do \ - gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ - done ENV PHP_VERSION 5.5.33 ENV PHP_FILENAME php-5.5.33.tar.xz ENV PHP_SHA256 b91dbd3c53f9895e8f7b29e5fed25a64dd3a76b454f6ef7265e73c96b4303f30 -# --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) -RUN buildDeps=" \ +RUN set -xe \ + && buildDeps=" \ $PHP_EXTRA_BUILD_DEPS \ libcurl4-openssl-dev \ - libreadline6-dev \ - librecode-dev \ + libedit-dev \ libsqlite3-dev \ libssl-dev \ libxml2-dev \ xz-utils \ " \ - && set -x \ && apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \ && curl -fSL "http://php.net/get/$PHP_FILENAME/from/this/mirror" -o "$PHP_FILENAME" \ && echo "$PHP_SHA256 *$PHP_FILENAME" | sha256sum -c - \ && curl -fSL "http://php.net/get/$PHP_FILENAME.asc/from/this/mirror" -o "$PHP_FILENAME.asc" \ + && export GNUPGHOME="$(mktemp -d)" \ + && for key in $GPG_KEYS; do \ + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ + done \ && gpg --batch --verify "$PHP_FILENAME.asc" "$PHP_FILENAME" \ + && rm -r "$GNUPGHOME" "$PHP_FILENAME.asc" \ && mkdir -p /usr/src/php \ && tar -xf "$PHP_FILENAME" -C /usr/src/php --strip-components=1 \ - && rm "$PHP_FILENAME"* \ + && rm "$PHP_FILENAME" \ && cd /usr/src/php \ && ./configure \ --with-config-file-path="$PHP_INI_DIR" \ --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \ $PHP_EXTRA_CONFIGURE_ARGS \ --disable-cgi \ +# --enable-mysqlnd is included here because it's harder to compile after the fact than extensions are (since it's a plugin for several extensions, not an extension in itself) --enable-mysqlnd \ --with-curl \ + --with-libedit \ --with-openssl \ - --with-readline \ - --with-recode \ --with-zlib \ && make -j"$(nproc)" \ && make install \ && { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \ - && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps \ - && make clean + && make clean \ + && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps COPY docker-php-ext-* /usr/local/bin/ diff --git a/5.5/zts/alpine/Dockerfile b/5.5/zts/alpine/Dockerfile new file mode 100644 index 00000000..29d747ca --- /dev/null +++ b/5.5/zts/alpine/Dockerfile @@ -0,0 +1,92 @@ +FROM alpine:3.3 + +# phpize deps +RUN apk add --no-cache --virtual .phpize-deps \ + autoconf \ + file \ + g++ \ + gcc \ + libc-dev \ + make \ + pkgconf \ + re2c + +# persistent / runtime deps +RUN apk add --no-cache --virtual .persistent-deps \ + ca-certificates \ + curl + +# ensure www-data user exists +RUN set -x \ + && addgroup -g 82 -S www-data \ + && adduser -u 82 -D -S -G www-data www-data +# 82 is the standard uid/gid for "www-data" in Alpine +# http://git.alpinelinux.org/cgit/aports/tree/main/apache2/apache2.pre-install?h=v3.3.2 +# http://git.alpinelinux.org/cgit/aports/tree/main/lighttpd/lighttpd.pre-install?h=v3.3.2 +# http://git.alpinelinux.org/cgit/aports/tree/main/nginx-initscripts/nginx-initscripts.pre-install?h=v3.3.2 + +ENV PHP_INI_DIR /usr/local/etc/php +RUN mkdir -p $PHP_INI_DIR/conf.d + +#### +ENV PHP_EXTRA_CONFIGURE_ARGS --enable-maintainer-zts +#### + +ENV GPG_KEYS 0B96609E270F565C13292B24C13C70B87267B52D 0BD78B5F97500D450838F95DFE857D9A90D90EC1 F38252826ACD957EF380D39F2F7956BC5DA04B5D + +ENV PHP_VERSION 5.5.33 +ENV PHP_FILENAME php-5.5.33.tar.xz +ENV PHP_SHA256 b91dbd3c53f9895e8f7b29e5fed25a64dd3a76b454f6ef7265e73c96b4303f30 + +RUN set -xe \ + && apk add --no-cache --virtual .build-deps \ + curl-dev \ + gnupg \ + libedit-dev \ + libxml2-dev \ + openssl-dev \ + sqlite-dev \ + && curl -fSL "http://php.net/get/$PHP_FILENAME/from/this/mirror" -o "$PHP_FILENAME" \ + && echo "$PHP_SHA256 *$PHP_FILENAME" | sha256sum -c - \ + && curl -fSL "http://php.net/get/$PHP_FILENAME.asc/from/this/mirror" -o "$PHP_FILENAME.asc" \ + && export GNUPGHOME="$(mktemp -d)" \ + && for key in $GPG_KEYS; do \ + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ + done \ + && gpg --batch --verify "$PHP_FILENAME.asc" "$PHP_FILENAME" \ + && rm -r "$GNUPGHOME" "$PHP_FILENAME.asc" \ + && mkdir -p /usr/src \ + && tar -Jxf "$PHP_FILENAME" -C /usr/src \ + && mv "/usr/src/php-$PHP_VERSION" /usr/src/php \ + && rm "$PHP_FILENAME" \ + && cd /usr/src/php \ + && ./configure \ + --with-config-file-path="$PHP_INI_DIR" \ + --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \ + $PHP_EXTRA_CONFIGURE_ARGS \ + --disable-cgi \ +# --enable-mysqlnd is included here because it's harder to compile after the fact than extensions are (since it's a plugin for several extensions, not an extension in itself) + --enable-mysqlnd \ + --with-curl \ + --with-libedit \ + --with-openssl \ + --with-zlib \ + && make -j"$(getconf _NPROCESSORS_ONLN)" \ + && make install \ + && { find /usr/local/bin /usr/local/sbin -type f -perm +0111 -exec strip --strip-all '{}' + || true; } \ + && make clean \ + && runDeps="$( \ + scanelf --needed --nobanner --recursive /usr/local \ + | awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \ + | sort -u \ + | xargs -r apk info --installed \ + | sort -u \ + )" \ + && apk add --virtual .php-rundeps $runDeps \ + && apk del .build-deps + +COPY docker-php-ext-* /usr/local/bin/ + +#### +CMD ["php", "-a"] +#### diff --git a/5.5/zts/alpine/docker-php-ext-configure b/5.5/zts/alpine/docker-php-ext-configure new file mode 100755 index 00000000..39947c8f --- /dev/null +++ b/5.5/zts/alpine/docker-php-ext-configure @@ -0,0 +1,19 @@ +#!/bin/sh +set -e + +ext="$1" +extDir="/usr/src/php/ext/$ext" +if [ -z "$ext" ] || ! [ -d "$extDir" ]; then + echo >&2 "usage: $0 ext-name [configure flags]" + echo >&2 " ie: $0 gd --with-jpeg-dir=/usr/local/something" + echo >&2 + echo >&2 'Possible values for ext-name:' + echo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort) + exit 1 +fi +shift + +set -x +cd "$extDir" +phpize +./configure "$@" diff --git a/5.5/zts/alpine/docker-php-ext-enable b/5.5/zts/alpine/docker-php-ext-enable new file mode 100755 index 00000000..367aaf2b --- /dev/null +++ b/5.5/zts/alpine/docker-php-ext-enable @@ -0,0 +1,83 @@ +#!/bin/sh +set -e + +cd "$(php -r 'echo ini_get("extension_dir");')" + +usage() { + echo "usage: $0 [options] module-name [module-name ...]" + echo " ie: $0 gd mysqli" + echo " $0 pdo pdo_mysql" + echo " $0 --ini-name 0-apc.ini apcu apc" + echo + echo 'Possible values for module-name:' + echo $(find -maxdepth 1 -type f -name '*.so' -exec basename '{}' ';' | sort) +} + +opts="$(getopt -o 'h?' --long 'help,ini-name:' -- "$@" || { usage >&2 && false; })" +eval set -- "$opts" + +iniName= +while true; do + flag="$1" + shift + case "$flag" in + --help|-h|'-?') usage && exit 0 ;; + --ini-name) iniName="$1" && shift ;; + --) break ;; + *) + { + echo "error: unknown flag: $flag" + usage + } >&2 + exit 1 + ;; + esac +done + +modules= +for module; do + if [ -z "$module" ]; then + continue + fi + if [ -f "$module.so" ] && ! [ -f "$module" ]; then + # allow ".so" to be optional + module="$module.so" + fi + if ! [ -f "$module" ]; then + echo >&2 "error: $(readlink -f "$module") does not exist" + echo >&2 + usage >&2 + exit 1 + fi + modules="$modules $module" +done + +if [ -z "$modules" ]; then + usage >&2 + exit 1 +fi + +for module in $modules; do + if nm -g "$module" | grep -q ' zend_extension_entry$'; then + # https://wiki.php.net/internals/extensions#loading_zend_extensions + line="zend_extension=$(readlink -f "$module")" + else + line="extension=$module" + fi + + ext="$(basename "$module")" + ext="${ext%.*}" + if php -r 'exit(extension_loaded("'"$ext"'") ? 0 : 1);'; then + # this isn't perfect, but it's better than nothing + # (for example, 'opcache.so' presents inside PHP as 'Zend OPcache', not 'opcache') + echo >&2 + echo >&2 "warning: $ext ($module) is already loaded!" + echo >&2 + continue + fi + + ini="/usr/local/etc/php/conf.d/${iniName:-"docker-php-ext-$ext.ini"}" + if ! grep -q "$line" "$ini" 2>/dev/null; then + echo "$line" >> "$ini" + fi +done diff --git a/5.5/zts/alpine/docker-php-ext-install b/5.5/zts/alpine/docker-php-ext-install new file mode 100755 index 00000000..67180a86 --- /dev/null +++ b/5.5/zts/alpine/docker-php-ext-install @@ -0,0 +1,71 @@ +#!/bin/sh +set -e + +cd /usr/src/php/ext + +usage() { + echo "usage: $0 [-jN] ext-name [ext-name ...]" + echo " ie: $0 gd mysqli" + echo " $0 pdo pdo_mysql" + echo " $0 -j5 gd mbstring mysqli pdo pdo_mysql shmop" + echo + echo 'if custom ./configure arguments are necessary, see docker-php-ext-configure' + echo + echo 'Possible values for ext-name:' + echo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort) +} + +opts="$(getopt -o 'h?j:' --long 'help,jobs:' -- "$@" || { usage >&2 && false; })" +eval set -- "$opts" + +j=1 +while true; do + flag="$1" + shift + case "$flag" in + --help|-h|'-?') usage && exit 0 ;; + --jobs|-j) j="$1" && shift ;; + --) break ;; + *) + { + echo "error: unknown flag: $flag" + usage + } >&2 + exit 1 + ;; + esac +done + +exts= +for ext; do + if [ -z "$ext" ]; then + continue + fi + if [ ! -d "$ext" ]; then + echo >&2 "error: $(pwd -P)/$ext does not exist" + echo >&2 + usage >&2 + exit 1 + fi + exts="$exts $ext" +done + +if [ -z "$exts" ]; then + usage >&2 + exit 1 +fi + +for ext in $exts; do + ( + cd "$ext" + [ -e Makefile ] || docker-php-ext-configure "$ext" + make -j"$j" + make -j"$j" install + find modules \ + -maxdepth 1 \ + -name '*.so' \ + -exec basename '{}' ';' \ + | xargs -r docker-php-ext-enable + make -j"$j" clean + ) +done diff --git a/5.5/zts/docker-php-ext-configure b/5.5/zts/docker-php-ext-configure index 3d21b5bb..39947c8f 100755 --- a/5.5/zts/docker-php-ext-configure +++ b/5.5/zts/docker-php-ext-configure @@ -1,9 +1,9 @@ -#!/bin/bash +#!/bin/sh set -e ext="$1" extDir="/usr/src/php/ext/$ext" -if [ -z "$ext" -o ! -d "$extDir" ]; then +if [ -z "$ext" ] || ! [ -d "$extDir" ]; then echo >&2 "usage: $0 ext-name [configure flags]" echo >&2 " ie: $0 gd --with-jpeg-dir=/usr/local/something" echo >&2 diff --git a/5.5/zts/docker-php-ext-enable b/5.5/zts/docker-php-ext-enable index edb07ed8..367aaf2b 100755 --- a/5.5/zts/docker-php-ext-enable +++ b/5.5/zts/docker-php-ext-enable @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -e cd "$(php -r 'echo ini_get("extension_dir");')" @@ -34,32 +34,30 @@ while true; do esac done -modules=() -while [ $# -gt 0 ]; do - module="$1" - shift +modules= +for module; do if [ -z "$module" ]; then continue fi - if [ -f "$module.so" -a ! -f "$module" ]; then + if [ -f "$module.so" ] && ! [ -f "$module" ]; then # allow ".so" to be optional - module+='.so' + module="$module.so" fi - if [ ! -f "$module" ]; then + if ! [ -f "$module" ]; then echo >&2 "error: $(readlink -f "$module") does not exist" echo >&2 usage >&2 exit 1 fi - modules+=( "$module" ) + modules="$modules $module" done -if [ "${#modules[@]}" -eq 0 ]; then +if [ -z "$modules" ]; then usage >&2 exit 1 fi -for module in "${modules[@]}"; do +for module in $modules; do if nm -g "$module" | grep -q ' zend_extension_entry$'; then # https://wiki.php.net/internals/extensions#loading_zend_extensions line="zend_extension=$(readlink -f "$module")" diff --git a/5.5/zts/docker-php-ext-install b/5.5/zts/docker-php-ext-install index 2c488cce..67180a86 100755 --- a/5.5/zts/docker-php-ext-install +++ b/5.5/zts/docker-php-ext-install @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -e cd /usr/src/php/ext @@ -36,10 +36,8 @@ while true; do esac done -exts=() -while [ $# -gt 0 ]; do - ext="$1" - shift +exts= +for ext; do if [ -z "$ext" ]; then continue fi @@ -49,21 +47,25 @@ while [ $# -gt 0 ]; do usage >&2 exit 1 fi - exts+=( "$ext" ) + exts="$exts $ext" done -if [ "${#exts[@]}" -eq 0 ]; then +if [ -z "$exts" ]; then usage >&2 exit 1 fi -for ext in "${exts[@]}"; do +for ext in $exts; do ( cd "$ext" [ -e Makefile ] || docker-php-ext-configure "$ext" make -j"$j" make -j"$j" install - find modules -maxdepth 1 -name '*.so' -exec basename '{}' ';' | xargs --no-run-if-empty --verbose docker-php-ext-enable + find modules \ + -maxdepth 1 \ + -name '*.so' \ + -exec basename '{}' ';' \ + | xargs -r docker-php-ext-enable make -j"$j" clean ) done diff --git a/5.6/Dockerfile b/5.6/Dockerfile index ebed6328..d3ff994f 100644 --- a/5.6/Dockerfile +++ b/5.6/Dockerfile @@ -1,10 +1,25 @@ FROM debian:jessie -# persistent / runtime deps -RUN apt-get update && apt-get install -y ca-certificates curl librecode0 libsqlite3-0 libxml2 --no-install-recommends && rm -r /var/lib/apt/lists/* - # phpize deps -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/* +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/* + +# persistent / runtime deps +RUN apt-get update && apt-get install -y \ + ca-certificates \ + curl \ + libedit2 \ + libsqlite3-0 \ + libxml2 \ + --no-install-recommends && rm -r /var/lib/apt/lists/* ENV PHP_INI_DIR /usr/local/etc/php RUN mkdir -p $PHP_INI_DIR/conf.d @@ -13,52 +28,51 @@ RUN mkdir -p $PHP_INI_DIR/conf.d #### ENV GPG_KEYS 0BD78B5F97500D450838F95DFE857D9A90D90EC1 6E4F6AB321FDC07F2C332E3AC2BF0BC433CFC8B3 -RUN set -xe \ - && for key in $GPG_KEYS; do \ - gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ - done ENV PHP_VERSION 5.6.19 ENV PHP_FILENAME php-5.6.19.tar.xz ENV PHP_SHA256 bb32337f93a00b71789f116bddafa8848139120e7fb6f4f98a84f52dbcb8329f -# --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) -RUN buildDeps=" \ +RUN set -xe \ + && buildDeps=" \ $PHP_EXTRA_BUILD_DEPS \ libcurl4-openssl-dev \ - libreadline6-dev \ - librecode-dev \ + libedit-dev \ libsqlite3-dev \ libssl-dev \ libxml2-dev \ xz-utils \ " \ - && set -x \ && apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \ && curl -fSL "http://php.net/get/$PHP_FILENAME/from/this/mirror" -o "$PHP_FILENAME" \ && echo "$PHP_SHA256 *$PHP_FILENAME" | sha256sum -c - \ && curl -fSL "http://php.net/get/$PHP_FILENAME.asc/from/this/mirror" -o "$PHP_FILENAME.asc" \ + && export GNUPGHOME="$(mktemp -d)" \ + && for key in $GPG_KEYS; do \ + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ + done \ && gpg --batch --verify "$PHP_FILENAME.asc" "$PHP_FILENAME" \ + && rm -r "$GNUPGHOME" "$PHP_FILENAME.asc" \ && mkdir -p /usr/src/php \ && tar -xf "$PHP_FILENAME" -C /usr/src/php --strip-components=1 \ - && rm "$PHP_FILENAME"* \ + && rm "$PHP_FILENAME" \ && cd /usr/src/php \ && ./configure \ --with-config-file-path="$PHP_INI_DIR" \ --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \ $PHP_EXTRA_CONFIGURE_ARGS \ --disable-cgi \ +# --enable-mysqlnd is included here because it's harder to compile after the fact than extensions are (since it's a plugin for several extensions, not an extension in itself) --enable-mysqlnd \ --with-curl \ + --with-libedit \ --with-openssl \ - --with-readline \ - --with-recode \ --with-zlib \ && make -j"$(nproc)" \ && make install \ && { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \ - && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps \ - && make clean + && make clean \ + && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps COPY docker-php-ext-* /usr/local/bin/ diff --git a/5.6/alpine/Dockerfile b/5.6/alpine/Dockerfile index 41f23b29..dac4914d 100644 --- a/5.6/alpine/Dockerfile +++ b/5.6/alpine/Dockerfile @@ -1,53 +1,74 @@ FROM alpine:3.3 +# phpize deps +RUN apk add --no-cache --virtual .phpize-deps \ + autoconf \ + file \ + g++ \ + gcc \ + libc-dev \ + make \ + pkgconf \ + re2c + +# persistent / runtime deps +RUN apk add --no-cache --virtual .persistent-deps \ + ca-certificates \ + curl + +# ensure www-data user exists +RUN set -x \ + && addgroup -g 82 -S www-data \ + && adduser -u 82 -D -S -G www-data www-data +# 82 is the standard uid/gid for "www-data" in Alpine +# http://git.alpinelinux.org/cgit/aports/tree/main/apache2/apache2.pre-install?h=v3.3.2 +# http://git.alpinelinux.org/cgit/aports/tree/main/lighttpd/lighttpd.pre-install?h=v3.3.2 +# http://git.alpinelinux.org/cgit/aports/tree/main/nginx-initscripts/nginx-initscripts.pre-install?h=v3.3.2 + ENV PHP_INI_DIR /usr/local/etc/php RUN mkdir -p $PHP_INI_DIR/conf.d -ENV PHP_VERSION 5.6.19 -ENV PHP_FILENAME php-5.6.19.tar.xz -ENV PHP_SHA256 2a24a3f84971680ac0a4c71050067de4f76ee235aa4a041fae21bfa69975c168 - #### #### -# --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) ENV GPG_KEYS 0BD78B5F97500D450838F95DFE857D9A90D90EC1 6E4F6AB321FDC07F2C332E3AC2BF0BC433CFC8B3 + +ENV PHP_VERSION 5.6.19 +ENV PHP_FILENAME php-5.6.19.tar.xz +ENV PHP_SHA256 bb32337f93a00b71789f116bddafa8848139120e7fb6f4f98a84f52dbcb8329f + RUN set -xe \ && apk add --no-cache --virtual .build-deps \ - autoconf \ curl-dev \ - file \ - gcc \ gnupg \ - libc-dev \ libedit-dev \ libxml2-dev \ - make \ openssl-dev \ - pkgconf \ - re2c \ sqlite-dev \ - && for key in $GPG_KEYS; do \ - gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ - done \ && curl -fSL "http://php.net/get/$PHP_FILENAME/from/this/mirror" -o "$PHP_FILENAME" \ && echo "$PHP_SHA256 *$PHP_FILENAME" | sha256sum -c - \ && curl -fSL "http://php.net/get/$PHP_FILENAME.asc/from/this/mirror" -o "$PHP_FILENAME.asc" \ + && export GNUPGHOME="$(mktemp -d)" \ + && for key in $GPG_KEYS; do \ + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ + done \ && gpg --batch --verify "$PHP_FILENAME.asc" "$PHP_FILENAME" \ + && rm -r "$GNUPGHOME" "$PHP_FILENAME.asc" \ && mkdir -p /usr/src \ && tar -Jxf "$PHP_FILENAME" -C /usr/src \ - && mv /usr/src/php-$PHP_VERSION /usr/src/php \ - && rm "$PHP_FILENAME"* \ + && mv "/usr/src/php-$PHP_VERSION" /usr/src/php \ + && rm "$PHP_FILENAME" \ && cd /usr/src/php \ && ./configure \ --with-config-file-path="$PHP_INI_DIR" \ --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \ $PHP_EXTRA_CONFIGURE_ARGS \ --disable-cgi \ +# --enable-mysqlnd is included here because it's harder to compile after the fact than extensions are (since it's a plugin for several extensions, not an extension in itself) --enable-mysqlnd \ --with-curl \ - --with-openssl \ --with-libedit \ + --with-openssl \ --with-zlib \ && make -j"$(getconf _NPROCESSORS_ONLN)" \ && make install \ diff --git a/5.6/alpine/docker-php-ext-enable b/5.6/alpine/docker-php-ext-enable index 5381d0d0..367aaf2b 100755 --- a/5.6/alpine/docker-php-ext-enable +++ b/5.6/alpine/docker-php-ext-enable @@ -4,15 +4,37 @@ set -e cd "$(php -r 'echo ini_get("extension_dir");')" usage() { - echo "usage: $0 module-name [module-name ...]" + echo "usage: $0 [options] module-name [module-name ...]" echo " ie: $0 gd mysqli" echo " $0 pdo pdo_mysql" + echo " $0 --ini-name 0-apc.ini apcu apc" echo echo 'Possible values for module-name:' echo $(find -maxdepth 1 -type f -name '*.so' -exec basename '{}' ';' | sort) } -modules="" +opts="$(getopt -o 'h?' --long 'help,ini-name:' -- "$@" || { usage >&2 && false; })" +eval set -- "$opts" + +iniName= +while true; do + flag="$1" + shift + case "$flag" in + --help|-h|'-?') usage && exit 0 ;; + --ini-name) iniName="$1" && shift ;; + --) break ;; + *) + { + echo "error: unknown flag: $flag" + usage + } >&2 + exit 1 + ;; + esac +done + +modules= for module; do if [ -z "$module" ]; then continue @@ -35,8 +57,8 @@ if [ -z "$modules" ]; then exit 1 fi -for module in ${modules}; do - if grep -q zend_extension_entry "$module"; then +for module in $modules; do + if nm -g "$module" | grep -q ' zend_extension_entry$'; then # https://wiki.php.net/internals/extensions#loading_zend_extensions line="zend_extension=$(readlink -f "$module")" else @@ -54,7 +76,7 @@ for module in ${modules}; do continue fi - ini="/usr/local/etc/php/conf.d/docker-php-ext-$ext.ini" + ini="/usr/local/etc/php/conf.d/${iniName:-"docker-php-ext-$ext.ini"}" if ! grep -q "$line" "$ini" 2>/dev/null; then echo "$line" >> "$ini" fi diff --git a/5.6/alpine/docker-php-ext-install b/5.6/alpine/docker-php-ext-install index 68309ff9..67180a86 100755 --- a/5.6/alpine/docker-php-ext-install +++ b/5.6/alpine/docker-php-ext-install @@ -61,7 +61,11 @@ for ext in $exts; do [ -e Makefile ] || docker-php-ext-configure "$ext" make -j"$j" make -j"$j" install - ls modules/*.so | cut -d/ -f2 | xargs -r docker-php-ext-enable + find modules \ + -maxdepth 1 \ + -name '*.so' \ + -exec basename '{}' ';' \ + | xargs -r docker-php-ext-enable make -j"$j" clean ) done diff --git a/5.6/apache/Dockerfile b/5.6/apache/Dockerfile index bab1182b..f683e2cf 100644 --- a/5.6/apache/Dockerfile +++ b/5.6/apache/Dockerfile @@ -1,10 +1,25 @@ FROM debian:jessie -# persistent / runtime deps -RUN apt-get update && apt-get install -y ca-certificates curl librecode0 libsqlite3-0 libxml2 --no-install-recommends && rm -r /var/lib/apt/lists/* - # phpize deps -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/* +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/* + +# persistent / runtime deps +RUN apt-get update && apt-get install -y \ + ca-certificates \ + curl \ + libedit2 \ + libsqlite3-0 \ + libxml2 \ + --no-install-recommends && rm -r /var/lib/apt/lists/* ENV PHP_INI_DIR /usr/local/etc/php RUN mkdir -p $PHP_INI_DIR/conf.d @@ -26,52 +41,51 @@ ENV PHP_EXTRA_CONFIGURE_ARGS --with-apxs2 #### ENV GPG_KEYS 0BD78B5F97500D450838F95DFE857D9A90D90EC1 6E4F6AB321FDC07F2C332E3AC2BF0BC433CFC8B3 -RUN set -xe \ - && for key in $GPG_KEYS; do \ - gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ - done ENV PHP_VERSION 5.6.19 ENV PHP_FILENAME php-5.6.19.tar.xz ENV PHP_SHA256 bb32337f93a00b71789f116bddafa8848139120e7fb6f4f98a84f52dbcb8329f -# --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) -RUN buildDeps=" \ +RUN set -xe \ + && buildDeps=" \ $PHP_EXTRA_BUILD_DEPS \ libcurl4-openssl-dev \ - libreadline6-dev \ - librecode-dev \ + libedit-dev \ libsqlite3-dev \ libssl-dev \ libxml2-dev \ xz-utils \ " \ - && set -x \ && apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \ && curl -fSL "http://php.net/get/$PHP_FILENAME/from/this/mirror" -o "$PHP_FILENAME" \ && echo "$PHP_SHA256 *$PHP_FILENAME" | sha256sum -c - \ && curl -fSL "http://php.net/get/$PHP_FILENAME.asc/from/this/mirror" -o "$PHP_FILENAME.asc" \ + && export GNUPGHOME="$(mktemp -d)" \ + && for key in $GPG_KEYS; do \ + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ + done \ && gpg --batch --verify "$PHP_FILENAME.asc" "$PHP_FILENAME" \ + && rm -r "$GNUPGHOME" "$PHP_FILENAME.asc" \ && mkdir -p /usr/src/php \ && tar -xf "$PHP_FILENAME" -C /usr/src/php --strip-components=1 \ - && rm "$PHP_FILENAME"* \ + && rm "$PHP_FILENAME" \ && cd /usr/src/php \ && ./configure \ --with-config-file-path="$PHP_INI_DIR" \ --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \ $PHP_EXTRA_CONFIGURE_ARGS \ --disable-cgi \ +# --enable-mysqlnd is included here because it's harder to compile after the fact than extensions are (since it's a plugin for several extensions, not an extension in itself) --enable-mysqlnd \ --with-curl \ + --with-libedit \ --with-openssl \ - --with-readline \ - --with-recode \ --with-zlib \ && make -j"$(nproc)" \ && make install \ && { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \ - && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps \ - && make clean + && make clean \ + && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps COPY docker-php-ext-* /usr/local/bin/ diff --git a/5.6/apache/docker-php-ext-configure b/5.6/apache/docker-php-ext-configure index 3d21b5bb..39947c8f 100755 --- a/5.6/apache/docker-php-ext-configure +++ b/5.6/apache/docker-php-ext-configure @@ -1,9 +1,9 @@ -#!/bin/bash +#!/bin/sh set -e ext="$1" extDir="/usr/src/php/ext/$ext" -if [ -z "$ext" -o ! -d "$extDir" ]; then +if [ -z "$ext" ] || ! [ -d "$extDir" ]; then echo >&2 "usage: $0 ext-name [configure flags]" echo >&2 " ie: $0 gd --with-jpeg-dir=/usr/local/something" echo >&2 diff --git a/5.6/apache/docker-php-ext-enable b/5.6/apache/docker-php-ext-enable index edb07ed8..367aaf2b 100755 --- a/5.6/apache/docker-php-ext-enable +++ b/5.6/apache/docker-php-ext-enable @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -e cd "$(php -r 'echo ini_get("extension_dir");')" @@ -34,32 +34,30 @@ while true; do esac done -modules=() -while [ $# -gt 0 ]; do - module="$1" - shift +modules= +for module; do if [ -z "$module" ]; then continue fi - if [ -f "$module.so" -a ! -f "$module" ]; then + if [ -f "$module.so" ] && ! [ -f "$module" ]; then # allow ".so" to be optional - module+='.so' + module="$module.so" fi - if [ ! -f "$module" ]; then + if ! [ -f "$module" ]; then echo >&2 "error: $(readlink -f "$module") does not exist" echo >&2 usage >&2 exit 1 fi - modules+=( "$module" ) + modules="$modules $module" done -if [ "${#modules[@]}" -eq 0 ]; then +if [ -z "$modules" ]; then usage >&2 exit 1 fi -for module in "${modules[@]}"; do +for module in $modules; do if nm -g "$module" | grep -q ' zend_extension_entry$'; then # https://wiki.php.net/internals/extensions#loading_zend_extensions line="zend_extension=$(readlink -f "$module")" diff --git a/5.6/apache/docker-php-ext-install b/5.6/apache/docker-php-ext-install index 2c488cce..67180a86 100755 --- a/5.6/apache/docker-php-ext-install +++ b/5.6/apache/docker-php-ext-install @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -e cd /usr/src/php/ext @@ -36,10 +36,8 @@ while true; do esac done -exts=() -while [ $# -gt 0 ]; do - ext="$1" - shift +exts= +for ext; do if [ -z "$ext" ]; then continue fi @@ -49,21 +47,25 @@ while [ $# -gt 0 ]; do usage >&2 exit 1 fi - exts+=( "$ext" ) + exts="$exts $ext" done -if [ "${#exts[@]}" -eq 0 ]; then +if [ -z "$exts" ]; then usage >&2 exit 1 fi -for ext in "${exts[@]}"; do +for ext in $exts; do ( cd "$ext" [ -e Makefile ] || docker-php-ext-configure "$ext" make -j"$j" make -j"$j" install - find modules -maxdepth 1 -name '*.so' -exec basename '{}' ';' | xargs --no-run-if-empty --verbose docker-php-ext-enable + find modules \ + -maxdepth 1 \ + -name '*.so' \ + -exec basename '{}' ';' \ + | xargs -r docker-php-ext-enable make -j"$j" clean ) done diff --git a/5.6/docker-php-ext-configure b/5.6/docker-php-ext-configure index 3d21b5bb..39947c8f 100755 --- a/5.6/docker-php-ext-configure +++ b/5.6/docker-php-ext-configure @@ -1,9 +1,9 @@ -#!/bin/bash +#!/bin/sh set -e ext="$1" extDir="/usr/src/php/ext/$ext" -if [ -z "$ext" -o ! -d "$extDir" ]; then +if [ -z "$ext" ] || ! [ -d "$extDir" ]; then echo >&2 "usage: $0 ext-name [configure flags]" echo >&2 " ie: $0 gd --with-jpeg-dir=/usr/local/something" echo >&2 diff --git a/5.6/docker-php-ext-enable b/5.6/docker-php-ext-enable index edb07ed8..367aaf2b 100755 --- a/5.6/docker-php-ext-enable +++ b/5.6/docker-php-ext-enable @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -e cd "$(php -r 'echo ini_get("extension_dir");')" @@ -34,32 +34,30 @@ while true; do esac done -modules=() -while [ $# -gt 0 ]; do - module="$1" - shift +modules= +for module; do if [ -z "$module" ]; then continue fi - if [ -f "$module.so" -a ! -f "$module" ]; then + if [ -f "$module.so" ] && ! [ -f "$module" ]; then # allow ".so" to be optional - module+='.so' + module="$module.so" fi - if [ ! -f "$module" ]; then + if ! [ -f "$module" ]; then echo >&2 "error: $(readlink -f "$module") does not exist" echo >&2 usage >&2 exit 1 fi - modules+=( "$module" ) + modules="$modules $module" done -if [ "${#modules[@]}" -eq 0 ]; then +if [ -z "$modules" ]; then usage >&2 exit 1 fi -for module in "${modules[@]}"; do +for module in $modules; do if nm -g "$module" | grep -q ' zend_extension_entry$'; then # https://wiki.php.net/internals/extensions#loading_zend_extensions line="zend_extension=$(readlink -f "$module")" diff --git a/5.6/docker-php-ext-install b/5.6/docker-php-ext-install index 2c488cce..67180a86 100755 --- a/5.6/docker-php-ext-install +++ b/5.6/docker-php-ext-install @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -e cd /usr/src/php/ext @@ -36,10 +36,8 @@ while true; do esac done -exts=() -while [ $# -gt 0 ]; do - ext="$1" - shift +exts= +for ext; do if [ -z "$ext" ]; then continue fi @@ -49,21 +47,25 @@ while [ $# -gt 0 ]; do usage >&2 exit 1 fi - exts+=( "$ext" ) + exts="$exts $ext" done -if [ "${#exts[@]}" -eq 0 ]; then +if [ -z "$exts" ]; then usage >&2 exit 1 fi -for ext in "${exts[@]}"; do +for ext in $exts; do ( cd "$ext" [ -e Makefile ] || docker-php-ext-configure "$ext" make -j"$j" make -j"$j" install - find modules -maxdepth 1 -name '*.so' -exec basename '{}' ';' | xargs --no-run-if-empty --verbose docker-php-ext-enable + find modules \ + -maxdepth 1 \ + -name '*.so' \ + -exec basename '{}' ';' \ + | xargs -r docker-php-ext-enable make -j"$j" clean ) done diff --git a/5.6/fpm/Dockerfile b/5.6/fpm/Dockerfile index d15614a8..eee61765 100644 --- a/5.6/fpm/Dockerfile +++ b/5.6/fpm/Dockerfile @@ -1,10 +1,25 @@ FROM debian:jessie -# persistent / runtime deps -RUN apt-get update && apt-get install -y ca-certificates curl librecode0 libsqlite3-0 libxml2 --no-install-recommends && rm -r /var/lib/apt/lists/* - # phpize deps -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/* +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/* + +# persistent / runtime deps +RUN apt-get update && apt-get install -y \ + ca-certificates \ + curl \ + libedit2 \ + libsqlite3-0 \ + libxml2 \ + --no-install-recommends && rm -r /var/lib/apt/lists/* ENV PHP_INI_DIR /usr/local/etc/php RUN mkdir -p $PHP_INI_DIR/conf.d @@ -14,52 +29,51 @@ ENV PHP_EXTRA_CONFIGURE_ARGS --enable-fpm --with-fpm-user=www-data --with-fpm-gr #### ENV GPG_KEYS 0BD78B5F97500D450838F95DFE857D9A90D90EC1 6E4F6AB321FDC07F2C332E3AC2BF0BC433CFC8B3 -RUN set -xe \ - && for key in $GPG_KEYS; do \ - gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ - done ENV PHP_VERSION 5.6.19 ENV PHP_FILENAME php-5.6.19.tar.xz ENV PHP_SHA256 bb32337f93a00b71789f116bddafa8848139120e7fb6f4f98a84f52dbcb8329f -# --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) -RUN buildDeps=" \ +RUN set -xe \ + && buildDeps=" \ $PHP_EXTRA_BUILD_DEPS \ libcurl4-openssl-dev \ - libreadline6-dev \ - librecode-dev \ + libedit-dev \ libsqlite3-dev \ libssl-dev \ libxml2-dev \ xz-utils \ " \ - && set -x \ && apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \ && curl -fSL "http://php.net/get/$PHP_FILENAME/from/this/mirror" -o "$PHP_FILENAME" \ && echo "$PHP_SHA256 *$PHP_FILENAME" | sha256sum -c - \ && curl -fSL "http://php.net/get/$PHP_FILENAME.asc/from/this/mirror" -o "$PHP_FILENAME.asc" \ + && export GNUPGHOME="$(mktemp -d)" \ + && for key in $GPG_KEYS; do \ + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ + done \ && gpg --batch --verify "$PHP_FILENAME.asc" "$PHP_FILENAME" \ + && rm -r "$GNUPGHOME" "$PHP_FILENAME.asc" \ && mkdir -p /usr/src/php \ && tar -xf "$PHP_FILENAME" -C /usr/src/php --strip-components=1 \ - && rm "$PHP_FILENAME"* \ + && rm "$PHP_FILENAME" \ && cd /usr/src/php \ && ./configure \ --with-config-file-path="$PHP_INI_DIR" \ --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \ $PHP_EXTRA_CONFIGURE_ARGS \ --disable-cgi \ +# --enable-mysqlnd is included here because it's harder to compile after the fact than extensions are (since it's a plugin for several extensions, not an extension in itself) --enable-mysqlnd \ --with-curl \ + --with-libedit \ --with-openssl \ - --with-readline \ - --with-recode \ --with-zlib \ && make -j"$(nproc)" \ && make install \ && { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \ - && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps \ - && make clean + && make clean \ + && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps COPY docker-php-ext-* /usr/local/bin/ diff --git a/5.6/fpm/alpine/Dockerfile b/5.6/fpm/alpine/Dockerfile index 762ba54d..e6b8c480 100644 --- a/5.6/fpm/alpine/Dockerfile +++ b/5.6/fpm/alpine/Dockerfile @@ -1,57 +1,75 @@ FROM alpine:3.3 +# phpize deps +RUN apk add --no-cache --virtual .phpize-deps \ + autoconf \ + file \ + g++ \ + gcc \ + libc-dev \ + make \ + pkgconf \ + re2c + +# persistent / runtime deps +RUN apk add --no-cache --virtual .persistent-deps \ + ca-certificates \ + curl + +# ensure www-data user exists +RUN set -x \ + && addgroup -g 82 -S www-data \ + && adduser -u 82 -D -S -G www-data www-data +# 82 is the standard uid/gid for "www-data" in Alpine +# http://git.alpinelinux.org/cgit/aports/tree/main/apache2/apache2.pre-install?h=v3.3.2 +# http://git.alpinelinux.org/cgit/aports/tree/main/lighttpd/lighttpd.pre-install?h=v3.3.2 +# http://git.alpinelinux.org/cgit/aports/tree/main/nginx-initscripts/nginx-initscripts.pre-install?h=v3.3.2 + ENV PHP_INI_DIR /usr/local/etc/php RUN mkdir -p $PHP_INI_DIR/conf.d -ENV PHP_VERSION 5.6.18 -ENV PHP_FILENAME php-5.6.18.tar.xz -ENV PHP_SHA256 54dd9106c3469bc7028644d72ac140af00655420bbaaf4a742a64e9ed02ec1b0 - - #### ENV PHP_EXTRA_CONFIGURE_ARGS --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data #### -# --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) ENV GPG_KEYS 0BD78B5F97500D450838F95DFE857D9A90D90EC1 6E4F6AB321FDC07F2C332E3AC2BF0BC433CFC8B3 -RUN addgroup -g 82 -S www-data \ - && adduser -u 82 -D -S -G www-data www-data + +ENV PHP_VERSION 5.6.19 +ENV PHP_FILENAME php-5.6.19.tar.xz +ENV PHP_SHA256 bb32337f93a00b71789f116bddafa8848139120e7fb6f4f98a84f52dbcb8329f + RUN set -xe \ && apk add --no-cache --virtual .build-deps \ - autoconf \ curl-dev \ - file \ - gcc \ gnupg \ - libc-dev \ libedit-dev \ libxml2-dev \ - make \ openssl-dev \ - pkgconf \ - re2c \ sqlite-dev \ - && for key in $GPG_KEYS; do \ - gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ - done \ && curl -fSL "http://php.net/get/$PHP_FILENAME/from/this/mirror" -o "$PHP_FILENAME" \ && echo "$PHP_SHA256 *$PHP_FILENAME" | sha256sum -c - \ && curl -fSL "http://php.net/get/$PHP_FILENAME.asc/from/this/mirror" -o "$PHP_FILENAME.asc" \ + && export GNUPGHOME="$(mktemp -d)" \ + && for key in $GPG_KEYS; do \ + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ + done \ && gpg --batch --verify "$PHP_FILENAME.asc" "$PHP_FILENAME" \ + && rm -r "$GNUPGHOME" "$PHP_FILENAME.asc" \ && mkdir -p /usr/src \ && tar -Jxf "$PHP_FILENAME" -C /usr/src \ - && mv /usr/src/php-$PHP_VERSION /usr/src/php \ - && rm "$PHP_FILENAME"* \ + && mv "/usr/src/php-$PHP_VERSION" /usr/src/php \ + && rm "$PHP_FILENAME" \ && cd /usr/src/php \ && ./configure \ --with-config-file-path="$PHP_INI_DIR" \ --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \ $PHP_EXTRA_CONFIGURE_ARGS \ --disable-cgi \ +# --enable-mysqlnd is included here because it's harder to compile after the fact than extensions are (since it's a plugin for several extensions, not an extension in itself) --enable-mysqlnd \ --with-curl \ - --with-openssl \ --with-libedit \ + --with-openssl \ --with-zlib \ && make -j"$(getconf _NPROCESSORS_ONLN)" \ && make install \ diff --git a/5.6/fpm/alpine/docker-php-ext-enable b/5.6/fpm/alpine/docker-php-ext-enable index 5381d0d0..367aaf2b 100755 --- a/5.6/fpm/alpine/docker-php-ext-enable +++ b/5.6/fpm/alpine/docker-php-ext-enable @@ -4,15 +4,37 @@ set -e cd "$(php -r 'echo ini_get("extension_dir");')" usage() { - echo "usage: $0 module-name [module-name ...]" + echo "usage: $0 [options] module-name [module-name ...]" echo " ie: $0 gd mysqli" echo " $0 pdo pdo_mysql" + echo " $0 --ini-name 0-apc.ini apcu apc" echo echo 'Possible values for module-name:' echo $(find -maxdepth 1 -type f -name '*.so' -exec basename '{}' ';' | sort) } -modules="" +opts="$(getopt -o 'h?' --long 'help,ini-name:' -- "$@" || { usage >&2 && false; })" +eval set -- "$opts" + +iniName= +while true; do + flag="$1" + shift + case "$flag" in + --help|-h|'-?') usage && exit 0 ;; + --ini-name) iniName="$1" && shift ;; + --) break ;; + *) + { + echo "error: unknown flag: $flag" + usage + } >&2 + exit 1 + ;; + esac +done + +modules= for module; do if [ -z "$module" ]; then continue @@ -35,8 +57,8 @@ if [ -z "$modules" ]; then exit 1 fi -for module in ${modules}; do - if grep -q zend_extension_entry "$module"; then +for module in $modules; do + if nm -g "$module" | grep -q ' zend_extension_entry$'; then # https://wiki.php.net/internals/extensions#loading_zend_extensions line="zend_extension=$(readlink -f "$module")" else @@ -54,7 +76,7 @@ for module in ${modules}; do continue fi - ini="/usr/local/etc/php/conf.d/docker-php-ext-$ext.ini" + ini="/usr/local/etc/php/conf.d/${iniName:-"docker-php-ext-$ext.ini"}" if ! grep -q "$line" "$ini" 2>/dev/null; then echo "$line" >> "$ini" fi diff --git a/5.6/fpm/alpine/docker-php-ext-install b/5.6/fpm/alpine/docker-php-ext-install index 68309ff9..67180a86 100755 --- a/5.6/fpm/alpine/docker-php-ext-install +++ b/5.6/fpm/alpine/docker-php-ext-install @@ -61,7 +61,11 @@ for ext in $exts; do [ -e Makefile ] || docker-php-ext-configure "$ext" make -j"$j" make -j"$j" install - ls modules/*.so | cut -d/ -f2 | xargs -r docker-php-ext-enable + find modules \ + -maxdepth 1 \ + -name '*.so' \ + -exec basename '{}' ';' \ + | xargs -r docker-php-ext-enable make -j"$j" clean ) done diff --git a/5.6/fpm/docker-php-ext-configure b/5.6/fpm/docker-php-ext-configure index 3d21b5bb..39947c8f 100755 --- a/5.6/fpm/docker-php-ext-configure +++ b/5.6/fpm/docker-php-ext-configure @@ -1,9 +1,9 @@ -#!/bin/bash +#!/bin/sh set -e ext="$1" extDir="/usr/src/php/ext/$ext" -if [ -z "$ext" -o ! -d "$extDir" ]; then +if [ -z "$ext" ] || ! [ -d "$extDir" ]; then echo >&2 "usage: $0 ext-name [configure flags]" echo >&2 " ie: $0 gd --with-jpeg-dir=/usr/local/something" echo >&2 diff --git a/5.6/fpm/docker-php-ext-enable b/5.6/fpm/docker-php-ext-enable index edb07ed8..367aaf2b 100755 --- a/5.6/fpm/docker-php-ext-enable +++ b/5.6/fpm/docker-php-ext-enable @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -e cd "$(php -r 'echo ini_get("extension_dir");')" @@ -34,32 +34,30 @@ while true; do esac done -modules=() -while [ $# -gt 0 ]; do - module="$1" - shift +modules= +for module; do if [ -z "$module" ]; then continue fi - if [ -f "$module.so" -a ! -f "$module" ]; then + if [ -f "$module.so" ] && ! [ -f "$module" ]; then # allow ".so" to be optional - module+='.so' + module="$module.so" fi - if [ ! -f "$module" ]; then + if ! [ -f "$module" ]; then echo >&2 "error: $(readlink -f "$module") does not exist" echo >&2 usage >&2 exit 1 fi - modules+=( "$module" ) + modules="$modules $module" done -if [ "${#modules[@]}" -eq 0 ]; then +if [ -z "$modules" ]; then usage >&2 exit 1 fi -for module in "${modules[@]}"; do +for module in $modules; do if nm -g "$module" | grep -q ' zend_extension_entry$'; then # https://wiki.php.net/internals/extensions#loading_zend_extensions line="zend_extension=$(readlink -f "$module")" diff --git a/5.6/fpm/docker-php-ext-install b/5.6/fpm/docker-php-ext-install index 2c488cce..67180a86 100755 --- a/5.6/fpm/docker-php-ext-install +++ b/5.6/fpm/docker-php-ext-install @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -e cd /usr/src/php/ext @@ -36,10 +36,8 @@ while true; do esac done -exts=() -while [ $# -gt 0 ]; do - ext="$1" - shift +exts= +for ext; do if [ -z "$ext" ]; then continue fi @@ -49,21 +47,25 @@ while [ $# -gt 0 ]; do usage >&2 exit 1 fi - exts+=( "$ext" ) + exts="$exts $ext" done -if [ "${#exts[@]}" -eq 0 ]; then +if [ -z "$exts" ]; then usage >&2 exit 1 fi -for ext in "${exts[@]}"; do +for ext in $exts; do ( cd "$ext" [ -e Makefile ] || docker-php-ext-configure "$ext" make -j"$j" make -j"$j" install - find modules -maxdepth 1 -name '*.so' -exec basename '{}' ';' | xargs --no-run-if-empty --verbose docker-php-ext-enable + find modules \ + -maxdepth 1 \ + -name '*.so' \ + -exec basename '{}' ';' \ + | xargs -r docker-php-ext-enable make -j"$j" clean ) done diff --git a/5.6/zts/Dockerfile b/5.6/zts/Dockerfile index 32d0f6ff..74455f3d 100644 --- a/5.6/zts/Dockerfile +++ b/5.6/zts/Dockerfile @@ -1,10 +1,25 @@ FROM debian:jessie -# persistent / runtime deps -RUN apt-get update && apt-get install -y ca-certificates curl librecode0 libsqlite3-0 libxml2 --no-install-recommends && rm -r /var/lib/apt/lists/* - # phpize deps -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/* +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/* + +# persistent / runtime deps +RUN apt-get update && apt-get install -y \ + ca-certificates \ + curl \ + libedit2 \ + libsqlite3-0 \ + libxml2 \ + --no-install-recommends && rm -r /var/lib/apt/lists/* ENV PHP_INI_DIR /usr/local/etc/php RUN mkdir -p $PHP_INI_DIR/conf.d @@ -14,52 +29,51 @@ ENV PHP_EXTRA_CONFIGURE_ARGS --enable-maintainer-zts #### ENV GPG_KEYS 0BD78B5F97500D450838F95DFE857D9A90D90EC1 6E4F6AB321FDC07F2C332E3AC2BF0BC433CFC8B3 -RUN set -xe \ - && for key in $GPG_KEYS; do \ - gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ - done ENV PHP_VERSION 5.6.19 ENV PHP_FILENAME php-5.6.19.tar.xz ENV PHP_SHA256 bb32337f93a00b71789f116bddafa8848139120e7fb6f4f98a84f52dbcb8329f -# --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) -RUN buildDeps=" \ +RUN set -xe \ + && buildDeps=" \ $PHP_EXTRA_BUILD_DEPS \ libcurl4-openssl-dev \ - libreadline6-dev \ - librecode-dev \ + libedit-dev \ libsqlite3-dev \ libssl-dev \ libxml2-dev \ xz-utils \ " \ - && set -x \ && apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \ && curl -fSL "http://php.net/get/$PHP_FILENAME/from/this/mirror" -o "$PHP_FILENAME" \ && echo "$PHP_SHA256 *$PHP_FILENAME" | sha256sum -c - \ && curl -fSL "http://php.net/get/$PHP_FILENAME.asc/from/this/mirror" -o "$PHP_FILENAME.asc" \ + && export GNUPGHOME="$(mktemp -d)" \ + && for key in $GPG_KEYS; do \ + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ + done \ && gpg --batch --verify "$PHP_FILENAME.asc" "$PHP_FILENAME" \ + && rm -r "$GNUPGHOME" "$PHP_FILENAME.asc" \ && mkdir -p /usr/src/php \ && tar -xf "$PHP_FILENAME" -C /usr/src/php --strip-components=1 \ - && rm "$PHP_FILENAME"* \ + && rm "$PHP_FILENAME" \ && cd /usr/src/php \ && ./configure \ --with-config-file-path="$PHP_INI_DIR" \ --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \ $PHP_EXTRA_CONFIGURE_ARGS \ --disable-cgi \ +# --enable-mysqlnd is included here because it's harder to compile after the fact than extensions are (since it's a plugin for several extensions, not an extension in itself) --enable-mysqlnd \ --with-curl \ + --with-libedit \ --with-openssl \ - --with-readline \ - --with-recode \ --with-zlib \ && make -j"$(nproc)" \ && make install \ && { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \ - && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps \ - && make clean + && make clean \ + && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps COPY docker-php-ext-* /usr/local/bin/ diff --git a/5.6/zts/alpine/Dockerfile b/5.6/zts/alpine/Dockerfile new file mode 100644 index 00000000..59a2e59e --- /dev/null +++ b/5.6/zts/alpine/Dockerfile @@ -0,0 +1,92 @@ +FROM alpine:3.3 + +# phpize deps +RUN apk add --no-cache --virtual .phpize-deps \ + autoconf \ + file \ + g++ \ + gcc \ + libc-dev \ + make \ + pkgconf \ + re2c + +# persistent / runtime deps +RUN apk add --no-cache --virtual .persistent-deps \ + ca-certificates \ + curl + +# ensure www-data user exists +RUN set -x \ + && addgroup -g 82 -S www-data \ + && adduser -u 82 -D -S -G www-data www-data +# 82 is the standard uid/gid for "www-data" in Alpine +# http://git.alpinelinux.org/cgit/aports/tree/main/apache2/apache2.pre-install?h=v3.3.2 +# http://git.alpinelinux.org/cgit/aports/tree/main/lighttpd/lighttpd.pre-install?h=v3.3.2 +# http://git.alpinelinux.org/cgit/aports/tree/main/nginx-initscripts/nginx-initscripts.pre-install?h=v3.3.2 + +ENV PHP_INI_DIR /usr/local/etc/php +RUN mkdir -p $PHP_INI_DIR/conf.d + +#### +ENV PHP_EXTRA_CONFIGURE_ARGS --enable-maintainer-zts +#### + +ENV GPG_KEYS 0BD78B5F97500D450838F95DFE857D9A90D90EC1 6E4F6AB321FDC07F2C332E3AC2BF0BC433CFC8B3 + +ENV PHP_VERSION 5.6.19 +ENV PHP_FILENAME php-5.6.19.tar.xz +ENV PHP_SHA256 bb32337f93a00b71789f116bddafa8848139120e7fb6f4f98a84f52dbcb8329f + +RUN set -xe \ + && apk add --no-cache --virtual .build-deps \ + curl-dev \ + gnupg \ + libedit-dev \ + libxml2-dev \ + openssl-dev \ + sqlite-dev \ + && curl -fSL "http://php.net/get/$PHP_FILENAME/from/this/mirror" -o "$PHP_FILENAME" \ + && echo "$PHP_SHA256 *$PHP_FILENAME" | sha256sum -c - \ + && curl -fSL "http://php.net/get/$PHP_FILENAME.asc/from/this/mirror" -o "$PHP_FILENAME.asc" \ + && export GNUPGHOME="$(mktemp -d)" \ + && for key in $GPG_KEYS; do \ + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ + done \ + && gpg --batch --verify "$PHP_FILENAME.asc" "$PHP_FILENAME" \ + && rm -r "$GNUPGHOME" "$PHP_FILENAME.asc" \ + && mkdir -p /usr/src \ + && tar -Jxf "$PHP_FILENAME" -C /usr/src \ + && mv "/usr/src/php-$PHP_VERSION" /usr/src/php \ + && rm "$PHP_FILENAME" \ + && cd /usr/src/php \ + && ./configure \ + --with-config-file-path="$PHP_INI_DIR" \ + --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \ + $PHP_EXTRA_CONFIGURE_ARGS \ + --disable-cgi \ +# --enable-mysqlnd is included here because it's harder to compile after the fact than extensions are (since it's a plugin for several extensions, not an extension in itself) + --enable-mysqlnd \ + --with-curl \ + --with-libedit \ + --with-openssl \ + --with-zlib \ + && make -j"$(getconf _NPROCESSORS_ONLN)" \ + && make install \ + && { find /usr/local/bin /usr/local/sbin -type f -perm +0111 -exec strip --strip-all '{}' + || true; } \ + && make clean \ + && runDeps="$( \ + scanelf --needed --nobanner --recursive /usr/local \ + | awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \ + | sort -u \ + | xargs -r apk info --installed \ + | sort -u \ + )" \ + && apk add --virtual .php-rundeps $runDeps \ + && apk del .build-deps + +COPY docker-php-ext-* /usr/local/bin/ + +#### +CMD ["php", "-a"] +#### diff --git a/5.6/zts/alpine/docker-php-ext-configure b/5.6/zts/alpine/docker-php-ext-configure new file mode 100755 index 00000000..39947c8f --- /dev/null +++ b/5.6/zts/alpine/docker-php-ext-configure @@ -0,0 +1,19 @@ +#!/bin/sh +set -e + +ext="$1" +extDir="/usr/src/php/ext/$ext" +if [ -z "$ext" ] || ! [ -d "$extDir" ]; then + echo >&2 "usage: $0 ext-name [configure flags]" + echo >&2 " ie: $0 gd --with-jpeg-dir=/usr/local/something" + echo >&2 + echo >&2 'Possible values for ext-name:' + echo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort) + exit 1 +fi +shift + +set -x +cd "$extDir" +phpize +./configure "$@" diff --git a/5.6/zts/alpine/docker-php-ext-enable b/5.6/zts/alpine/docker-php-ext-enable new file mode 100755 index 00000000..367aaf2b --- /dev/null +++ b/5.6/zts/alpine/docker-php-ext-enable @@ -0,0 +1,83 @@ +#!/bin/sh +set -e + +cd "$(php -r 'echo ini_get("extension_dir");')" + +usage() { + echo "usage: $0 [options] module-name [module-name ...]" + echo " ie: $0 gd mysqli" + echo " $0 pdo pdo_mysql" + echo " $0 --ini-name 0-apc.ini apcu apc" + echo + echo 'Possible values for module-name:' + echo $(find -maxdepth 1 -type f -name '*.so' -exec basename '{}' ';' | sort) +} + +opts="$(getopt -o 'h?' --long 'help,ini-name:' -- "$@" || { usage >&2 && false; })" +eval set -- "$opts" + +iniName= +while true; do + flag="$1" + shift + case "$flag" in + --help|-h|'-?') usage && exit 0 ;; + --ini-name) iniName="$1" && shift ;; + --) break ;; + *) + { + echo "error: unknown flag: $flag" + usage + } >&2 + exit 1 + ;; + esac +done + +modules= +for module; do + if [ -z "$module" ]; then + continue + fi + if [ -f "$module.so" ] && ! [ -f "$module" ]; then + # allow ".so" to be optional + module="$module.so" + fi + if ! [ -f "$module" ]; then + echo >&2 "error: $(readlink -f "$module") does not exist" + echo >&2 + usage >&2 + exit 1 + fi + modules="$modules $module" +done + +if [ -z "$modules" ]; then + usage >&2 + exit 1 +fi + +for module in $modules; do + if nm -g "$module" | grep -q ' zend_extension_entry$'; then + # https://wiki.php.net/internals/extensions#loading_zend_extensions + line="zend_extension=$(readlink -f "$module")" + else + line="extension=$module" + fi + + ext="$(basename "$module")" + ext="${ext%.*}" + if php -r 'exit(extension_loaded("'"$ext"'") ? 0 : 1);'; then + # this isn't perfect, but it's better than nothing + # (for example, 'opcache.so' presents inside PHP as 'Zend OPcache', not 'opcache') + echo >&2 + echo >&2 "warning: $ext ($module) is already loaded!" + echo >&2 + continue + fi + + ini="/usr/local/etc/php/conf.d/${iniName:-"docker-php-ext-$ext.ini"}" + if ! grep -q "$line" "$ini" 2>/dev/null; then + echo "$line" >> "$ini" + fi +done diff --git a/5.6/zts/alpine/docker-php-ext-install b/5.6/zts/alpine/docker-php-ext-install new file mode 100755 index 00000000..67180a86 --- /dev/null +++ b/5.6/zts/alpine/docker-php-ext-install @@ -0,0 +1,71 @@ +#!/bin/sh +set -e + +cd /usr/src/php/ext + +usage() { + echo "usage: $0 [-jN] ext-name [ext-name ...]" + echo " ie: $0 gd mysqli" + echo " $0 pdo pdo_mysql" + echo " $0 -j5 gd mbstring mysqli pdo pdo_mysql shmop" + echo + echo 'if custom ./configure arguments are necessary, see docker-php-ext-configure' + echo + echo 'Possible values for ext-name:' + echo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort) +} + +opts="$(getopt -o 'h?j:' --long 'help,jobs:' -- "$@" || { usage >&2 && false; })" +eval set -- "$opts" + +j=1 +while true; do + flag="$1" + shift + case "$flag" in + --help|-h|'-?') usage && exit 0 ;; + --jobs|-j) j="$1" && shift ;; + --) break ;; + *) + { + echo "error: unknown flag: $flag" + usage + } >&2 + exit 1 + ;; + esac +done + +exts= +for ext; do + if [ -z "$ext" ]; then + continue + fi + if [ ! -d "$ext" ]; then + echo >&2 "error: $(pwd -P)/$ext does not exist" + echo >&2 + usage >&2 + exit 1 + fi + exts="$exts $ext" +done + +if [ -z "$exts" ]; then + usage >&2 + exit 1 +fi + +for ext in $exts; do + ( + cd "$ext" + [ -e Makefile ] || docker-php-ext-configure "$ext" + make -j"$j" + make -j"$j" install + find modules \ + -maxdepth 1 \ + -name '*.so' \ + -exec basename '{}' ';' \ + | xargs -r docker-php-ext-enable + make -j"$j" clean + ) +done diff --git a/5.6/zts/docker-php-ext-configure b/5.6/zts/docker-php-ext-configure index 3d21b5bb..39947c8f 100755 --- a/5.6/zts/docker-php-ext-configure +++ b/5.6/zts/docker-php-ext-configure @@ -1,9 +1,9 @@ -#!/bin/bash +#!/bin/sh set -e ext="$1" extDir="/usr/src/php/ext/$ext" -if [ -z "$ext" -o ! -d "$extDir" ]; then +if [ -z "$ext" ] || ! [ -d "$extDir" ]; then echo >&2 "usage: $0 ext-name [configure flags]" echo >&2 " ie: $0 gd --with-jpeg-dir=/usr/local/something" echo >&2 diff --git a/5.6/zts/docker-php-ext-enable b/5.6/zts/docker-php-ext-enable index edb07ed8..367aaf2b 100755 --- a/5.6/zts/docker-php-ext-enable +++ b/5.6/zts/docker-php-ext-enable @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -e cd "$(php -r 'echo ini_get("extension_dir");')" @@ -34,32 +34,30 @@ while true; do esac done -modules=() -while [ $# -gt 0 ]; do - module="$1" - shift +modules= +for module; do if [ -z "$module" ]; then continue fi - if [ -f "$module.so" -a ! -f "$module" ]; then + if [ -f "$module.so" ] && ! [ -f "$module" ]; then # allow ".so" to be optional - module+='.so' + module="$module.so" fi - if [ ! -f "$module" ]; then + if ! [ -f "$module" ]; then echo >&2 "error: $(readlink -f "$module") does not exist" echo >&2 usage >&2 exit 1 fi - modules+=( "$module" ) + modules="$modules $module" done -if [ "${#modules[@]}" -eq 0 ]; then +if [ -z "$modules" ]; then usage >&2 exit 1 fi -for module in "${modules[@]}"; do +for module in $modules; do if nm -g "$module" | grep -q ' zend_extension_entry$'; then # https://wiki.php.net/internals/extensions#loading_zend_extensions line="zend_extension=$(readlink -f "$module")" diff --git a/5.6/zts/docker-php-ext-install b/5.6/zts/docker-php-ext-install index 2c488cce..67180a86 100755 --- a/5.6/zts/docker-php-ext-install +++ b/5.6/zts/docker-php-ext-install @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -e cd /usr/src/php/ext @@ -36,10 +36,8 @@ while true; do esac done -exts=() -while [ $# -gt 0 ]; do - ext="$1" - shift +exts= +for ext; do if [ -z "$ext" ]; then continue fi @@ -49,21 +47,25 @@ while [ $# -gt 0 ]; do usage >&2 exit 1 fi - exts+=( "$ext" ) + exts="$exts $ext" done -if [ "${#exts[@]}" -eq 0 ]; then +if [ -z "$exts" ]; then usage >&2 exit 1 fi -for ext in "${exts[@]}"; do +for ext in $exts; do ( cd "$ext" [ -e Makefile ] || docker-php-ext-configure "$ext" make -j"$j" make -j"$j" install - find modules -maxdepth 1 -name '*.so' -exec basename '{}' ';' | xargs --no-run-if-empty --verbose docker-php-ext-enable + find modules \ + -maxdepth 1 \ + -name '*.so' \ + -exec basename '{}' ';' \ + | xargs -r docker-php-ext-enable make -j"$j" clean ) done diff --git a/7.0/Dockerfile b/7.0/Dockerfile index 1a1f31c9..9df465c5 100644 --- a/7.0/Dockerfile +++ b/7.0/Dockerfile @@ -1,10 +1,25 @@ FROM debian:jessie -# persistent / runtime deps -RUN apt-get update && apt-get install -y ca-certificates curl librecode0 libsqlite3-0 libxml2 --no-install-recommends && rm -r /var/lib/apt/lists/* - # phpize deps -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/* +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/* + +# persistent / runtime deps +RUN apt-get update && apt-get install -y \ + ca-certificates \ + curl \ + libedit2 \ + libsqlite3-0 \ + libxml2 \ + --no-install-recommends && rm -r /var/lib/apt/lists/* ENV PHP_INI_DIR /usr/local/etc/php RUN mkdir -p $PHP_INI_DIR/conf.d @@ -13,52 +28,51 @@ RUN mkdir -p $PHP_INI_DIR/conf.d #### ENV GPG_KEYS 1A4E8B7277C42E53DBA9C7B9BCAA30EA9C0D5763 -RUN set -xe \ - && for key in $GPG_KEYS; do \ - gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ - done ENV PHP_VERSION 7.0.4 ENV PHP_FILENAME php-7.0.4.tar.xz ENV PHP_SHA256 584e0e374e357a71b6e95175a2947d787453afc7f9ab7c55651c10491c4df532 -# --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) -RUN buildDeps=" \ +RUN set -xe \ + && buildDeps=" \ $PHP_EXTRA_BUILD_DEPS \ libcurl4-openssl-dev \ - libreadline6-dev \ - librecode-dev \ + libedit-dev \ libsqlite3-dev \ libssl-dev \ libxml2-dev \ xz-utils \ " \ - && set -x \ && apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \ && curl -fSL "http://php.net/get/$PHP_FILENAME/from/this/mirror" -o "$PHP_FILENAME" \ && echo "$PHP_SHA256 *$PHP_FILENAME" | sha256sum -c - \ && curl -fSL "http://php.net/get/$PHP_FILENAME.asc/from/this/mirror" -o "$PHP_FILENAME.asc" \ + && export GNUPGHOME="$(mktemp -d)" \ + && for key in $GPG_KEYS; do \ + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ + done \ && gpg --batch --verify "$PHP_FILENAME.asc" "$PHP_FILENAME" \ + && rm -r "$GNUPGHOME" "$PHP_FILENAME.asc" \ && mkdir -p /usr/src/php \ && tar -xf "$PHP_FILENAME" -C /usr/src/php --strip-components=1 \ - && rm "$PHP_FILENAME"* \ + && rm "$PHP_FILENAME" \ && cd /usr/src/php \ && ./configure \ --with-config-file-path="$PHP_INI_DIR" \ --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \ $PHP_EXTRA_CONFIGURE_ARGS \ --disable-cgi \ +# --enable-mysqlnd is included here because it's harder to compile after the fact than extensions are (since it's a plugin for several extensions, not an extension in itself) --enable-mysqlnd \ --with-curl \ + --with-libedit \ --with-openssl \ - --with-readline \ - --with-recode \ --with-zlib \ && make -j"$(nproc)" \ && make install \ && { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \ - && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps \ - && make clean + && make clean \ + && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps COPY docker-php-ext-* /usr/local/bin/ diff --git a/7.0/alpine/Dockerfile b/7.0/alpine/Dockerfile index d035877e..e0ef122e 100644 --- a/7.0/alpine/Dockerfile +++ b/7.0/alpine/Dockerfile @@ -1,53 +1,74 @@ FROM alpine:3.3 +# phpize deps +RUN apk add --no-cache --virtual .phpize-deps \ + autoconf \ + file \ + g++ \ + gcc \ + libc-dev \ + make \ + pkgconf \ + re2c + +# persistent / runtime deps +RUN apk add --no-cache --virtual .persistent-deps \ + ca-certificates \ + curl + +# ensure www-data user exists +RUN set -x \ + && addgroup -g 82 -S www-data \ + && adduser -u 82 -D -S -G www-data www-data +# 82 is the standard uid/gid for "www-data" in Alpine +# http://git.alpinelinux.org/cgit/aports/tree/main/apache2/apache2.pre-install?h=v3.3.2 +# http://git.alpinelinux.org/cgit/aports/tree/main/lighttpd/lighttpd.pre-install?h=v3.3.2 +# http://git.alpinelinux.org/cgit/aports/tree/main/nginx-initscripts/nginx-initscripts.pre-install?h=v3.3.2 + ENV PHP_INI_DIR /usr/local/etc/php RUN mkdir -p $PHP_INI_DIR/conf.d +#### +#### + +ENV GPG_KEYS 1A4E8B7277C42E53DBA9C7B9BCAA30EA9C0D5763 + ENV PHP_VERSION 7.0.4 ENV PHP_FILENAME php-7.0.4.tar.xz ENV PHP_SHA256 584e0e374e357a71b6e95175a2947d787453afc7f9ab7c55651c10491c4df532 -#### -#### - -# --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) -ENV GPG_KEYS 1A4E8B7277C42E53DBA9C7B9BCAA30EA9C0D5763 RUN set -xe \ && apk add --no-cache --virtual .build-deps \ - autoconf \ curl-dev \ - file \ - gcc \ gnupg \ - libc-dev \ libedit-dev \ libxml2-dev \ - make \ openssl-dev \ - pkgconf \ - re2c \ sqlite-dev \ - && for key in $GPG_KEYS; do \ - gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ - done \ && curl -fSL "http://php.net/get/$PHP_FILENAME/from/this/mirror" -o "$PHP_FILENAME" \ && echo "$PHP_SHA256 *$PHP_FILENAME" | sha256sum -c - \ && curl -fSL "http://php.net/get/$PHP_FILENAME.asc/from/this/mirror" -o "$PHP_FILENAME.asc" \ + && export GNUPGHOME="$(mktemp -d)" \ + && for key in $GPG_KEYS; do \ + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ + done \ && gpg --batch --verify "$PHP_FILENAME.asc" "$PHP_FILENAME" \ + && rm -r "$GNUPGHOME" "$PHP_FILENAME.asc" \ && mkdir -p /usr/src \ && tar -Jxf "$PHP_FILENAME" -C /usr/src \ - && mv /usr/src/php-$PHP_VERSION /usr/src/php \ - && rm "$PHP_FILENAME"* \ + && mv "/usr/src/php-$PHP_VERSION" /usr/src/php \ + && rm "$PHP_FILENAME" \ && cd /usr/src/php \ && ./configure \ --with-config-file-path="$PHP_INI_DIR" \ --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \ $PHP_EXTRA_CONFIGURE_ARGS \ --disable-cgi \ +# --enable-mysqlnd is included here because it's harder to compile after the fact than extensions are (since it's a plugin for several extensions, not an extension in itself) --enable-mysqlnd \ --with-curl \ - --with-openssl \ --with-libedit \ + --with-openssl \ --with-zlib \ && make -j"$(getconf _NPROCESSORS_ONLN)" \ && make install \ diff --git a/7.0/alpine/docker-php-ext-enable b/7.0/alpine/docker-php-ext-enable index 5381d0d0..367aaf2b 100755 --- a/7.0/alpine/docker-php-ext-enable +++ b/7.0/alpine/docker-php-ext-enable @@ -4,15 +4,37 @@ set -e cd "$(php -r 'echo ini_get("extension_dir");')" usage() { - echo "usage: $0 module-name [module-name ...]" + echo "usage: $0 [options] module-name [module-name ...]" echo " ie: $0 gd mysqli" echo " $0 pdo pdo_mysql" + echo " $0 --ini-name 0-apc.ini apcu apc" echo echo 'Possible values for module-name:' echo $(find -maxdepth 1 -type f -name '*.so' -exec basename '{}' ';' | sort) } -modules="" +opts="$(getopt -o 'h?' --long 'help,ini-name:' -- "$@" || { usage >&2 && false; })" +eval set -- "$opts" + +iniName= +while true; do + flag="$1" + shift + case "$flag" in + --help|-h|'-?') usage && exit 0 ;; + --ini-name) iniName="$1" && shift ;; + --) break ;; + *) + { + echo "error: unknown flag: $flag" + usage + } >&2 + exit 1 + ;; + esac +done + +modules= for module; do if [ -z "$module" ]; then continue @@ -35,8 +57,8 @@ if [ -z "$modules" ]; then exit 1 fi -for module in ${modules}; do - if grep -q zend_extension_entry "$module"; then +for module in $modules; do + if nm -g "$module" | grep -q ' zend_extension_entry$'; then # https://wiki.php.net/internals/extensions#loading_zend_extensions line="zend_extension=$(readlink -f "$module")" else @@ -54,7 +76,7 @@ for module in ${modules}; do continue fi - ini="/usr/local/etc/php/conf.d/docker-php-ext-$ext.ini" + ini="/usr/local/etc/php/conf.d/${iniName:-"docker-php-ext-$ext.ini"}" if ! grep -q "$line" "$ini" 2>/dev/null; then echo "$line" >> "$ini" fi diff --git a/7.0/alpine/docker-php-ext-install b/7.0/alpine/docker-php-ext-install index 68309ff9..67180a86 100755 --- a/7.0/alpine/docker-php-ext-install +++ b/7.0/alpine/docker-php-ext-install @@ -61,7 +61,11 @@ for ext in $exts; do [ -e Makefile ] || docker-php-ext-configure "$ext" make -j"$j" make -j"$j" install - ls modules/*.so | cut -d/ -f2 | xargs -r docker-php-ext-enable + find modules \ + -maxdepth 1 \ + -name '*.so' \ + -exec basename '{}' ';' \ + | xargs -r docker-php-ext-enable make -j"$j" clean ) done diff --git a/7.0/apache/Dockerfile b/7.0/apache/Dockerfile index 269827dd..4c73f911 100644 --- a/7.0/apache/Dockerfile +++ b/7.0/apache/Dockerfile @@ -1,10 +1,25 @@ FROM debian:jessie -# persistent / runtime deps -RUN apt-get update && apt-get install -y ca-certificates curl librecode0 libsqlite3-0 libxml2 --no-install-recommends && rm -r /var/lib/apt/lists/* - # phpize deps -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/* +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/* + +# persistent / runtime deps +RUN apt-get update && apt-get install -y \ + ca-certificates \ + curl \ + libedit2 \ + libsqlite3-0 \ + libxml2 \ + --no-install-recommends && rm -r /var/lib/apt/lists/* ENV PHP_INI_DIR /usr/local/etc/php RUN mkdir -p $PHP_INI_DIR/conf.d @@ -26,52 +41,51 @@ ENV PHP_EXTRA_CONFIGURE_ARGS --with-apxs2 #### ENV GPG_KEYS 1A4E8B7277C42E53DBA9C7B9BCAA30EA9C0D5763 -RUN set -xe \ - && for key in $GPG_KEYS; do \ - gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ - done ENV PHP_VERSION 7.0.4 ENV PHP_FILENAME php-7.0.4.tar.xz ENV PHP_SHA256 584e0e374e357a71b6e95175a2947d787453afc7f9ab7c55651c10491c4df532 -# --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) -RUN buildDeps=" \ +RUN set -xe \ + && buildDeps=" \ $PHP_EXTRA_BUILD_DEPS \ libcurl4-openssl-dev \ - libreadline6-dev \ - librecode-dev \ + libedit-dev \ libsqlite3-dev \ libssl-dev \ libxml2-dev \ xz-utils \ " \ - && set -x \ && apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \ && curl -fSL "http://php.net/get/$PHP_FILENAME/from/this/mirror" -o "$PHP_FILENAME" \ && echo "$PHP_SHA256 *$PHP_FILENAME" | sha256sum -c - \ && curl -fSL "http://php.net/get/$PHP_FILENAME.asc/from/this/mirror" -o "$PHP_FILENAME.asc" \ + && export GNUPGHOME="$(mktemp -d)" \ + && for key in $GPG_KEYS; do \ + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ + done \ && gpg --batch --verify "$PHP_FILENAME.asc" "$PHP_FILENAME" \ + && rm -r "$GNUPGHOME" "$PHP_FILENAME.asc" \ && mkdir -p /usr/src/php \ && tar -xf "$PHP_FILENAME" -C /usr/src/php --strip-components=1 \ - && rm "$PHP_FILENAME"* \ + && rm "$PHP_FILENAME" \ && cd /usr/src/php \ && ./configure \ --with-config-file-path="$PHP_INI_DIR" \ --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \ $PHP_EXTRA_CONFIGURE_ARGS \ --disable-cgi \ +# --enable-mysqlnd is included here because it's harder to compile after the fact than extensions are (since it's a plugin for several extensions, not an extension in itself) --enable-mysqlnd \ --with-curl \ + --with-libedit \ --with-openssl \ - --with-readline \ - --with-recode \ --with-zlib \ && make -j"$(nproc)" \ && make install \ && { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \ - && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps \ - && make clean + && make clean \ + && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps COPY docker-php-ext-* /usr/local/bin/ diff --git a/7.0/apache/docker-php-ext-configure b/7.0/apache/docker-php-ext-configure index 3d21b5bb..39947c8f 100755 --- a/7.0/apache/docker-php-ext-configure +++ b/7.0/apache/docker-php-ext-configure @@ -1,9 +1,9 @@ -#!/bin/bash +#!/bin/sh set -e ext="$1" extDir="/usr/src/php/ext/$ext" -if [ -z "$ext" -o ! -d "$extDir" ]; then +if [ -z "$ext" ] || ! [ -d "$extDir" ]; then echo >&2 "usage: $0 ext-name [configure flags]" echo >&2 " ie: $0 gd --with-jpeg-dir=/usr/local/something" echo >&2 diff --git a/7.0/apache/docker-php-ext-enable b/7.0/apache/docker-php-ext-enable index edb07ed8..367aaf2b 100755 --- a/7.0/apache/docker-php-ext-enable +++ b/7.0/apache/docker-php-ext-enable @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -e cd "$(php -r 'echo ini_get("extension_dir");')" @@ -34,32 +34,30 @@ while true; do esac done -modules=() -while [ $# -gt 0 ]; do - module="$1" - shift +modules= +for module; do if [ -z "$module" ]; then continue fi - if [ -f "$module.so" -a ! -f "$module" ]; then + if [ -f "$module.so" ] && ! [ -f "$module" ]; then # allow ".so" to be optional - module+='.so' + module="$module.so" fi - if [ ! -f "$module" ]; then + if ! [ -f "$module" ]; then echo >&2 "error: $(readlink -f "$module") does not exist" echo >&2 usage >&2 exit 1 fi - modules+=( "$module" ) + modules="$modules $module" done -if [ "${#modules[@]}" -eq 0 ]; then +if [ -z "$modules" ]; then usage >&2 exit 1 fi -for module in "${modules[@]}"; do +for module in $modules; do if nm -g "$module" | grep -q ' zend_extension_entry$'; then # https://wiki.php.net/internals/extensions#loading_zend_extensions line="zend_extension=$(readlink -f "$module")" diff --git a/7.0/apache/docker-php-ext-install b/7.0/apache/docker-php-ext-install index 2c488cce..67180a86 100755 --- a/7.0/apache/docker-php-ext-install +++ b/7.0/apache/docker-php-ext-install @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -e cd /usr/src/php/ext @@ -36,10 +36,8 @@ while true; do esac done -exts=() -while [ $# -gt 0 ]; do - ext="$1" - shift +exts= +for ext; do if [ -z "$ext" ]; then continue fi @@ -49,21 +47,25 @@ while [ $# -gt 0 ]; do usage >&2 exit 1 fi - exts+=( "$ext" ) + exts="$exts $ext" done -if [ "${#exts[@]}" -eq 0 ]; then +if [ -z "$exts" ]; then usage >&2 exit 1 fi -for ext in "${exts[@]}"; do +for ext in $exts; do ( cd "$ext" [ -e Makefile ] || docker-php-ext-configure "$ext" make -j"$j" make -j"$j" install - find modules -maxdepth 1 -name '*.so' -exec basename '{}' ';' | xargs --no-run-if-empty --verbose docker-php-ext-enable + find modules \ + -maxdepth 1 \ + -name '*.so' \ + -exec basename '{}' ';' \ + | xargs -r docker-php-ext-enable make -j"$j" clean ) done diff --git a/7.0/docker-php-ext-configure b/7.0/docker-php-ext-configure index 3d21b5bb..39947c8f 100755 --- a/7.0/docker-php-ext-configure +++ b/7.0/docker-php-ext-configure @@ -1,9 +1,9 @@ -#!/bin/bash +#!/bin/sh set -e ext="$1" extDir="/usr/src/php/ext/$ext" -if [ -z "$ext" -o ! -d "$extDir" ]; then +if [ -z "$ext" ] || ! [ -d "$extDir" ]; then echo >&2 "usage: $0 ext-name [configure flags]" echo >&2 " ie: $0 gd --with-jpeg-dir=/usr/local/something" echo >&2 diff --git a/7.0/docker-php-ext-enable b/7.0/docker-php-ext-enable index edb07ed8..367aaf2b 100755 --- a/7.0/docker-php-ext-enable +++ b/7.0/docker-php-ext-enable @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -e cd "$(php -r 'echo ini_get("extension_dir");')" @@ -34,32 +34,30 @@ while true; do esac done -modules=() -while [ $# -gt 0 ]; do - module="$1" - shift +modules= +for module; do if [ -z "$module" ]; then continue fi - if [ -f "$module.so" -a ! -f "$module" ]; then + if [ -f "$module.so" ] && ! [ -f "$module" ]; then # allow ".so" to be optional - module+='.so' + module="$module.so" fi - if [ ! -f "$module" ]; then + if ! [ -f "$module" ]; then echo >&2 "error: $(readlink -f "$module") does not exist" echo >&2 usage >&2 exit 1 fi - modules+=( "$module" ) + modules="$modules $module" done -if [ "${#modules[@]}" -eq 0 ]; then +if [ -z "$modules" ]; then usage >&2 exit 1 fi -for module in "${modules[@]}"; do +for module in $modules; do if nm -g "$module" | grep -q ' zend_extension_entry$'; then # https://wiki.php.net/internals/extensions#loading_zend_extensions line="zend_extension=$(readlink -f "$module")" diff --git a/7.0/docker-php-ext-install b/7.0/docker-php-ext-install index 2c488cce..67180a86 100755 --- a/7.0/docker-php-ext-install +++ b/7.0/docker-php-ext-install @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -e cd /usr/src/php/ext @@ -36,10 +36,8 @@ while true; do esac done -exts=() -while [ $# -gt 0 ]; do - ext="$1" - shift +exts= +for ext; do if [ -z "$ext" ]; then continue fi @@ -49,21 +47,25 @@ while [ $# -gt 0 ]; do usage >&2 exit 1 fi - exts+=( "$ext" ) + exts="$exts $ext" done -if [ "${#exts[@]}" -eq 0 ]; then +if [ -z "$exts" ]; then usage >&2 exit 1 fi -for ext in "${exts[@]}"; do +for ext in $exts; do ( cd "$ext" [ -e Makefile ] || docker-php-ext-configure "$ext" make -j"$j" make -j"$j" install - find modules -maxdepth 1 -name '*.so' -exec basename '{}' ';' | xargs --no-run-if-empty --verbose docker-php-ext-enable + find modules \ + -maxdepth 1 \ + -name '*.so' \ + -exec basename '{}' ';' \ + | xargs -r docker-php-ext-enable make -j"$j" clean ) done diff --git a/7.0/fpm/Dockerfile b/7.0/fpm/Dockerfile index 8be39711..216c116e 100644 --- a/7.0/fpm/Dockerfile +++ b/7.0/fpm/Dockerfile @@ -1,10 +1,25 @@ FROM debian:jessie -# persistent / runtime deps -RUN apt-get update && apt-get install -y ca-certificates curl librecode0 libsqlite3-0 libxml2 --no-install-recommends && rm -r /var/lib/apt/lists/* - # phpize deps -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/* +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/* + +# persistent / runtime deps +RUN apt-get update && apt-get install -y \ + ca-certificates \ + curl \ + libedit2 \ + libsqlite3-0 \ + libxml2 \ + --no-install-recommends && rm -r /var/lib/apt/lists/* ENV PHP_INI_DIR /usr/local/etc/php RUN mkdir -p $PHP_INI_DIR/conf.d @@ -14,52 +29,51 @@ ENV PHP_EXTRA_CONFIGURE_ARGS --enable-fpm --with-fpm-user=www-data --with-fpm-gr #### ENV GPG_KEYS 1A4E8B7277C42E53DBA9C7B9BCAA30EA9C0D5763 -RUN set -xe \ - && for key in $GPG_KEYS; do \ - gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ - done ENV PHP_VERSION 7.0.4 ENV PHP_FILENAME php-7.0.4.tar.xz ENV PHP_SHA256 584e0e374e357a71b6e95175a2947d787453afc7f9ab7c55651c10491c4df532 -# --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) -RUN buildDeps=" \ +RUN set -xe \ + && buildDeps=" \ $PHP_EXTRA_BUILD_DEPS \ libcurl4-openssl-dev \ - libreadline6-dev \ - librecode-dev \ + libedit-dev \ libsqlite3-dev \ libssl-dev \ libxml2-dev \ xz-utils \ " \ - && set -x \ && apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \ && curl -fSL "http://php.net/get/$PHP_FILENAME/from/this/mirror" -o "$PHP_FILENAME" \ && echo "$PHP_SHA256 *$PHP_FILENAME" | sha256sum -c - \ && curl -fSL "http://php.net/get/$PHP_FILENAME.asc/from/this/mirror" -o "$PHP_FILENAME.asc" \ + && export GNUPGHOME="$(mktemp -d)" \ + && for key in $GPG_KEYS; do \ + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ + done \ && gpg --batch --verify "$PHP_FILENAME.asc" "$PHP_FILENAME" \ + && rm -r "$GNUPGHOME" "$PHP_FILENAME.asc" \ && mkdir -p /usr/src/php \ && tar -xf "$PHP_FILENAME" -C /usr/src/php --strip-components=1 \ - && rm "$PHP_FILENAME"* \ + && rm "$PHP_FILENAME" \ && cd /usr/src/php \ && ./configure \ --with-config-file-path="$PHP_INI_DIR" \ --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \ $PHP_EXTRA_CONFIGURE_ARGS \ --disable-cgi \ +# --enable-mysqlnd is included here because it's harder to compile after the fact than extensions are (since it's a plugin for several extensions, not an extension in itself) --enable-mysqlnd \ --with-curl \ + --with-libedit \ --with-openssl \ - --with-readline \ - --with-recode \ --with-zlib \ && make -j"$(nproc)" \ && make install \ && { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \ - && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps \ - && make clean + && make clean \ + && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps COPY docker-php-ext-* /usr/local/bin/ diff --git a/7.0/fpm/alpine/Dockerfile b/7.0/fpm/alpine/Dockerfile index 3691eace..993446a8 100644 --- a/7.0/fpm/alpine/Dockerfile +++ b/7.0/fpm/alpine/Dockerfile @@ -1,57 +1,75 @@ FROM alpine:3.3 +# phpize deps +RUN apk add --no-cache --virtual .phpize-deps \ + autoconf \ + file \ + g++ \ + gcc \ + libc-dev \ + make \ + pkgconf \ + re2c + +# persistent / runtime deps +RUN apk add --no-cache --virtual .persistent-deps \ + ca-certificates \ + curl + +# ensure www-data user exists +RUN set -x \ + && addgroup -g 82 -S www-data \ + && adduser -u 82 -D -S -G www-data www-data +# 82 is the standard uid/gid for "www-data" in Alpine +# http://git.alpinelinux.org/cgit/aports/tree/main/apache2/apache2.pre-install?h=v3.3.2 +# http://git.alpinelinux.org/cgit/aports/tree/main/lighttpd/lighttpd.pre-install?h=v3.3.2 +# http://git.alpinelinux.org/cgit/aports/tree/main/nginx-initscripts/nginx-initscripts.pre-install?h=v3.3.2 + ENV PHP_INI_DIR /usr/local/etc/php RUN mkdir -p $PHP_INI_DIR/conf.d -ENV PHP_VERSION 7.0.4 -ENV PHP_FILENAME php-7.0.4.tar.xz -ENV PHP_SHA256 584e0e374e357a71b6e95175a2947d787453afc7f9ab7c55651c10491c4df532 - - #### ENV PHP_EXTRA_CONFIGURE_ARGS --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data #### -# --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) ENV GPG_KEYS 1A4E8B7277C42E53DBA9C7B9BCAA30EA9C0D5763 -RUN addgroup -g 82 -S www-data \ - && adduser -u 82 -D -S -G www-data www-data + +ENV PHP_VERSION 7.0.4 +ENV PHP_FILENAME php-7.0.4.tar.xz +ENV PHP_SHA256 584e0e374e357a71b6e95175a2947d787453afc7f9ab7c55651c10491c4df532 + RUN set -xe \ && apk add --no-cache --virtual .build-deps \ - autoconf \ curl-dev \ - file \ - gcc \ gnupg \ - libc-dev \ libedit-dev \ libxml2-dev \ - make \ openssl-dev \ - pkgconf \ - re2c \ sqlite-dev \ - && for key in $GPG_KEYS; do \ - gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ - done \ && curl -fSL "http://php.net/get/$PHP_FILENAME/from/this/mirror" -o "$PHP_FILENAME" \ && echo "$PHP_SHA256 *$PHP_FILENAME" | sha256sum -c - \ && curl -fSL "http://php.net/get/$PHP_FILENAME.asc/from/this/mirror" -o "$PHP_FILENAME.asc" \ + && export GNUPGHOME="$(mktemp -d)" \ + && for key in $GPG_KEYS; do \ + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ + done \ && gpg --batch --verify "$PHP_FILENAME.asc" "$PHP_FILENAME" \ + && rm -r "$GNUPGHOME" "$PHP_FILENAME.asc" \ && mkdir -p /usr/src \ && tar -Jxf "$PHP_FILENAME" -C /usr/src \ - && mv /usr/src/php-$PHP_VERSION /usr/src/php \ - && rm "$PHP_FILENAME"* \ + && mv "/usr/src/php-$PHP_VERSION" /usr/src/php \ + && rm "$PHP_FILENAME" \ && cd /usr/src/php \ && ./configure \ --with-config-file-path="$PHP_INI_DIR" \ --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \ $PHP_EXTRA_CONFIGURE_ARGS \ --disable-cgi \ +# --enable-mysqlnd is included here because it's harder to compile after the fact than extensions are (since it's a plugin for several extensions, not an extension in itself) --enable-mysqlnd \ --with-curl \ - --with-openssl \ --with-libedit \ + --with-openssl \ --with-zlib \ && make -j"$(getconf _NPROCESSORS_ONLN)" \ && make install \ diff --git a/7.0/fpm/alpine/docker-php-ext-enable b/7.0/fpm/alpine/docker-php-ext-enable index 5381d0d0..367aaf2b 100755 --- a/7.0/fpm/alpine/docker-php-ext-enable +++ b/7.0/fpm/alpine/docker-php-ext-enable @@ -4,15 +4,37 @@ set -e cd "$(php -r 'echo ini_get("extension_dir");')" usage() { - echo "usage: $0 module-name [module-name ...]" + echo "usage: $0 [options] module-name [module-name ...]" echo " ie: $0 gd mysqli" echo " $0 pdo pdo_mysql" + echo " $0 --ini-name 0-apc.ini apcu apc" echo echo 'Possible values for module-name:' echo $(find -maxdepth 1 -type f -name '*.so' -exec basename '{}' ';' | sort) } -modules="" +opts="$(getopt -o 'h?' --long 'help,ini-name:' -- "$@" || { usage >&2 && false; })" +eval set -- "$opts" + +iniName= +while true; do + flag="$1" + shift + case "$flag" in + --help|-h|'-?') usage && exit 0 ;; + --ini-name) iniName="$1" && shift ;; + --) break ;; + *) + { + echo "error: unknown flag: $flag" + usage + } >&2 + exit 1 + ;; + esac +done + +modules= for module; do if [ -z "$module" ]; then continue @@ -35,8 +57,8 @@ if [ -z "$modules" ]; then exit 1 fi -for module in ${modules}; do - if grep -q zend_extension_entry "$module"; then +for module in $modules; do + if nm -g "$module" | grep -q ' zend_extension_entry$'; then # https://wiki.php.net/internals/extensions#loading_zend_extensions line="zend_extension=$(readlink -f "$module")" else @@ -54,7 +76,7 @@ for module in ${modules}; do continue fi - ini="/usr/local/etc/php/conf.d/docker-php-ext-$ext.ini" + ini="/usr/local/etc/php/conf.d/${iniName:-"docker-php-ext-$ext.ini"}" if ! grep -q "$line" "$ini" 2>/dev/null; then echo "$line" >> "$ini" fi diff --git a/7.0/fpm/alpine/docker-php-ext-install b/7.0/fpm/alpine/docker-php-ext-install index 68309ff9..67180a86 100755 --- a/7.0/fpm/alpine/docker-php-ext-install +++ b/7.0/fpm/alpine/docker-php-ext-install @@ -61,7 +61,11 @@ for ext in $exts; do [ -e Makefile ] || docker-php-ext-configure "$ext" make -j"$j" make -j"$j" install - ls modules/*.so | cut -d/ -f2 | xargs -r docker-php-ext-enable + find modules \ + -maxdepth 1 \ + -name '*.so' \ + -exec basename '{}' ';' \ + | xargs -r docker-php-ext-enable make -j"$j" clean ) done diff --git a/7.0/fpm/docker-php-ext-configure b/7.0/fpm/docker-php-ext-configure index 3d21b5bb..39947c8f 100755 --- a/7.0/fpm/docker-php-ext-configure +++ b/7.0/fpm/docker-php-ext-configure @@ -1,9 +1,9 @@ -#!/bin/bash +#!/bin/sh set -e ext="$1" extDir="/usr/src/php/ext/$ext" -if [ -z "$ext" -o ! -d "$extDir" ]; then +if [ -z "$ext" ] || ! [ -d "$extDir" ]; then echo >&2 "usage: $0 ext-name [configure flags]" echo >&2 " ie: $0 gd --with-jpeg-dir=/usr/local/something" echo >&2 diff --git a/7.0/fpm/docker-php-ext-enable b/7.0/fpm/docker-php-ext-enable index edb07ed8..367aaf2b 100755 --- a/7.0/fpm/docker-php-ext-enable +++ b/7.0/fpm/docker-php-ext-enable @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -e cd "$(php -r 'echo ini_get("extension_dir");')" @@ -34,32 +34,30 @@ while true; do esac done -modules=() -while [ $# -gt 0 ]; do - module="$1" - shift +modules= +for module; do if [ -z "$module" ]; then continue fi - if [ -f "$module.so" -a ! -f "$module" ]; then + if [ -f "$module.so" ] && ! [ -f "$module" ]; then # allow ".so" to be optional - module+='.so' + module="$module.so" fi - if [ ! -f "$module" ]; then + if ! [ -f "$module" ]; then echo >&2 "error: $(readlink -f "$module") does not exist" echo >&2 usage >&2 exit 1 fi - modules+=( "$module" ) + modules="$modules $module" done -if [ "${#modules[@]}" -eq 0 ]; then +if [ -z "$modules" ]; then usage >&2 exit 1 fi -for module in "${modules[@]}"; do +for module in $modules; do if nm -g "$module" | grep -q ' zend_extension_entry$'; then # https://wiki.php.net/internals/extensions#loading_zend_extensions line="zend_extension=$(readlink -f "$module")" diff --git a/7.0/fpm/docker-php-ext-install b/7.0/fpm/docker-php-ext-install index 2c488cce..67180a86 100755 --- a/7.0/fpm/docker-php-ext-install +++ b/7.0/fpm/docker-php-ext-install @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -e cd /usr/src/php/ext @@ -36,10 +36,8 @@ while true; do esac done -exts=() -while [ $# -gt 0 ]; do - ext="$1" - shift +exts= +for ext; do if [ -z "$ext" ]; then continue fi @@ -49,21 +47,25 @@ while [ $# -gt 0 ]; do usage >&2 exit 1 fi - exts+=( "$ext" ) + exts="$exts $ext" done -if [ "${#exts[@]}" -eq 0 ]; then +if [ -z "$exts" ]; then usage >&2 exit 1 fi -for ext in "${exts[@]}"; do +for ext in $exts; do ( cd "$ext" [ -e Makefile ] || docker-php-ext-configure "$ext" make -j"$j" make -j"$j" install - find modules -maxdepth 1 -name '*.so' -exec basename '{}' ';' | xargs --no-run-if-empty --verbose docker-php-ext-enable + find modules \ + -maxdepth 1 \ + -name '*.so' \ + -exec basename '{}' ';' \ + | xargs -r docker-php-ext-enable make -j"$j" clean ) done diff --git a/7.0/zts/Dockerfile b/7.0/zts/Dockerfile index ee16d66e..c1a93bc1 100644 --- a/7.0/zts/Dockerfile +++ b/7.0/zts/Dockerfile @@ -1,10 +1,25 @@ FROM debian:jessie -# persistent / runtime deps -RUN apt-get update && apt-get install -y ca-certificates curl librecode0 libsqlite3-0 libxml2 --no-install-recommends && rm -r /var/lib/apt/lists/* - # phpize deps -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/* +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/* + +# persistent / runtime deps +RUN apt-get update && apt-get install -y \ + ca-certificates \ + curl \ + libedit2 \ + libsqlite3-0 \ + libxml2 \ + --no-install-recommends && rm -r /var/lib/apt/lists/* ENV PHP_INI_DIR /usr/local/etc/php RUN mkdir -p $PHP_INI_DIR/conf.d @@ -14,52 +29,51 @@ ENV PHP_EXTRA_CONFIGURE_ARGS --enable-maintainer-zts #### ENV GPG_KEYS 1A4E8B7277C42E53DBA9C7B9BCAA30EA9C0D5763 -RUN set -xe \ - && for key in $GPG_KEYS; do \ - gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ - done ENV PHP_VERSION 7.0.4 ENV PHP_FILENAME php-7.0.4.tar.xz ENV PHP_SHA256 584e0e374e357a71b6e95175a2947d787453afc7f9ab7c55651c10491c4df532 -# --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) -RUN buildDeps=" \ +RUN set -xe \ + && buildDeps=" \ $PHP_EXTRA_BUILD_DEPS \ libcurl4-openssl-dev \ - libreadline6-dev \ - librecode-dev \ + libedit-dev \ libsqlite3-dev \ libssl-dev \ libxml2-dev \ xz-utils \ " \ - && set -x \ && apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \ && curl -fSL "http://php.net/get/$PHP_FILENAME/from/this/mirror" -o "$PHP_FILENAME" \ && echo "$PHP_SHA256 *$PHP_FILENAME" | sha256sum -c - \ && curl -fSL "http://php.net/get/$PHP_FILENAME.asc/from/this/mirror" -o "$PHP_FILENAME.asc" \ + && export GNUPGHOME="$(mktemp -d)" \ + && for key in $GPG_KEYS; do \ + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ + done \ && gpg --batch --verify "$PHP_FILENAME.asc" "$PHP_FILENAME" \ + && rm -r "$GNUPGHOME" "$PHP_FILENAME.asc" \ && mkdir -p /usr/src/php \ && tar -xf "$PHP_FILENAME" -C /usr/src/php --strip-components=1 \ - && rm "$PHP_FILENAME"* \ + && rm "$PHP_FILENAME" \ && cd /usr/src/php \ && ./configure \ --with-config-file-path="$PHP_INI_DIR" \ --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \ $PHP_EXTRA_CONFIGURE_ARGS \ --disable-cgi \ +# --enable-mysqlnd is included here because it's harder to compile after the fact than extensions are (since it's a plugin for several extensions, not an extension in itself) --enable-mysqlnd \ --with-curl \ + --with-libedit \ --with-openssl \ - --with-readline \ - --with-recode \ --with-zlib \ && make -j"$(nproc)" \ && make install \ && { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \ - && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps \ - && make clean + && make clean \ + && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps COPY docker-php-ext-* /usr/local/bin/ diff --git a/7.0/zts/alpine/Dockerfile b/7.0/zts/alpine/Dockerfile new file mode 100644 index 00000000..f1b94084 --- /dev/null +++ b/7.0/zts/alpine/Dockerfile @@ -0,0 +1,92 @@ +FROM alpine:3.3 + +# phpize deps +RUN apk add --no-cache --virtual .phpize-deps \ + autoconf \ + file \ + g++ \ + gcc \ + libc-dev \ + make \ + pkgconf \ + re2c + +# persistent / runtime deps +RUN apk add --no-cache --virtual .persistent-deps \ + ca-certificates \ + curl + +# ensure www-data user exists +RUN set -x \ + && addgroup -g 82 -S www-data \ + && adduser -u 82 -D -S -G www-data www-data +# 82 is the standard uid/gid for "www-data" in Alpine +# http://git.alpinelinux.org/cgit/aports/tree/main/apache2/apache2.pre-install?h=v3.3.2 +# http://git.alpinelinux.org/cgit/aports/tree/main/lighttpd/lighttpd.pre-install?h=v3.3.2 +# http://git.alpinelinux.org/cgit/aports/tree/main/nginx-initscripts/nginx-initscripts.pre-install?h=v3.3.2 + +ENV PHP_INI_DIR /usr/local/etc/php +RUN mkdir -p $PHP_INI_DIR/conf.d + +#### +ENV PHP_EXTRA_CONFIGURE_ARGS --enable-maintainer-zts +#### + +ENV GPG_KEYS 1A4E8B7277C42E53DBA9C7B9BCAA30EA9C0D5763 + +ENV PHP_VERSION 7.0.4 +ENV PHP_FILENAME php-7.0.4.tar.xz +ENV PHP_SHA256 584e0e374e357a71b6e95175a2947d787453afc7f9ab7c55651c10491c4df532 + +RUN set -xe \ + && apk add --no-cache --virtual .build-deps \ + curl-dev \ + gnupg \ + libedit-dev \ + libxml2-dev \ + openssl-dev \ + sqlite-dev \ + && curl -fSL "http://php.net/get/$PHP_FILENAME/from/this/mirror" -o "$PHP_FILENAME" \ + && echo "$PHP_SHA256 *$PHP_FILENAME" | sha256sum -c - \ + && curl -fSL "http://php.net/get/$PHP_FILENAME.asc/from/this/mirror" -o "$PHP_FILENAME.asc" \ + && export GNUPGHOME="$(mktemp -d)" \ + && for key in $GPG_KEYS; do \ + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ + done \ + && gpg --batch --verify "$PHP_FILENAME.asc" "$PHP_FILENAME" \ + && rm -r "$GNUPGHOME" "$PHP_FILENAME.asc" \ + && mkdir -p /usr/src \ + && tar -Jxf "$PHP_FILENAME" -C /usr/src \ + && mv "/usr/src/php-$PHP_VERSION" /usr/src/php \ + && rm "$PHP_FILENAME" \ + && cd /usr/src/php \ + && ./configure \ + --with-config-file-path="$PHP_INI_DIR" \ + --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \ + $PHP_EXTRA_CONFIGURE_ARGS \ + --disable-cgi \ +# --enable-mysqlnd is included here because it's harder to compile after the fact than extensions are (since it's a plugin for several extensions, not an extension in itself) + --enable-mysqlnd \ + --with-curl \ + --with-libedit \ + --with-openssl \ + --with-zlib \ + && make -j"$(getconf _NPROCESSORS_ONLN)" \ + && make install \ + && { find /usr/local/bin /usr/local/sbin -type f -perm +0111 -exec strip --strip-all '{}' + || true; } \ + && make clean \ + && runDeps="$( \ + scanelf --needed --nobanner --recursive /usr/local \ + | awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \ + | sort -u \ + | xargs -r apk info --installed \ + | sort -u \ + )" \ + && apk add --virtual .php-rundeps $runDeps \ + && apk del .build-deps + +COPY docker-php-ext-* /usr/local/bin/ + +#### +CMD ["php", "-a"] +#### diff --git a/7.0/zts/alpine/docker-php-ext-configure b/7.0/zts/alpine/docker-php-ext-configure new file mode 100755 index 00000000..39947c8f --- /dev/null +++ b/7.0/zts/alpine/docker-php-ext-configure @@ -0,0 +1,19 @@ +#!/bin/sh +set -e + +ext="$1" +extDir="/usr/src/php/ext/$ext" +if [ -z "$ext" ] || ! [ -d "$extDir" ]; then + echo >&2 "usage: $0 ext-name [configure flags]" + echo >&2 " ie: $0 gd --with-jpeg-dir=/usr/local/something" + echo >&2 + echo >&2 'Possible values for ext-name:' + echo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort) + exit 1 +fi +shift + +set -x +cd "$extDir" +phpize +./configure "$@" diff --git a/7.0/zts/alpine/docker-php-ext-enable b/7.0/zts/alpine/docker-php-ext-enable new file mode 100755 index 00000000..367aaf2b --- /dev/null +++ b/7.0/zts/alpine/docker-php-ext-enable @@ -0,0 +1,83 @@ +#!/bin/sh +set -e + +cd "$(php -r 'echo ini_get("extension_dir");')" + +usage() { + echo "usage: $0 [options] module-name [module-name ...]" + echo " ie: $0 gd mysqli" + echo " $0 pdo pdo_mysql" + echo " $0 --ini-name 0-apc.ini apcu apc" + echo + echo 'Possible values for module-name:' + echo $(find -maxdepth 1 -type f -name '*.so' -exec basename '{}' ';' | sort) +} + +opts="$(getopt -o 'h?' --long 'help,ini-name:' -- "$@" || { usage >&2 && false; })" +eval set -- "$opts" + +iniName= +while true; do + flag="$1" + shift + case "$flag" in + --help|-h|'-?') usage && exit 0 ;; + --ini-name) iniName="$1" && shift ;; + --) break ;; + *) + { + echo "error: unknown flag: $flag" + usage + } >&2 + exit 1 + ;; + esac +done + +modules= +for module; do + if [ -z "$module" ]; then + continue + fi + if [ -f "$module.so" ] && ! [ -f "$module" ]; then + # allow ".so" to be optional + module="$module.so" + fi + if ! [ -f "$module" ]; then + echo >&2 "error: $(readlink -f "$module") does not exist" + echo >&2 + usage >&2 + exit 1 + fi + modules="$modules $module" +done + +if [ -z "$modules" ]; then + usage >&2 + exit 1 +fi + +for module in $modules; do + if nm -g "$module" | grep -q ' zend_extension_entry$'; then + # https://wiki.php.net/internals/extensions#loading_zend_extensions + line="zend_extension=$(readlink -f "$module")" + else + line="extension=$module" + fi + + ext="$(basename "$module")" + ext="${ext%.*}" + if php -r 'exit(extension_loaded("'"$ext"'") ? 0 : 1);'; then + # this isn't perfect, but it's better than nothing + # (for example, 'opcache.so' presents inside PHP as 'Zend OPcache', not 'opcache') + echo >&2 + echo >&2 "warning: $ext ($module) is already loaded!" + echo >&2 + continue + fi + + ini="/usr/local/etc/php/conf.d/${iniName:-"docker-php-ext-$ext.ini"}" + if ! grep -q "$line" "$ini" 2>/dev/null; then + echo "$line" >> "$ini" + fi +done diff --git a/7.0/zts/alpine/docker-php-ext-install b/7.0/zts/alpine/docker-php-ext-install new file mode 100755 index 00000000..67180a86 --- /dev/null +++ b/7.0/zts/alpine/docker-php-ext-install @@ -0,0 +1,71 @@ +#!/bin/sh +set -e + +cd /usr/src/php/ext + +usage() { + echo "usage: $0 [-jN] ext-name [ext-name ...]" + echo " ie: $0 gd mysqli" + echo " $0 pdo pdo_mysql" + echo " $0 -j5 gd mbstring mysqli pdo pdo_mysql shmop" + echo + echo 'if custom ./configure arguments are necessary, see docker-php-ext-configure' + echo + echo 'Possible values for ext-name:' + echo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort) +} + +opts="$(getopt -o 'h?j:' --long 'help,jobs:' -- "$@" || { usage >&2 && false; })" +eval set -- "$opts" + +j=1 +while true; do + flag="$1" + shift + case "$flag" in + --help|-h|'-?') usage && exit 0 ;; + --jobs|-j) j="$1" && shift ;; + --) break ;; + *) + { + echo "error: unknown flag: $flag" + usage + } >&2 + exit 1 + ;; + esac +done + +exts= +for ext; do + if [ -z "$ext" ]; then + continue + fi + if [ ! -d "$ext" ]; then + echo >&2 "error: $(pwd -P)/$ext does not exist" + echo >&2 + usage >&2 + exit 1 + fi + exts="$exts $ext" +done + +if [ -z "$exts" ]; then + usage >&2 + exit 1 +fi + +for ext in $exts; do + ( + cd "$ext" + [ -e Makefile ] || docker-php-ext-configure "$ext" + make -j"$j" + make -j"$j" install + find modules \ + -maxdepth 1 \ + -name '*.so' \ + -exec basename '{}' ';' \ + | xargs -r docker-php-ext-enable + make -j"$j" clean + ) +done diff --git a/7.0/zts/docker-php-ext-configure b/7.0/zts/docker-php-ext-configure index 3d21b5bb..39947c8f 100755 --- a/7.0/zts/docker-php-ext-configure +++ b/7.0/zts/docker-php-ext-configure @@ -1,9 +1,9 @@ -#!/bin/bash +#!/bin/sh set -e ext="$1" extDir="/usr/src/php/ext/$ext" -if [ -z "$ext" -o ! -d "$extDir" ]; then +if [ -z "$ext" ] || ! [ -d "$extDir" ]; then echo >&2 "usage: $0 ext-name [configure flags]" echo >&2 " ie: $0 gd --with-jpeg-dir=/usr/local/something" echo >&2 diff --git a/7.0/zts/docker-php-ext-enable b/7.0/zts/docker-php-ext-enable index edb07ed8..367aaf2b 100755 --- a/7.0/zts/docker-php-ext-enable +++ b/7.0/zts/docker-php-ext-enable @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -e cd "$(php -r 'echo ini_get("extension_dir");')" @@ -34,32 +34,30 @@ while true; do esac done -modules=() -while [ $# -gt 0 ]; do - module="$1" - shift +modules= +for module; do if [ -z "$module" ]; then continue fi - if [ -f "$module.so" -a ! -f "$module" ]; then + if [ -f "$module.so" ] && ! [ -f "$module" ]; then # allow ".so" to be optional - module+='.so' + module="$module.so" fi - if [ ! -f "$module" ]; then + if ! [ -f "$module" ]; then echo >&2 "error: $(readlink -f "$module") does not exist" echo >&2 usage >&2 exit 1 fi - modules+=( "$module" ) + modules="$modules $module" done -if [ "${#modules[@]}" -eq 0 ]; then +if [ -z "$modules" ]; then usage >&2 exit 1 fi -for module in "${modules[@]}"; do +for module in $modules; do if nm -g "$module" | grep -q ' zend_extension_entry$'; then # https://wiki.php.net/internals/extensions#loading_zend_extensions line="zend_extension=$(readlink -f "$module")" diff --git a/7.0/zts/docker-php-ext-install b/7.0/zts/docker-php-ext-install index 2c488cce..67180a86 100755 --- a/7.0/zts/docker-php-ext-install +++ b/7.0/zts/docker-php-ext-install @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -e cd /usr/src/php/ext @@ -36,10 +36,8 @@ while true; do esac done -exts=() -while [ $# -gt 0 ]; do - ext="$1" - shift +exts= +for ext; do if [ -z "$ext" ]; then continue fi @@ -49,21 +47,25 @@ while [ $# -gt 0 ]; do usage >&2 exit 1 fi - exts+=( "$ext" ) + exts="$exts $ext" done -if [ "${#exts[@]}" -eq 0 ]; then +if [ -z "$exts" ]; then usage >&2 exit 1 fi -for ext in "${exts[@]}"; do +for ext in $exts; do ( cd "$ext" [ -e Makefile ] || docker-php-ext-configure "$ext" make -j"$j" make -j"$j" install - find modules -maxdepth 1 -name '*.so' -exec basename '{}' ';' | xargs --no-run-if-empty --verbose docker-php-ext-enable + find modules \ + -maxdepth 1 \ + -name '*.so' \ + -exec basename '{}' ';' \ + | xargs -r docker-php-ext-enable make -j"$j" clean ) done