{"action":"created","issue":{"url":"https://api.github.com/repos/docker-library/official-images/issues/1942","repository_url":"https://api.github.com/repos/docker-library/official-images","labels_url":"https://api.github.com/repos/docker-library/official-images/issues/1942/labels{/name}","comments_url":"https://api.github.com/repos/docker-library/official-images/issues/1942/comments","events_url":"https://api.github.com/repos/docker-library/official-images/issues/1942/events","html_url":"https://github.com/docker-library/official-images/pull/1942","id":165431786,"number":1942,"title":"Updates to drupal, haproxy, memcached, mongo, owncloud, php, and tomcat","user":{"login":"yosifkit","id":896423,"avatar_url":"https://avatars.githubusercontent.com/u/896423?v=3","gravatar_id":"","url":"https://api.github.com/users/yosifkit","html_url":"https://github.com/yosifkit","followers_url":"https://api.github.com/users/yosifkit/followers","following_url":"https://api.github.com/users/yosifkit/following{/other_user}","gists_url":"https://api.github.com/users/yosifkit/gists{/gist_id}","starred_url":"https://api.github.com/users/yosifkit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yosifkit/subscriptions","organizations_url":"https://api.github.com/users/yosifkit/orgs","repos_url":"https://api.github.com/users/yosifkit/repos","events_url":"https://api.github.com/users/yosifkit/events{/privacy}","received_events_url":"https://api.github.com/users/yosifkit/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/docker-library/official-images/labels/library/drupal","name":"library/drupal","color":"ededed"},{"url":"https://api.github.com/repos/docker-library/official-images/labels/library/haproxy","name":"library/haproxy","color":"ededed"},{"url":"https://api.github.com/repos/docker-library/official-images/labels/library/memcached","name":"library/memcached","color":"ededed"},{"url":"https://api.github.com/repos/docker-library/official-images/labels/library/mongo","name":"library/mongo","color":"ededed"},{"url":"https://api.github.com/repos/docker-library/official-images/labels/library/owncloud","name":"library/owncloud","color":"ededed"},{"url":"https://api.github.com/repos/docker-library/official-images/labels/library/php","name":"library/php","color":"ededed"},{"url":"https://api.github.com/repos/docker-library/official-images/labels/library/tomcat","name":"library/tomcat","color":"ededed"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-07-13T22:01:24Z","updated_at":"2016-07-13T22:19:44Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/docker-library/official-images/pulls/1942","html_url":"https://github.com/docker-library/official-images/pull/1942","diff_url":"https://github.com/docker-library/official-images/pull/1942.diff","patch_url":"https://github.com/docker-library/official-images/pull/1942.patch"},"body":" - `drupal` bump `8.1.6` and https://github.com/docker-library/drupal/pull/51\r\n - `haproxy` bump to `1.6.7`\r\n - `memcached` bump to `1.4.29`\r\n - `mongo` bump to `3.2.8`\r\n - `owncloud` https://github.com/docker-library/owncloud/pull/74 and https://github.com/docker-library/owncloud/pull/75\r\n - `php` https://github.com/docker-library/php/pull/256\r\n - `tomcat` bump to `8.5.4` and `9.0.0.M9`"},"comment":{"url":"https://api.github.com/repos/docker-library/official-images/issues/comments/232503933","html_url":"https://github.com/docker-library/official-images/pull/1942#issuecomment-232503933","issue_url":"https://api.github.com/repos/docker-library/official-images/issues/1942","id":232503933,"user":{"login":"tianon","id":161631,"avatar_url":"https://avatars.githubusercontent.com/u/161631?v=3","gravatar_id":"","url":"https://api.github.com/users/tianon","html_url":"https://github.com/tianon","followers_url":"https://api.github.com/users/tianon/followers","following_url":"https://api.github.com/users/tianon/following{/other_user}","gists_url":"https://api.github.com/users/tianon/gists{/gist_id}","starred_url":"https://api.github.com/users/tianon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tianon/subscriptions","organizations_url":"https://api.github.com/users/tianon/orgs","repos_url":"https://api.github.com/users/tianon/repos","events_url":"https://api.github.com/users/tianon/events{/privacy}","received_events_url":"https://api.github.com/users/tianon/received_events","type":"User","site_admin":false},"created_at":"2016-07-13T22:19:43Z","updated_at":"2016-07-13T22:19:43Z","body":"```diff\r\ndiff --git a/drupal_7-fpm/Dockerfile b/drupal_7-fpm/Dockerfile\r\nindex 995bc17..ea7dd6e 100644\r\n--- a/drupal_7-fpm/Dockerfile\r\n+++ b/drupal_7-fpm/Dockerfile\r\n@@ -1,5 +1,5 @@\r\n # from https://www.drupal.org/requirements/php#drupalversions\r\n-FROM php:5.6-fpm\r\n+FROM php:7.0-fpm\r\n \r\n # install the PHP extensions we need\r\n RUN apt-get update && apt-get install -y libpng12-dev libjpeg-dev libpq-dev \\\r\ndiff --git a/drupal_7/Dockerfile b/drupal_7/Dockerfile\r\nindex ecb5e2a..4c6ebef 100644\r\n--- a/drupal_7/Dockerfile\r\n+++ b/drupal_7/Dockerfile\r\n@@ -1,5 +1,5 @@\r\n # from https://www.drupal.org/requirements/php#drupalversions\r\n-FROM php:5.6-apache\r\n+FROM php:7.0-apache\r\n \r\n RUN a2enmod rewrite\r\n \r\ndiff --git a/drupal_fpm/Dockerfile b/drupal_fpm/Dockerfile\r\nindex 952e1ee..055fbb1 100644\r\n--- a/drupal_fpm/Dockerfile\r\n+++ b/drupal_fpm/Dockerfile\r\n@@ -21,8 +21,8 @@ RUN { \\\r\n WORKDIR /var/www/html\r\n \r\n # https://www.drupal.org/node/3060/release\r\n-ENV DRUPAL_VERSION 8.1.5\r\n-ENV DRUPAL_MD5 0b30a3711d922c5348d6119e5124243b\r\n+ENV DRUPAL_VERSION 8.1.6\r\n+ENV DRUPAL_MD5 f3fdd2f9266938c2c7afc091e8d6e6d1\r\n \r\n RUN curl -fSL \"http://ftp.drupal.org/files/projects/drupal-${DRUPAL_VERSION}.tar.gz\" -o drupal.tar.gz \\\r\n \t&& echo \"${DRUPAL_MD5} *drupal.tar.gz\" | md5sum -c - \\\r\ndiff --git a/drupal_latest/Dockerfile b/drupal_latest/Dockerfile\r\nindex 4010b50..976d0a2 100644\r\n--- a/drupal_latest/Dockerfile\r\n+++ b/drupal_latest/Dockerfile\r\n@@ -23,8 +23,8 @@ RUN { \\\r\n WORKDIR /var/www/html\r\n \r\n # https://www.drupal.org/node/3060/release\r\n-ENV DRUPAL_VERSION 8.1.5\r\n-ENV DRUPAL_MD5 0b30a3711d922c5348d6119e5124243b\r\n+ENV DRUPAL_VERSION 8.1.6\r\n+ENV DRUPAL_MD5 f3fdd2f9266938c2c7afc091e8d6e6d1\r\n \r\n RUN curl -fSL \"http://ftp.drupal.org/files/projects/drupal-${DRUPAL_VERSION}.tar.gz\" -o drupal.tar.gz \\\r\n \t&& echo \"${DRUPAL_MD5} *drupal.tar.gz\" | md5sum -c - \\\r\ndiff --git a/haproxy_alpine/Dockerfile b/haproxy_alpine/Dockerfile\r\nindex d52bfba..0275a9a 100644\r\n--- a/haproxy_alpine/Dockerfile\r\n+++ b/haproxy_alpine/Dockerfile\r\n@@ -1,8 +1,8 @@\r\n FROM alpine:3.4\r\n \r\n ENV HAPROXY_MAJOR 1.6\r\n-ENV HAPROXY_VERSION 1.6.6\r\n-ENV HAPROXY_MD5 b418d83cf4f2da328f6eb8c255b8716b\r\n+ENV HAPROXY_VERSION 1.6.7\r\n+ENV HAPROXY_MD5 a046ed63b00347bd367b983529dd541f\r\n \r\n # see http://sources.debian.net/src/haproxy/1.5.8-1/debian/rules/ for some helpful navigation of the possible \"make\" arguments\r\n RUN set -x \\\r\ndiff --git a/haproxy_latest/Dockerfile b/haproxy_latest/Dockerfile\r\nindex b4626e4..4b2b9b8 100644\r\n--- a/haproxy_latest/Dockerfile\r\n+++ b/haproxy_latest/Dockerfile\r\n@@ -3,8 +3,8 @@ FROM debian:jessie\r\n RUN apt-get update && apt-get install -y libssl1.0.0 libpcre3 --no-install-recommends && rm -rf /var/lib/apt/lists/*\r\n \r\n ENV HAPROXY_MAJOR 1.6\r\n-ENV HAPROXY_VERSION 1.6.6\r\n-ENV HAPROXY_MD5 b418d83cf4f2da328f6eb8c255b8716b\r\n+ENV HAPROXY_VERSION 1.6.7\r\n+ENV HAPROXY_MD5 a046ed63b00347bd367b983529dd541f\r\n \r\n # see http://sources.debian.net/src/haproxy/1.5.8-1/debian/rules/ for some helpful navigation of the possible \"make\" arguments\r\n RUN buildDeps='curl gcc libc6-dev libpcre3-dev libssl-dev make' \\\r\ndiff --git a/memcached_alpine/Dockerfile b/memcached_alpine/Dockerfile\r\nindex 80ea9e1..bb35998 100644\r\n--- a/memcached_alpine/Dockerfile\r\n+++ b/memcached_alpine/Dockerfile\r\n@@ -3,8 +3,8 @@ FROM alpine:3.4\r\n # add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added\r\n RUN adduser -D memcache\r\n \r\n-ENV MEMCACHED_VERSION 1.4.28\r\n-ENV MEMCACHED_SHA1 c27662ca84933f5ebd837a86dde9378d05c1f200\r\n+ENV MEMCACHED_VERSION 1.4.29\r\n+ENV MEMCACHED_SHA1 8994b4d0dbcc8d536f3d6cd4763489a3c51ca44b\r\n \r\n RUN set -x \\\r\n \t&& apk add --no-cache --virtual .build-deps \\\r\ndiff --git a/memcached_latest/Dockerfile b/memcached_latest/Dockerfile\r\nindex 84473bb..a6d62f4 100644\r\n--- a/memcached_latest/Dockerfile\r\n+++ b/memcached_latest/Dockerfile\r\n@@ -7,8 +7,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \\\r\n \t\tlibevent-2.0-5 \\\r\n \t&& rm -rf /var/lib/apt/lists/*\r\n \r\n-ENV MEMCACHED_VERSION 1.4.28\r\n-ENV MEMCACHED_SHA1 c27662ca84933f5ebd837a86dde9378d05c1f200\r\n+ENV MEMCACHED_VERSION 1.4.29\r\n+ENV MEMCACHED_SHA1 8994b4d0dbcc8d536f3d6cd4763489a3c51ca44b\r\n \r\n RUN buildDeps=' \\\r\n \t\tgcc \\\r\ndiff --git a/mongo_latest/Dockerfile b/mongo_latest/Dockerfile\r\nindex 5929a5a..50b1ee6 100644\r\n--- a/mongo_latest/Dockerfile\r\n+++ b/mongo_latest/Dockerfile\r\n@@ -39,7 +39,7 @@ RUN set -ex \\\r\n \tdone\r\n \r\n ENV MONGO_MAJOR 3.2\r\n-ENV MONGO_VERSION 3.2.7\r\n+ENV MONGO_VERSION 3.2.8\r\n \r\n RUN echo \"deb http://repo.mongodb.org/apt/debian wheezy/mongodb-org/$MONGO_MAJOR main\" > /etc/apt/sources.list.d/mongodb-org.list\r\n \r\ndiff --git a/owncloud_8-fpm/Dockerfile b/owncloud_8-fpm/Dockerfile\r\nindex 1ed04e1..7f054d1 100644\r\n--- a/owncloud_8-fpm/Dockerfile\r\n+++ b/owncloud_8-fpm/Dockerfile\r\n@@ -6,6 +6,7 @@ RUN apt-get update && apt-get install -y \\\r\n \tlibfreetype6-dev \\\r\n \tlibicu-dev \\\r\n \tlibjpeg-dev \\\r\n+\tlibldap2-dev \\\r\n \tlibmcrypt-dev \\\r\n \tlibmemcached-dev \\\r\n \tlibpng12-dev \\\r\n@@ -15,7 +16,8 @@ RUN apt-get update && apt-get install -y \\\r\n \r\n # https://doc.owncloud.org/server/8.1/admin_manual/installation/source_installation.html#prerequisites\r\n RUN docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \\\r\n-\t&& docker-php-ext-install gd exif intl mbstring mcrypt mysql opcache pdo_mysql pdo_pgsql pgsql zip\r\n+\t&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \\\r\n+\t&& docker-php-ext-install exif gd intl ldap mbstring mcrypt mysql opcache pdo_mysql pdo_pgsql pgsql zip\r\n \r\n # set recommended PHP.ini settings\r\n # see https://secure.php.net/manual/en/opcache.installation.php\r\n@@ -33,7 +35,7 @@ RUN set -ex \\\r\n \t&& pecl install APCu-4.0.10 \\\r\n \t&& pecl install memcached-2.2.0 \\\r\n \t&& pecl install redis-2.2.8 \\\r\n-\t&& docker-php-ext-enable apcu redis memcached\r\n+\t&& docker-php-ext-enable apcu memcached redis\r\n \r\n ENV OWNCLOUD_VERSION 8.2.6\r\n VOLUME /var/www/html\r\ndiff --git a/owncloud_8.0-fpm/Dockerfile b/owncloud_8.0-fpm/Dockerfile\r\nindex 657b205..384d8ce 100644\r\n--- a/owncloud_8.0-fpm/Dockerfile\r\n+++ b/owncloud_8.0-fpm/Dockerfile\r\n@@ -6,6 +6,7 @@ RUN apt-get update && apt-get install -y \\\r\n \tlibfreetype6-dev \\\r\n \tlibicu-dev \\\r\n \tlibjpeg-dev \\\r\n+\tlibldap2-dev \\\r\n \tlibmcrypt-dev \\\r\n \tlibpng12-dev \\\r\n \tlibpq-dev \\\r\n@@ -14,7 +15,8 @@ RUN apt-get update && apt-get install -y \\\r\n \r\n # https://doc.owncloud.org/server/8.1/admin_manual/installation/source_installation.html#prerequisites\r\n RUN docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \\\r\n-\t&& docker-php-ext-install gd exif intl mbstring mcrypt mysql opcache pdo_mysql pdo_pgsql pgsql zip\r\n+\t&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \\\r\n+\t&& docker-php-ext-install exif gd intl ldap mbstring mcrypt mysql opcache pdo_mysql pdo_pgsql pgsql zip\r\n \r\n # set recommended PHP.ini settings\r\n # see https://secure.php.net/manual/en/opcache.installation.php\r\n@@ -28,7 +30,8 @@ RUN { \\\r\n \t} > /usr/local/etc/php/conf.d/opcache-recommended.ini\r\n \r\n # PECL extensions\r\n-RUN pecl install APCu-4.0.10 \\\r\n+RUN set -ex \\\r\n+\t&& pecl install APCu-4.0.10 \\\r\n \t&& docker-php-ext-enable apcu\r\n \r\n ENV OWNCLOUD_VERSION 8.0.13\r\ndiff --git a/owncloud_8.0/Dockerfile b/owncloud_8.0/Dockerfile\r\nindex 30208b0..15e110f 100644\r\n--- a/owncloud_8.0/Dockerfile\r\n+++ b/owncloud_8.0/Dockerfile\r\n@@ -6,6 +6,7 @@ RUN apt-get update && apt-get install -y \\\r\n \tlibfreetype6-dev \\\r\n \tlibicu-dev \\\r\n \tlibjpeg-dev \\\r\n+\tlibldap2-dev \\\r\n \tlibmcrypt-dev \\\r\n \tlibpng12-dev \\\r\n \tlibpq-dev \\\r\n@@ -14,7 +15,8 @@ RUN apt-get update && apt-get install -y \\\r\n \r\n # https://doc.owncloud.org/server/8.1/admin_manual/installation/source_installation.html#prerequisites\r\n RUN docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \\\r\n-\t&& docker-php-ext-install gd exif intl mbstring mcrypt mysql opcache pdo_mysql pdo_pgsql pgsql zip\r\n+\t&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \\\r\n+\t&& docker-php-ext-install exif gd intl ldap mbstring mcrypt mysql opcache pdo_mysql pdo_pgsql pgsql zip\r\n \r\n # set recommended PHP.ini settings\r\n # see https://secure.php.net/manual/en/opcache.installation.php\r\n@@ -26,13 +28,13 @@ RUN { \\\r\n \t\techo 'opcache.fast_shutdown=1'; \\\r\n \t\techo 'opcache.enable_cli=1'; \\\r\n \t} > /usr/local/etc/php/conf.d/opcache-recommended.ini\r\n+RUN a2enmod rewrite\r\n \r\n # PECL extensions\r\n-RUN pecl install APCu-4.0.10 \\\r\n+RUN set -ex \\\r\n+\t&& pecl install APCu-4.0.10 \\\r\n \t&& docker-php-ext-enable apcu\r\n \r\n-RUN a2enmod rewrite\r\n-\r\n ENV OWNCLOUD_VERSION 8.0.13\r\n VOLUME /var/www/html\r\n \r\ndiff --git a/owncloud_8.1-fpm/Dockerfile b/owncloud_8.1-fpm/Dockerfile\r\nindex 42890ce..c3ba02a 100644\r\n--- a/owncloud_8.1-fpm/Dockerfile\r\n+++ b/owncloud_8.1-fpm/Dockerfile\r\n@@ -6,6 +6,7 @@ RUN apt-get update && apt-get install -y \\\r\n \tlibfreetype6-dev \\\r\n \tlibicu-dev \\\r\n \tlibjpeg-dev \\\r\n+\tlibldap2-dev \\\r\n \tlibmcrypt-dev \\\r\n \tlibmemcached-dev \\\r\n \tlibpng12-dev \\\r\n@@ -15,7 +16,8 @@ RUN apt-get update && apt-get install -y \\\r\n \r\n # https://doc.owncloud.org/server/8.1/admin_manual/installation/source_installation.html#prerequisites\r\n RUN docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \\\r\n-\t&& docker-php-ext-install gd exif intl mbstring mcrypt mysql opcache pdo_mysql pdo_pgsql pgsql zip\r\n+\t&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \\\r\n+\t&& docker-php-ext-install exif gd intl ldap mbstring mcrypt mysql opcache pdo_mysql pdo_pgsql pgsql zip\r\n \r\n # set recommended PHP.ini settings\r\n # see https://secure.php.net/manual/en/opcache.installation.php\r\n@@ -33,7 +35,7 @@ RUN set -ex \\\r\n \t&& pecl install APCu-4.0.10 \\\r\n \t&& pecl install memcached-2.2.0 \\\r\n \t&& pecl install redis-2.2.8 \\\r\n-\t&& docker-php-ext-enable apcu redis memcached\r\n+\t&& docker-php-ext-enable apcu memcached redis\r\n \r\n ENV OWNCLOUD_VERSION 8.1.8\r\n VOLUME /var/www/html\r\ndiff --git a/owncloud_8.1/Dockerfile b/owncloud_8.1/Dockerfile\r\nindex d9743e1..836e5c9 100644\r\n--- a/owncloud_8.1/Dockerfile\r\n+++ b/owncloud_8.1/Dockerfile\r\n@@ -6,6 +6,7 @@ RUN apt-get update && apt-get install -y \\\r\n \tlibfreetype6-dev \\\r\n \tlibicu-dev \\\r\n \tlibjpeg-dev \\\r\n+\tlibldap2-dev \\\r\n \tlibmcrypt-dev \\\r\n \tlibmemcached-dev \\\r\n \tlibpng12-dev \\\r\n@@ -15,7 +16,8 @@ RUN apt-get update && apt-get install -y \\\r\n \r\n # https://doc.owncloud.org/server/8.1/admin_manual/installation/source_installation.html#prerequisites\r\n RUN docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \\\r\n-\t&& docker-php-ext-install gd exif intl mbstring mcrypt mysql opcache pdo_mysql pdo_pgsql pgsql zip\r\n+\t&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \\\r\n+\t&& docker-php-ext-install exif gd intl ldap mbstring mcrypt mysql opcache pdo_mysql pdo_pgsql pgsql zip\r\n \r\n # set recommended PHP.ini settings\r\n # see https://secure.php.net/manual/en/opcache.installation.php\r\n@@ -27,15 +29,14 @@ RUN { \\\r\n \t\techo 'opcache.fast_shutdown=1'; \\\r\n \t\techo 'opcache.enable_cli=1'; \\\r\n \t} > /usr/local/etc/php/conf.d/opcache-recommended.ini\r\n+RUN a2enmod rewrite\r\n \r\n # PECL extensions\r\n RUN set -ex \\\r\n \t&& pecl install APCu-4.0.10 \\\r\n \t&& pecl install memcached-2.2.0 \\\r\n \t&& pecl install redis-2.2.8 \\\r\n-\t&& docker-php-ext-enable apcu redis memcached\r\n-\r\n-RUN a2enmod rewrite\r\n+\t&& docker-php-ext-enable apcu memcached redis\r\n \r\n ENV OWNCLOUD_VERSION 8.1.8\r\n VOLUME /var/www/html\r\ndiff --git a/owncloud_8/Dockerfile b/owncloud_8/Dockerfile\r\nindex 2b0f2f4..d9ba067 100644\r\n--- a/owncloud_8/Dockerfile\r\n+++ b/owncloud_8/Dockerfile\r\n@@ -6,6 +6,7 @@ RUN apt-get update && apt-get install -y \\\r\n \tlibfreetype6-dev \\\r\n \tlibicu-dev \\\r\n \tlibjpeg-dev \\\r\n+\tlibldap2-dev \\\r\n \tlibmcrypt-dev \\\r\n \tlibmemcached-dev \\\r\n \tlibpng12-dev \\\r\n@@ -15,7 +16,8 @@ RUN apt-get update && apt-get install -y \\\r\n \r\n # https://doc.owncloud.org/server/8.1/admin_manual/installation/source_installation.html#prerequisites\r\n RUN docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \\\r\n-\t&& docker-php-ext-install gd exif intl mbstring mcrypt mysql opcache pdo_mysql pdo_pgsql pgsql zip\r\n+\t&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \\\r\n+\t&& docker-php-ext-install exif gd intl ldap mbstring mcrypt mysql opcache pdo_mysql pdo_pgsql pgsql zip\r\n \r\n # set recommended PHP.ini settings\r\n # see https://secure.php.net/manual/en/opcache.installation.php\r\n@@ -27,15 +29,14 @@ RUN { \\\r\n \t\techo 'opcache.fast_shutdown=1'; \\\r\n \t\techo 'opcache.enable_cli=1'; \\\r\n \t} > /usr/local/etc/php/conf.d/opcache-recommended.ini\r\n+RUN a2enmod rewrite\r\n \r\n # PECL extensions\r\n RUN set -ex \\\r\n \t&& pecl install APCu-4.0.10 \\\r\n \t&& pecl install memcached-2.2.0 \\\r\n \t&& pecl install redis-2.2.8 \\\r\n-\t&& docker-php-ext-enable apcu redis memcached\r\n-\r\n-RUN a2enmod rewrite\r\n+\t&& docker-php-ext-enable apcu memcached redis\r\n \r\n ENV OWNCLOUD_VERSION 8.2.6\r\n VOLUME /var/www/html\r\ndiff --git a/owncloud_fpm/Dockerfile b/owncloud_fpm/Dockerfile\r\nindex 46caedd..9d6c8f5 100644\r\n--- a/owncloud_fpm/Dockerfile\r\n+++ b/owncloud_fpm/Dockerfile\r\n@@ -6,6 +6,7 @@ RUN apt-get update && apt-get install -y \\\r\n \tlibfreetype6-dev \\\r\n \tlibicu-dev \\\r\n \tlibjpeg-dev \\\r\n+\tlibldap2-dev \\\r\n \tlibmcrypt-dev \\\r\n \tlibmemcached-dev \\\r\n \tlibpng12-dev \\\r\n@@ -15,7 +16,8 @@ RUN apt-get update && apt-get install -y \\\r\n \r\n # https://doc.owncloud.org/server/8.1/admin_manual/installation/source_installation.html#prerequisites\r\n RUN docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \\\r\n-\t&& docker-php-ext-install gd exif intl mbstring mcrypt mysql opcache pdo_mysql pdo_pgsql pgsql zip\r\n+\t&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \\\r\n+\t&& docker-php-ext-install exif gd intl ldap mbstring mcrypt mysql opcache pdo_mysql pdo_pgsql pgsql zip\r\n \r\n # set recommended PHP.ini settings\r\n # see https://secure.php.net/manual/en/opcache.installation.php\r\n@@ -33,7 +35,7 @@ RUN set -ex \\\r\n \t&& pecl install APCu-4.0.10 \\\r\n \t&& pecl install memcached-2.2.0 \\\r\n \t&& pecl install redis-2.2.8 \\\r\n-\t&& docker-php-ext-enable apcu redis memcached\r\n+\t&& docker-php-ext-enable apcu memcached redis\r\n \r\n ENV OWNCLOUD_VERSION 9.0.3\r\n VOLUME /var/www/html\r\ndiff --git a/owncloud_latest/Dockerfile b/owncloud_latest/Dockerfile\r\nindex 47e6bab..682f777 100644\r\n--- a/owncloud_latest/Dockerfile\r\n+++ b/owncloud_latest/Dockerfile\r\n@@ -6,6 +6,7 @@ RUN apt-get update && apt-get install -y \\\r\n \tlibfreetype6-dev \\\r\n \tlibicu-dev \\\r\n \tlibjpeg-dev \\\r\n+\tlibldap2-dev \\\r\n \tlibmcrypt-dev \\\r\n \tlibmemcached-dev \\\r\n \tlibpng12-dev \\\r\n@@ -15,7 +16,8 @@ RUN apt-get update && apt-get install -y \\\r\n \r\n # https://doc.owncloud.org/server/8.1/admin_manual/installation/source_installation.html#prerequisites\r\n RUN docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \\\r\n-\t&& docker-php-ext-install gd exif intl mbstring mcrypt mysql opcache pdo_mysql pdo_pgsql pgsql zip\r\n+\t&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \\\r\n+\t&& docker-php-ext-install exif gd intl ldap mbstring mcrypt mysql opcache pdo_mysql pdo_pgsql pgsql zip\r\n \r\n # set recommended PHP.ini settings\r\n # see https://secure.php.net/manual/en/opcache.installation.php\r\n@@ -27,15 +29,14 @@ RUN { \\\r\n \t\techo 'opcache.fast_shutdown=1'; \\\r\n \t\techo 'opcache.enable_cli=1'; \\\r\n \t} > /usr/local/etc/php/conf.d/opcache-recommended.ini\r\n+RUN a2enmod rewrite\r\n \r\n # PECL extensions\r\n RUN set -ex \\\r\n \t&& pecl install APCu-4.0.10 \\\r\n \t&& pecl install memcached-2.2.0 \\\r\n \t&& pecl install redis-2.2.8 \\\r\n-\t&& docker-php-ext-enable apcu redis memcached\r\n-\r\n-RUN a2enmod rewrite\r\n+\t&& docker-php-ext-enable apcu memcached redis\r\n \r\n ENV OWNCLOUD_VERSION 9.0.3\r\n VOLUME /var/www/html\r\ndiff --git a/php_5-alpine/Dockerfile b/php_5-alpine/Dockerfile\r\nindex 6225b38..c86c195 100644\r\n--- a/php_5-alpine/Dockerfile\r\n+++ b/php_5-alpine/Dockerfile\r\n@@ -12,7 +12,9 @@ ENV PHPIZE_DEPS \\\r\n \t\tre2c\r\n RUN apk add --no-cache --virtual .persistent-deps \\\r\n \t\tca-certificates \\\r\n-\t\tcurl\r\n+\t\tcurl \\\r\n+\t\ttar \\\r\n+\t\txz\r\n \r\n # ensure www-data user exists\r\n RUN set -x \\\r\n@@ -36,27 +38,32 @@ ENV PHP_FILENAME php-5.6.23.tar.xz\r\n ENV PHP_SHA256 39141e9a617af172aedbbacee7a63eb15502850f7cea20d759a9cffa7cfb0a1a\r\n \r\n RUN set -xe \\\r\n+\t&& apk add --no-cache --virtual .fetch-deps \\\r\n+\t\tgnupg \\\r\n+\t&& mkdir -p /usr/src \\\r\n+\t&& cd /usr/src/ \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o php.tar.xz \\\r\n+\t&& echo \"$PHP_SHA256 *php.tar.xz\" | sha256sum -c - \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o php.tar.xz.asc \\\r\n+\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n+\t&& for key in $GPG_KEYS; do \\\r\n+\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n+\tdone \\\r\n+\t&& gpg --batch --verify php.tar.xz.asc php.tar.xz \\\r\n+\t&& rm -r \"$GNUPGHOME\" \\\r\n+\t&& apk del .fetch-deps\r\n+\r\n+COPY docker-php-source /usr/local/bin/\r\n+\r\n+RUN set -xe \\\r\n \t&& apk add --no-cache --virtual .build-deps \\\r\n \t\t$PHPIZE_DEPS \\\r\n \t\tcurl-dev \\\r\n-\t\tgnupg \\\r\n \t\tlibedit-dev \\\r\n \t\tlibxml2-dev \\\r\n \t\topenssl-dev \\\r\n \t\tsqlite-dev \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o \"$PHP_FILENAME\" \\\r\n-\t&& echo \"$PHP_SHA256 *$PHP_FILENAME\" | sha256sum -c - \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o \"$PHP_FILENAME.asc\" \\\r\n-\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n-\t&& for key in $GPG_KEYS; do \\\r\n-\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n-\tdone \\\r\n-\t&& gpg --batch --verify \"$PHP_FILENAME.asc\" \"$PHP_FILENAME\" \\\r\n-\t&& rm -r \"$GNUPGHOME\" \"$PHP_FILENAME.asc\" \\\r\n-\t&& mkdir -p /usr/src \\\r\n-\t&& tar -Jxf \"$PHP_FILENAME\" -C /usr/src \\\r\n-\t&& mv \"/usr/src/php-$PHP_VERSION\" /usr/src/php \\\r\n-\t&& rm \"$PHP_FILENAME\" \\\r\n+\t&& docker-php-source extract \\\r\n \t&& cd /usr/src/php \\\r\n \t&& ./configure \\\r\n \t\t--with-config-file-path=\"$PHP_INI_DIR\" \\\r\n@@ -83,7 +90,8 @@ RUN set -xe \\\r\n \t\t\t| sort -u \\\r\n \t)\" \\\r\n \t&& apk add --no-cache --virtual .php-rundeps $runDeps \\\r\n-\t&& apk del .build-deps\r\n+\t&& apk del .build-deps \\\r\n+\t&& docker-php-source delete\r\n \r\n COPY docker-php-ext-* /usr/local/bin/\r\n \r\ndiff --git a/php_5-alpine/docker-php-ext-configure b/php_5-alpine/docker-php-ext-configure\r\nindex dd56be1..ac3e899 100755\r\n--- a/php_5-alpine/docker-php-ext-configure\r\n+++ b/php_5-alpine/docker-php-ext-configure\r\n@@ -2,13 +2,12 @@\r\n set -e\r\n \r\n ext=\"$1\"\r\n-extDir=\"/usr/src/php/ext/$ext\"\r\n-if [ -z \"$ext\" ] || ! [ -d \"$extDir\" ]; then\r\n+if [ -z \"$ext\" ] || ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n \techo >&2 \"usage: $0 ext-name [configure flags]\"\r\n \techo >&2 \"   ie: $0 gd --with-jpeg-dir=/usr/local/something\"\r\n \techo >&2\r\n \techo >&2 'Possible values for ext-name:'\r\n-\techo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n \texit 1\r\n fi\r\n shift\r\n@@ -28,7 +27,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+\r\n set -x\r\n-cd \"$extDir\"\r\n+cd \"/usr/src/php/ext/$ext\"\r\n phpize\r\n ./configure \"$@\"\r\ndiff --git a/php_5-alpine/docker-php-ext-install b/php_5-alpine/docker-php-ext-install\r\nindex 43927b4..f7fc78d 100755\r\n--- a/php_5-alpine/docker-php-ext-install\r\n+++ b/php_5-alpine/docker-php-ext-install\r\n@@ -1,8 +1,6 @@\r\n #!/bin/sh\r\n set -e\r\n \r\n-cd /usr/src/php/ext\r\n-\r\n usage() {\r\n \techo \"usage: $0 [-jN] ext-name [ext-name ...]\"\r\n \techo \"   ie: $0 gd mysqli\"\r\n@@ -12,7 +10,7 @@ usage() {\r\n \techo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'\r\n \techo\r\n \techo 'Possible values for ext-name:'\r\n-\techo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n }\r\n \r\n opts=\"$(getopt -o 'h?j:' --long 'help,jobs:' -- \"$@\" || { usage >&2 && false; })\"\r\n@@ -41,8 +39,8 @@ for ext; do\r\n \tif [ -z \"$ext\" ]; then\r\n \t\tcontinue\r\n \tfi\r\n-\tif [ ! -d \"$ext\" ]; then\r\n-\t\techo >&2 \"error: $(pwd -P)/$ext does not exist\"\r\n+\tif ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n+\t\techo >&2 \"error: /usr/src/php/ext/$ext does not exist\"\r\n \t\techo >&2\r\n \t\tusage >&2\r\n \t\texit 1\r\n@@ -72,6 +70,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+cd /usr/src/php/ext\r\n+\r\n for ext in $exts; do\r\n \t(\r\n \t\tcd \"$ext\"\r\n@@ -90,3 +91,4 @@ done\r\n if [ \"$pm\" = 'apk' ] && [ -n \"$apkDel\" ]; then\r\n \tapk del $apkDel\r\n fi\r\n+docker-php-source delete\r\ndiff --git a/php_5-alpine/docker-php-source b/php_5-alpine/docker-php-source\r\nnew file mode 100755\r\nindex 0000000..9020385\r\n--- /dev/null\r\n+++ b/php_5-alpine/docker-php-source\r\n@@ -0,0 +1,44 @@\r\n+#!/bin/sh\r\n+set -e\r\n+dir=/usr/src/php\r\n+\r\n+usage() {\r\n+\techo \"usage: $0 COMMAND\"\r\n+\techo\r\n+\techo \"Manage php source tarball lifecycle.\"\r\n+\techo\r\n+\techo \"Commands:\"\r\n+\techo \"   extract  extract php source tarball into directory $dir if not already done.\"\r\n+\techo \"   delete   delete extracted php source located into $dir if not already done.\"\r\n+\techo\r\n+}\r\n+\r\n+case \"$1\" in\r\n+\textract)\r\n+\t\tif [ -e \"$dir\" -a ! -d \"$dir\" ] ; then\r\n+\t\t\techo >&2 \"$dir exists and is not a directory\"\r\n+\t\t\texit 1\r\n+\t\tfi\r\n+\t\tif [ ! -d \"$dir\" ]; then\r\n+\t\t\tmkdir -p \"$dir\"\r\n+\t\t\ttar -Jxf /usr/src/php.tar.xz -C \"$dir\" --strip-components=1\r\n+\r\n+\t\t\tif [ ! -f /usr/src/php-available-exts ]; then\r\n+\t\t\t\tfind \"$dir/ext\" \\\r\n+\t\t\t\t\t\t-mindepth 2 \\\r\n+\t\t\t\t\t\t-maxdepth 2 \\\r\n+\t\t\t\t\t\t-type f \\\r\n+\t\t\t\t\t\t-name 'config.m4' \\\r\n+\t\t\t\t\t| xargs -n1 dirname | xargs -n1 basename | sort \\\r\n+\t\t\t\t> /usr/src/php-available-exts\r\n+\t\t\tfi\r\n+\t\tfi\r\n+\t\t;;\r\n+\tdelete)\r\n+\t\trm -rf \"$dir\"\r\n+\t\t;;\r\n+\t*)\r\n+\t\tusage\r\n+\t\texit 1\r\n+\t\t;;\r\n+esac\r\ndiff --git a/php_5-apache/Dockerfile b/php_5-apache/Dockerfile\r\nindex 7260d28..9ac3869 100644\r\n--- a/php_5-apache/Dockerfile\r\n+++ b/php_5-apache/Dockerfile\r\n@@ -17,6 +17,7 @@ RUN apt-get update && apt-get install -y \\\r\n \t\tlibedit2 \\\r\n \t\tlibsqlite3-0 \\\r\n \t\tlibxml2 \\\r\n+\t\txz-utils \\\r\n \t--no-install-recommends && rm -r /var/lib/apt/lists/*\r\n \r\n ENV PHP_INI_DIR /usr/local/etc/php\r\n@@ -79,6 +80,20 @@ ENV PHP_FILENAME php-5.6.23.tar.xz\r\n ENV PHP_SHA256 39141e9a617af172aedbbacee7a63eb15502850f7cea20d759a9cffa7cfb0a1a\r\n \r\n RUN set -xe \\\r\n+\t&& cd /usr/src/ \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o php.tar.xz \\\r\n+\t&& echo \"$PHP_SHA256 *php.tar.xz\" | sha256sum -c - \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o php.tar.xz.asc \\\r\n+\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n+\t&& for key in $GPG_KEYS; do \\\r\n+\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n+\tdone \\\r\n+\t&& gpg --batch --verify php.tar.xz.asc php.tar.xz \\\r\n+\t&& rm -r \"$GNUPGHOME\"\r\n+\r\n+COPY docker-php-source /usr/local/bin/\r\n+\r\n+RUN set -xe \\\r\n \t&& buildDeps=\" \\\r\n \t\t$PHP_EXTRA_BUILD_DEPS \\\r\n \t\tlibcurl4-openssl-dev \\\r\n@@ -86,21 +101,9 @@ RUN set -xe \\\r\n \t\tlibsqlite3-dev \\\r\n \t\tlibssl-dev \\\r\n \t\tlibxml2-dev \\\r\n-\t\txz-utils \\\r\n \t\" \\\r\n \t&& apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o \"$PHP_FILENAME\" \\\r\n-\t&& echo \"$PHP_SHA256 *$PHP_FILENAME\" | sha256sum -c - \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o \"$PHP_FILENAME.asc\" \\\r\n-\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n-\t&& for key in $GPG_KEYS; do \\\r\n-\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n-\tdone \\\r\n-\t&& gpg --batch --verify \"$PHP_FILENAME.asc\" \"$PHP_FILENAME\" \\\r\n-\t&& rm -r \"$GNUPGHOME\" \"$PHP_FILENAME.asc\" \\\r\n-\t&& mkdir -p /usr/src/php \\\r\n-\t&& tar -xf \"$PHP_FILENAME\" -C /usr/src/php --strip-components=1 \\\r\n-\t&& rm \"$PHP_FILENAME\" \\\r\n+\t&& docker-php-source extract \\\r\n \t&& cd /usr/src/php \\\r\n \t&& ./configure \\\r\n \t\t--with-config-file-path=\"$PHP_INI_DIR\" \\\r\n@@ -119,7 +122,8 @@ RUN set -xe \\\r\n \t&& make install \\\r\n \t&& { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \\\r\n \t&& make clean \\\r\n-\t&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps\r\n+\t&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps \\\r\n+\t&& docker-php-source delete\r\n \r\n COPY docker-php-ext-* /usr/local/bin/\r\n \r\ndiff --git a/php_5-apache/docker-php-ext-configure b/php_5-apache/docker-php-ext-configure\r\nindex dd56be1..ac3e899 100755\r\n--- a/php_5-apache/docker-php-ext-configure\r\n+++ b/php_5-apache/docker-php-ext-configure\r\n@@ -2,13 +2,12 @@\r\n set -e\r\n \r\n ext=\"$1\"\r\n-extDir=\"/usr/src/php/ext/$ext\"\r\n-if [ -z \"$ext\" ] || ! [ -d \"$extDir\" ]; then\r\n+if [ -z \"$ext\" ] || ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n \techo >&2 \"usage: $0 ext-name [configure flags]\"\r\n \techo >&2 \"   ie: $0 gd --with-jpeg-dir=/usr/local/something\"\r\n \techo >&2\r\n \techo >&2 'Possible values for ext-name:'\r\n-\techo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n \texit 1\r\n fi\r\n shift\r\n@@ -28,7 +27,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+\r\n set -x\r\n-cd \"$extDir\"\r\n+cd \"/usr/src/php/ext/$ext\"\r\n phpize\r\n ./configure \"$@\"\r\ndiff --git a/php_5-apache/docker-php-ext-install b/php_5-apache/docker-php-ext-install\r\nindex 43927b4..f7fc78d 100755\r\n--- a/php_5-apache/docker-php-ext-install\r\n+++ b/php_5-apache/docker-php-ext-install\r\n@@ -1,8 +1,6 @@\r\n #!/bin/sh\r\n set -e\r\n \r\n-cd /usr/src/php/ext\r\n-\r\n usage() {\r\n \techo \"usage: $0 [-jN] ext-name [ext-name ...]\"\r\n \techo \"   ie: $0 gd mysqli\"\r\n@@ -12,7 +10,7 @@ usage() {\r\n \techo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'\r\n \techo\r\n \techo 'Possible values for ext-name:'\r\n-\techo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n }\r\n \r\n opts=\"$(getopt -o 'h?j:' --long 'help,jobs:' -- \"$@\" || { usage >&2 && false; })\"\r\n@@ -41,8 +39,8 @@ for ext; do\r\n \tif [ -z \"$ext\" ]; then\r\n \t\tcontinue\r\n \tfi\r\n-\tif [ ! -d \"$ext\" ]; then\r\n-\t\techo >&2 \"error: $(pwd -P)/$ext does not exist\"\r\n+\tif ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n+\t\techo >&2 \"error: /usr/src/php/ext/$ext does not exist\"\r\n \t\techo >&2\r\n \t\tusage >&2\r\n \t\texit 1\r\n@@ -72,6 +70,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+cd /usr/src/php/ext\r\n+\r\n for ext in $exts; do\r\n \t(\r\n \t\tcd \"$ext\"\r\n@@ -90,3 +91,4 @@ done\r\n if [ \"$pm\" = 'apk' ] && [ -n \"$apkDel\" ]; then\r\n \tapk del $apkDel\r\n fi\r\n+docker-php-source delete\r\ndiff --git a/php_5-apache/docker-php-source b/php_5-apache/docker-php-source\r\nnew file mode 100755\r\nindex 0000000..9020385\r\n--- /dev/null\r\n+++ b/php_5-apache/docker-php-source\r\n@@ -0,0 +1,44 @@\r\n+#!/bin/sh\r\n+set -e\r\n+dir=/usr/src/php\r\n+\r\n+usage() {\r\n+\techo \"usage: $0 COMMAND\"\r\n+\techo\r\n+\techo \"Manage php source tarball lifecycle.\"\r\n+\techo\r\n+\techo \"Commands:\"\r\n+\techo \"   extract  extract php source tarball into directory $dir if not already done.\"\r\n+\techo \"   delete   delete extracted php source located into $dir if not already done.\"\r\n+\techo\r\n+}\r\n+\r\n+case \"$1\" in\r\n+\textract)\r\n+\t\tif [ -e \"$dir\" -a ! -d \"$dir\" ] ; then\r\n+\t\t\techo >&2 \"$dir exists and is not a directory\"\r\n+\t\t\texit 1\r\n+\t\tfi\r\n+\t\tif [ ! -d \"$dir\" ]; then\r\n+\t\t\tmkdir -p \"$dir\"\r\n+\t\t\ttar -Jxf /usr/src/php.tar.xz -C \"$dir\" --strip-components=1\r\n+\r\n+\t\t\tif [ ! -f /usr/src/php-available-exts ]; then\r\n+\t\t\t\tfind \"$dir/ext\" \\\r\n+\t\t\t\t\t\t-mindepth 2 \\\r\n+\t\t\t\t\t\t-maxdepth 2 \\\r\n+\t\t\t\t\t\t-type f \\\r\n+\t\t\t\t\t\t-name 'config.m4' \\\r\n+\t\t\t\t\t| xargs -n1 dirname | xargs -n1 basename | sort \\\r\n+\t\t\t\t> /usr/src/php-available-exts\r\n+\t\t\tfi\r\n+\t\tfi\r\n+\t\t;;\r\n+\tdelete)\r\n+\t\trm -rf \"$dir\"\r\n+\t\t;;\r\n+\t*)\r\n+\t\tusage\r\n+\t\texit 1\r\n+\t\t;;\r\n+esac\r\ndiff --git a/php_5-fpm-alpine/Dockerfile b/php_5-fpm-alpine/Dockerfile\r\nindex 055d94a..fa9ac9d 100644\r\n--- a/php_5-fpm-alpine/Dockerfile\r\n+++ b/php_5-fpm-alpine/Dockerfile\r\n@@ -12,7 +12,9 @@ ENV PHPIZE_DEPS \\\r\n \t\tre2c\r\n RUN apk add --no-cache --virtual .persistent-deps \\\r\n \t\tca-certificates \\\r\n-\t\tcurl\r\n+\t\tcurl \\\r\n+\t\ttar \\\r\n+\t\txz\r\n \r\n # ensure www-data user exists\r\n RUN set -x \\\r\n@@ -37,27 +39,32 @@ ENV PHP_FILENAME php-5.6.23.tar.xz\r\n ENV PHP_SHA256 39141e9a617af172aedbbacee7a63eb15502850f7cea20d759a9cffa7cfb0a1a\r\n \r\n RUN set -xe \\\r\n+\t&& apk add --no-cache --virtual .fetch-deps \\\r\n+\t\tgnupg \\\r\n+\t&& mkdir -p /usr/src \\\r\n+\t&& cd /usr/src/ \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o php.tar.xz \\\r\n+\t&& echo \"$PHP_SHA256 *php.tar.xz\" | sha256sum -c - \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o php.tar.xz.asc \\\r\n+\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n+\t&& for key in $GPG_KEYS; do \\\r\n+\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n+\tdone \\\r\n+\t&& gpg --batch --verify php.tar.xz.asc php.tar.xz \\\r\n+\t&& rm -r \"$GNUPGHOME\" \\\r\n+\t&& apk del .fetch-deps\r\n+\r\n+COPY docker-php-source /usr/local/bin/\r\n+\r\n+RUN set -xe \\\r\n \t&& apk add --no-cache --virtual .build-deps \\\r\n \t\t$PHPIZE_DEPS \\\r\n \t\tcurl-dev \\\r\n-\t\tgnupg \\\r\n \t\tlibedit-dev \\\r\n \t\tlibxml2-dev \\\r\n \t\topenssl-dev \\\r\n \t\tsqlite-dev \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o \"$PHP_FILENAME\" \\\r\n-\t&& echo \"$PHP_SHA256 *$PHP_FILENAME\" | sha256sum -c - \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o \"$PHP_FILENAME.asc\" \\\r\n-\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n-\t&& for key in $GPG_KEYS; do \\\r\n-\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n-\tdone \\\r\n-\t&& gpg --batch --verify \"$PHP_FILENAME.asc\" \"$PHP_FILENAME\" \\\r\n-\t&& rm -r \"$GNUPGHOME\" \"$PHP_FILENAME.asc\" \\\r\n-\t&& mkdir -p /usr/src \\\r\n-\t&& tar -Jxf \"$PHP_FILENAME\" -C /usr/src \\\r\n-\t&& mv \"/usr/src/php-$PHP_VERSION\" /usr/src/php \\\r\n-\t&& rm \"$PHP_FILENAME\" \\\r\n+\t&& docker-php-source extract \\\r\n \t&& cd /usr/src/php \\\r\n \t&& ./configure \\\r\n \t\t--with-config-file-path=\"$PHP_INI_DIR\" \\\r\n@@ -84,7 +91,8 @@ RUN set -xe \\\r\n \t\t\t| sort -u \\\r\n \t)\" \\\r\n \t&& apk add --no-cache --virtual .php-rundeps $runDeps \\\r\n-\t&& apk del .build-deps\r\n+\t&& apk del .build-deps \\\r\n+\t&& docker-php-source delete\r\n \r\n COPY docker-php-ext-* /usr/local/bin/\r\n \r\ndiff --git a/php_5-fpm-alpine/docker-php-ext-configure b/php_5-fpm-alpine/docker-php-ext-configure\r\nindex dd56be1..ac3e899 100755\r\n--- a/php_5-fpm-alpine/docker-php-ext-configure\r\n+++ b/php_5-fpm-alpine/docker-php-ext-configure\r\n@@ -2,13 +2,12 @@\r\n set -e\r\n \r\n ext=\"$1\"\r\n-extDir=\"/usr/src/php/ext/$ext\"\r\n-if [ -z \"$ext\" ] || ! [ -d \"$extDir\" ]; then\r\n+if [ -z \"$ext\" ] || ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n \techo >&2 \"usage: $0 ext-name [configure flags]\"\r\n \techo >&2 \"   ie: $0 gd --with-jpeg-dir=/usr/local/something\"\r\n \techo >&2\r\n \techo >&2 'Possible values for ext-name:'\r\n-\techo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n \texit 1\r\n fi\r\n shift\r\n@@ -28,7 +27,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+\r\n set -x\r\n-cd \"$extDir\"\r\n+cd \"/usr/src/php/ext/$ext\"\r\n phpize\r\n ./configure \"$@\"\r\ndiff --git a/php_5-fpm-alpine/docker-php-ext-install b/php_5-fpm-alpine/docker-php-ext-install\r\nindex 43927b4..f7fc78d 100755\r\n--- a/php_5-fpm-alpine/docker-php-ext-install\r\n+++ b/php_5-fpm-alpine/docker-php-ext-install\r\n@@ -1,8 +1,6 @@\r\n #!/bin/sh\r\n set -e\r\n \r\n-cd /usr/src/php/ext\r\n-\r\n usage() {\r\n \techo \"usage: $0 [-jN] ext-name [ext-name ...]\"\r\n \techo \"   ie: $0 gd mysqli\"\r\n@@ -12,7 +10,7 @@ usage() {\r\n \techo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'\r\n \techo\r\n \techo 'Possible values for ext-name:'\r\n-\techo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n }\r\n \r\n opts=\"$(getopt -o 'h?j:' --long 'help,jobs:' -- \"$@\" || { usage >&2 && false; })\"\r\n@@ -41,8 +39,8 @@ for ext; do\r\n \tif [ -z \"$ext\" ]; then\r\n \t\tcontinue\r\n \tfi\r\n-\tif [ ! -d \"$ext\" ]; then\r\n-\t\techo >&2 \"error: $(pwd -P)/$ext does not exist\"\r\n+\tif ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n+\t\techo >&2 \"error: /usr/src/php/ext/$ext does not exist\"\r\n \t\techo >&2\r\n \t\tusage >&2\r\n \t\texit 1\r\n@@ -72,6 +70,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+cd /usr/src/php/ext\r\n+\r\n for ext in $exts; do\r\n \t(\r\n \t\tcd \"$ext\"\r\n@@ -90,3 +91,4 @@ done\r\n if [ \"$pm\" = 'apk' ] && [ -n \"$apkDel\" ]; then\r\n \tapk del $apkDel\r\n fi\r\n+docker-php-source delete\r\ndiff --git a/php_5-fpm-alpine/docker-php-source b/php_5-fpm-alpine/docker-php-source\r\nnew file mode 100755\r\nindex 0000000..9020385\r\n--- /dev/null\r\n+++ b/php_5-fpm-alpine/docker-php-source\r\n@@ -0,0 +1,44 @@\r\n+#!/bin/sh\r\n+set -e\r\n+dir=/usr/src/php\r\n+\r\n+usage() {\r\n+\techo \"usage: $0 COMMAND\"\r\n+\techo\r\n+\techo \"Manage php source tarball lifecycle.\"\r\n+\techo\r\n+\techo \"Commands:\"\r\n+\techo \"   extract  extract php source tarball into directory $dir if not already done.\"\r\n+\techo \"   delete   delete extracted php source located into $dir if not already done.\"\r\n+\techo\r\n+}\r\n+\r\n+case \"$1\" in\r\n+\textract)\r\n+\t\tif [ -e \"$dir\" -a ! -d \"$dir\" ] ; then\r\n+\t\t\techo >&2 \"$dir exists and is not a directory\"\r\n+\t\t\texit 1\r\n+\t\tfi\r\n+\t\tif [ ! -d \"$dir\" ]; then\r\n+\t\t\tmkdir -p \"$dir\"\r\n+\t\t\ttar -Jxf /usr/src/php.tar.xz -C \"$dir\" --strip-components=1\r\n+\r\n+\t\t\tif [ ! -f /usr/src/php-available-exts ]; then\r\n+\t\t\t\tfind \"$dir/ext\" \\\r\n+\t\t\t\t\t\t-mindepth 2 \\\r\n+\t\t\t\t\t\t-maxdepth 2 \\\r\n+\t\t\t\t\t\t-type f \\\r\n+\t\t\t\t\t\t-name 'config.m4' \\\r\n+\t\t\t\t\t| xargs -n1 dirname | xargs -n1 basename | sort \\\r\n+\t\t\t\t> /usr/src/php-available-exts\r\n+\t\t\tfi\r\n+\t\tfi\r\n+\t\t;;\r\n+\tdelete)\r\n+\t\trm -rf \"$dir\"\r\n+\t\t;;\r\n+\t*)\r\n+\t\tusage\r\n+\t\texit 1\r\n+\t\t;;\r\n+esac\r\ndiff --git a/php_5-fpm/Dockerfile b/php_5-fpm/Dockerfile\r\nindex 7a00015..83b8ca8 100644\r\n--- a/php_5-fpm/Dockerfile\r\n+++ b/php_5-fpm/Dockerfile\r\n@@ -17,6 +17,7 @@ RUN apt-get update && apt-get install -y \\\r\n \t\tlibedit2 \\\r\n \t\tlibsqlite3-0 \\\r\n \t\tlibxml2 \\\r\n+\t\txz-utils \\\r\n \t--no-install-recommends && rm -r /var/lib/apt/lists/*\r\n \r\n ENV PHP_INI_DIR /usr/local/etc/php\r\n@@ -33,6 +34,20 @@ ENV PHP_FILENAME php-5.6.23.tar.xz\r\n ENV PHP_SHA256 39141e9a617af172aedbbacee7a63eb15502850f7cea20d759a9cffa7cfb0a1a\r\n \r\n RUN set -xe \\\r\n+\t&& cd /usr/src/ \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o php.tar.xz \\\r\n+\t&& echo \"$PHP_SHA256 *php.tar.xz\" | sha256sum -c - \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o php.tar.xz.asc \\\r\n+\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n+\t&& for key in $GPG_KEYS; do \\\r\n+\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n+\tdone \\\r\n+\t&& gpg --batch --verify php.tar.xz.asc php.tar.xz \\\r\n+\t&& rm -r \"$GNUPGHOME\"\r\n+\r\n+COPY docker-php-source /usr/local/bin/\r\n+\r\n+RUN set -xe \\\r\n \t&& buildDeps=\" \\\r\n \t\t$PHP_EXTRA_BUILD_DEPS \\\r\n \t\tlibcurl4-openssl-dev \\\r\n@@ -40,21 +55,9 @@ RUN set -xe \\\r\n \t\tlibsqlite3-dev \\\r\n \t\tlibssl-dev \\\r\n \t\tlibxml2-dev \\\r\n-\t\txz-utils \\\r\n \t\" \\\r\n \t&& apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o \"$PHP_FILENAME\" \\\r\n-\t&& echo \"$PHP_SHA256 *$PHP_FILENAME\" | sha256sum -c - \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o \"$PHP_FILENAME.asc\" \\\r\n-\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n-\t&& for key in $GPG_KEYS; do \\\r\n-\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n-\tdone \\\r\n-\t&& gpg --batch --verify \"$PHP_FILENAME.asc\" \"$PHP_FILENAME\" \\\r\n-\t&& rm -r \"$GNUPGHOME\" \"$PHP_FILENAME.asc\" \\\r\n-\t&& mkdir -p /usr/src/php \\\r\n-\t&& tar -xf \"$PHP_FILENAME\" -C /usr/src/php --strip-components=1 \\\r\n-\t&& rm \"$PHP_FILENAME\" \\\r\n+\t&& docker-php-source extract \\\r\n \t&& cd /usr/src/php \\\r\n \t&& ./configure \\\r\n \t\t--with-config-file-path=\"$PHP_INI_DIR\" \\\r\n@@ -73,7 +76,8 @@ RUN set -xe \\\r\n \t&& make install \\\r\n \t&& { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \\\r\n \t&& make clean \\\r\n-\t&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps\r\n+\t&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps \\\r\n+\t&& docker-php-source delete\r\n \r\n COPY docker-php-ext-* /usr/local/bin/\r\n \r\ndiff --git a/php_5-fpm/docker-php-ext-configure b/php_5-fpm/docker-php-ext-configure\r\nindex dd56be1..ac3e899 100755\r\n--- a/php_5-fpm/docker-php-ext-configure\r\n+++ b/php_5-fpm/docker-php-ext-configure\r\n@@ -2,13 +2,12 @@\r\n set -e\r\n \r\n ext=\"$1\"\r\n-extDir=\"/usr/src/php/ext/$ext\"\r\n-if [ -z \"$ext\" ] || ! [ -d \"$extDir\" ]; then\r\n+if [ -z \"$ext\" ] || ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n \techo >&2 \"usage: $0 ext-name [configure flags]\"\r\n \techo >&2 \"   ie: $0 gd --with-jpeg-dir=/usr/local/something\"\r\n \techo >&2\r\n \techo >&2 'Possible values for ext-name:'\r\n-\techo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n \texit 1\r\n fi\r\n shift\r\n@@ -28,7 +27,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+\r\n set -x\r\n-cd \"$extDir\"\r\n+cd \"/usr/src/php/ext/$ext\"\r\n phpize\r\n ./configure \"$@\"\r\ndiff --git a/php_5-fpm/docker-php-ext-install b/php_5-fpm/docker-php-ext-install\r\nindex 43927b4..f7fc78d 100755\r\n--- a/php_5-fpm/docker-php-ext-install\r\n+++ b/php_5-fpm/docker-php-ext-install\r\n@@ -1,8 +1,6 @@\r\n #!/bin/sh\r\n set -e\r\n \r\n-cd /usr/src/php/ext\r\n-\r\n usage() {\r\n \techo \"usage: $0 [-jN] ext-name [ext-name ...]\"\r\n \techo \"   ie: $0 gd mysqli\"\r\n@@ -12,7 +10,7 @@ usage() {\r\n \techo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'\r\n \techo\r\n \techo 'Possible values for ext-name:'\r\n-\techo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n }\r\n \r\n opts=\"$(getopt -o 'h?j:' --long 'help,jobs:' -- \"$@\" || { usage >&2 && false; })\"\r\n@@ -41,8 +39,8 @@ for ext; do\r\n \tif [ -z \"$ext\" ]; then\r\n \t\tcontinue\r\n \tfi\r\n-\tif [ ! -d \"$ext\" ]; then\r\n-\t\techo >&2 \"error: $(pwd -P)/$ext does not exist\"\r\n+\tif ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n+\t\techo >&2 \"error: /usr/src/php/ext/$ext does not exist\"\r\n \t\techo >&2\r\n \t\tusage >&2\r\n \t\texit 1\r\n@@ -72,6 +70,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+cd /usr/src/php/ext\r\n+\r\n for ext in $exts; do\r\n \t(\r\n \t\tcd \"$ext\"\r\n@@ -90,3 +91,4 @@ done\r\n if [ \"$pm\" = 'apk' ] && [ -n \"$apkDel\" ]; then\r\n \tapk del $apkDel\r\n fi\r\n+docker-php-source delete\r\ndiff --git a/php_5-fpm/docker-php-source b/php_5-fpm/docker-php-source\r\nnew file mode 100755\r\nindex 0000000..9020385\r\n--- /dev/null\r\n+++ b/php_5-fpm/docker-php-source\r\n@@ -0,0 +1,44 @@\r\n+#!/bin/sh\r\n+set -e\r\n+dir=/usr/src/php\r\n+\r\n+usage() {\r\n+\techo \"usage: $0 COMMAND\"\r\n+\techo\r\n+\techo \"Manage php source tarball lifecycle.\"\r\n+\techo\r\n+\techo \"Commands:\"\r\n+\techo \"   extract  extract php source tarball into directory $dir if not already done.\"\r\n+\techo \"   delete   delete extracted php source located into $dir if not already done.\"\r\n+\techo\r\n+}\r\n+\r\n+case \"$1\" in\r\n+\textract)\r\n+\t\tif [ -e \"$dir\" -a ! -d \"$dir\" ] ; then\r\n+\t\t\techo >&2 \"$dir exists and is not a directory\"\r\n+\t\t\texit 1\r\n+\t\tfi\r\n+\t\tif [ ! -d \"$dir\" ]; then\r\n+\t\t\tmkdir -p \"$dir\"\r\n+\t\t\ttar -Jxf /usr/src/php.tar.xz -C \"$dir\" --strip-components=1\r\n+\r\n+\t\t\tif [ ! -f /usr/src/php-available-exts ]; then\r\n+\t\t\t\tfind \"$dir/ext\" \\\r\n+\t\t\t\t\t\t-mindepth 2 \\\r\n+\t\t\t\t\t\t-maxdepth 2 \\\r\n+\t\t\t\t\t\t-type f \\\r\n+\t\t\t\t\t\t-name 'config.m4' \\\r\n+\t\t\t\t\t| xargs -n1 dirname | xargs -n1 basename | sort \\\r\n+\t\t\t\t> /usr/src/php-available-exts\r\n+\t\t\tfi\r\n+\t\tfi\r\n+\t\t;;\r\n+\tdelete)\r\n+\t\trm -rf \"$dir\"\r\n+\t\t;;\r\n+\t*)\r\n+\t\tusage\r\n+\t\texit 1\r\n+\t\t;;\r\n+esac\r\ndiff --git a/php_5-zts-alpine/Dockerfile b/php_5-zts-alpine/Dockerfile\r\nindex 2ba8548..2ea5b1e 100644\r\n--- a/php_5-zts-alpine/Dockerfile\r\n+++ b/php_5-zts-alpine/Dockerfile\r\n@@ -12,7 +12,9 @@ ENV PHPIZE_DEPS \\\r\n \t\tre2c\r\n RUN apk add --no-cache --virtual .persistent-deps \\\r\n \t\tca-certificates \\\r\n-\t\tcurl\r\n+\t\tcurl \\\r\n+\t\ttar \\\r\n+\t\txz\r\n \r\n # ensure www-data user exists\r\n RUN set -x \\\r\n@@ -37,27 +39,32 @@ ENV PHP_FILENAME php-5.6.23.tar.xz\r\n ENV PHP_SHA256 39141e9a617af172aedbbacee7a63eb15502850f7cea20d759a9cffa7cfb0a1a\r\n \r\n RUN set -xe \\\r\n+\t&& apk add --no-cache --virtual .fetch-deps \\\r\n+\t\tgnupg \\\r\n+\t&& mkdir -p /usr/src \\\r\n+\t&& cd /usr/src/ \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o php.tar.xz \\\r\n+\t&& echo \"$PHP_SHA256 *php.tar.xz\" | sha256sum -c - \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o php.tar.xz.asc \\\r\n+\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n+\t&& for key in $GPG_KEYS; do \\\r\n+\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n+\tdone \\\r\n+\t&& gpg --batch --verify php.tar.xz.asc php.tar.xz \\\r\n+\t&& rm -r \"$GNUPGHOME\" \\\r\n+\t&& apk del .fetch-deps\r\n+\r\n+COPY docker-php-source /usr/local/bin/\r\n+\r\n+RUN set -xe \\\r\n \t&& apk add --no-cache --virtual .build-deps \\\r\n \t\t$PHPIZE_DEPS \\\r\n \t\tcurl-dev \\\r\n-\t\tgnupg \\\r\n \t\tlibedit-dev \\\r\n \t\tlibxml2-dev \\\r\n \t\topenssl-dev \\\r\n \t\tsqlite-dev \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o \"$PHP_FILENAME\" \\\r\n-\t&& echo \"$PHP_SHA256 *$PHP_FILENAME\" | sha256sum -c - \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o \"$PHP_FILENAME.asc\" \\\r\n-\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n-\t&& for key in $GPG_KEYS; do \\\r\n-\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n-\tdone \\\r\n-\t&& gpg --batch --verify \"$PHP_FILENAME.asc\" \"$PHP_FILENAME\" \\\r\n-\t&& rm -r \"$GNUPGHOME\" \"$PHP_FILENAME.asc\" \\\r\n-\t&& mkdir -p /usr/src \\\r\n-\t&& tar -Jxf \"$PHP_FILENAME\" -C /usr/src \\\r\n-\t&& mv \"/usr/src/php-$PHP_VERSION\" /usr/src/php \\\r\n-\t&& rm \"$PHP_FILENAME\" \\\r\n+\t&& docker-php-source extract \\\r\n \t&& cd /usr/src/php \\\r\n \t&& ./configure \\\r\n \t\t--with-config-file-path=\"$PHP_INI_DIR\" \\\r\n@@ -84,7 +91,8 @@ RUN set -xe \\\r\n \t\t\t| sort -u \\\r\n \t)\" \\\r\n \t&& apk add --no-cache --virtual .php-rundeps $runDeps \\\r\n-\t&& apk del .build-deps\r\n+\t&& apk del .build-deps \\\r\n+\t&& docker-php-source delete\r\n \r\n COPY docker-php-ext-* /usr/local/bin/\r\n \r\ndiff --git a/php_5-zts-alpine/docker-php-ext-configure b/php_5-zts-alpine/docker-php-ext-configure\r\nindex dd56be1..ac3e899 100755\r\n--- a/php_5-zts-alpine/docker-php-ext-configure\r\n+++ b/php_5-zts-alpine/docker-php-ext-configure\r\n@@ -2,13 +2,12 @@\r\n set -e\r\n \r\n ext=\"$1\"\r\n-extDir=\"/usr/src/php/ext/$ext\"\r\n-if [ -z \"$ext\" ] || ! [ -d \"$extDir\" ]; then\r\n+if [ -z \"$ext\" ] || ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n \techo >&2 \"usage: $0 ext-name [configure flags]\"\r\n \techo >&2 \"   ie: $0 gd --with-jpeg-dir=/usr/local/something\"\r\n \techo >&2\r\n \techo >&2 'Possible values for ext-name:'\r\n-\techo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n \texit 1\r\n fi\r\n shift\r\n@@ -28,7 +27,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+\r\n set -x\r\n-cd \"$extDir\"\r\n+cd \"/usr/src/php/ext/$ext\"\r\n phpize\r\n ./configure \"$@\"\r\ndiff --git a/php_5-zts-alpine/docker-php-ext-install b/php_5-zts-alpine/docker-php-ext-install\r\nindex 43927b4..f7fc78d 100755\r\n--- a/php_5-zts-alpine/docker-php-ext-install\r\n+++ b/php_5-zts-alpine/docker-php-ext-install\r\n@@ -1,8 +1,6 @@\r\n #!/bin/sh\r\n set -e\r\n \r\n-cd /usr/src/php/ext\r\n-\r\n usage() {\r\n \techo \"usage: $0 [-jN] ext-name [ext-name ...]\"\r\n \techo \"   ie: $0 gd mysqli\"\r\n@@ -12,7 +10,7 @@ usage() {\r\n \techo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'\r\n \techo\r\n \techo 'Possible values for ext-name:'\r\n-\techo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n }\r\n \r\n opts=\"$(getopt -o 'h?j:' --long 'help,jobs:' -- \"$@\" || { usage >&2 && false; })\"\r\n@@ -41,8 +39,8 @@ for ext; do\r\n \tif [ -z \"$ext\" ]; then\r\n \t\tcontinue\r\n \tfi\r\n-\tif [ ! -d \"$ext\" ]; then\r\n-\t\techo >&2 \"error: $(pwd -P)/$ext does not exist\"\r\n+\tif ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n+\t\techo >&2 \"error: /usr/src/php/ext/$ext does not exist\"\r\n \t\techo >&2\r\n \t\tusage >&2\r\n \t\texit 1\r\n@@ -72,6 +70,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+cd /usr/src/php/ext\r\n+\r\n for ext in $exts; do\r\n \t(\r\n \t\tcd \"$ext\"\r\n@@ -90,3 +91,4 @@ done\r\n if [ \"$pm\" = 'apk' ] && [ -n \"$apkDel\" ]; then\r\n \tapk del $apkDel\r\n fi\r\n+docker-php-source delete\r\ndiff --git a/php_5-zts-alpine/docker-php-source b/php_5-zts-alpine/docker-php-source\r\nnew file mode 100755\r\nindex 0000000..9020385\r\n--- /dev/null\r\n+++ b/php_5-zts-alpine/docker-php-source\r\n@@ -0,0 +1,44 @@\r\n+#!/bin/sh\r\n+set -e\r\n+dir=/usr/src/php\r\n+\r\n+usage() {\r\n+\techo \"usage: $0 COMMAND\"\r\n+\techo\r\n+\techo \"Manage php source tarball lifecycle.\"\r\n+\techo\r\n+\techo \"Commands:\"\r\n+\techo \"   extract  extract php source tarball into directory $dir if not already done.\"\r\n+\techo \"   delete   delete extracted php source located into $dir if not already done.\"\r\n+\techo\r\n+}\r\n+\r\n+case \"$1\" in\r\n+\textract)\r\n+\t\tif [ -e \"$dir\" -a ! -d \"$dir\" ] ; then\r\n+\t\t\techo >&2 \"$dir exists and is not a directory\"\r\n+\t\t\texit 1\r\n+\t\tfi\r\n+\t\tif [ ! -d \"$dir\" ]; then\r\n+\t\t\tmkdir -p \"$dir\"\r\n+\t\t\ttar -Jxf /usr/src/php.tar.xz -C \"$dir\" --strip-components=1\r\n+\r\n+\t\t\tif [ ! -f /usr/src/php-available-exts ]; then\r\n+\t\t\t\tfind \"$dir/ext\" \\\r\n+\t\t\t\t\t\t-mindepth 2 \\\r\n+\t\t\t\t\t\t-maxdepth 2 \\\r\n+\t\t\t\t\t\t-type f \\\r\n+\t\t\t\t\t\t-name 'config.m4' \\\r\n+\t\t\t\t\t| xargs -n1 dirname | xargs -n1 basename | sort \\\r\n+\t\t\t\t> /usr/src/php-available-exts\r\n+\t\t\tfi\r\n+\t\tfi\r\n+\t\t;;\r\n+\tdelete)\r\n+\t\trm -rf \"$dir\"\r\n+\t\t;;\r\n+\t*)\r\n+\t\tusage\r\n+\t\texit 1\r\n+\t\t;;\r\n+esac\r\ndiff --git a/php_5-zts/Dockerfile b/php_5-zts/Dockerfile\r\nindex 0da3ef0..4976907 100644\r\n--- a/php_5-zts/Dockerfile\r\n+++ b/php_5-zts/Dockerfile\r\n@@ -17,6 +17,7 @@ RUN apt-get update && apt-get install -y \\\r\n \t\tlibedit2 \\\r\n \t\tlibsqlite3-0 \\\r\n \t\tlibxml2 \\\r\n+\t\txz-utils \\\r\n \t--no-install-recommends && rm -r /var/lib/apt/lists/*\r\n \r\n ENV PHP_INI_DIR /usr/local/etc/php\r\n@@ -33,6 +34,20 @@ ENV PHP_FILENAME php-5.6.23.tar.xz\r\n ENV PHP_SHA256 39141e9a617af172aedbbacee7a63eb15502850f7cea20d759a9cffa7cfb0a1a\r\n \r\n RUN set -xe \\\r\n+\t&& cd /usr/src/ \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o php.tar.xz \\\r\n+\t&& echo \"$PHP_SHA256 *php.tar.xz\" | sha256sum -c - \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o php.tar.xz.asc \\\r\n+\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n+\t&& for key in $GPG_KEYS; do \\\r\n+\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n+\tdone \\\r\n+\t&& gpg --batch --verify php.tar.xz.asc php.tar.xz \\\r\n+\t&& rm -r \"$GNUPGHOME\"\r\n+\r\n+COPY docker-php-source /usr/local/bin/\r\n+\r\n+RUN set -xe \\\r\n \t&& buildDeps=\" \\\r\n \t\t$PHP_EXTRA_BUILD_DEPS \\\r\n \t\tlibcurl4-openssl-dev \\\r\n@@ -40,21 +55,9 @@ RUN set -xe \\\r\n \t\tlibsqlite3-dev \\\r\n \t\tlibssl-dev \\\r\n \t\tlibxml2-dev \\\r\n-\t\txz-utils \\\r\n \t\" \\\r\n \t&& apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o \"$PHP_FILENAME\" \\\r\n-\t&& echo \"$PHP_SHA256 *$PHP_FILENAME\" | sha256sum -c - \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o \"$PHP_FILENAME.asc\" \\\r\n-\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n-\t&& for key in $GPG_KEYS; do \\\r\n-\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n-\tdone \\\r\n-\t&& gpg --batch --verify \"$PHP_FILENAME.asc\" \"$PHP_FILENAME\" \\\r\n-\t&& rm -r \"$GNUPGHOME\" \"$PHP_FILENAME.asc\" \\\r\n-\t&& mkdir -p /usr/src/php \\\r\n-\t&& tar -xf \"$PHP_FILENAME\" -C /usr/src/php --strip-components=1 \\\r\n-\t&& rm \"$PHP_FILENAME\" \\\r\n+\t&& docker-php-source extract \\\r\n \t&& cd /usr/src/php \\\r\n \t&& ./configure \\\r\n \t\t--with-config-file-path=\"$PHP_INI_DIR\" \\\r\n@@ -73,7 +76,8 @@ RUN set -xe \\\r\n \t&& make install \\\r\n \t&& { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \\\r\n \t&& make clean \\\r\n-\t&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps\r\n+\t&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps \\\r\n+\t&& docker-php-source delete\r\n \r\n COPY docker-php-ext-* /usr/local/bin/\r\n \r\ndiff --git a/php_5-zts/docker-php-ext-configure b/php_5-zts/docker-php-ext-configure\r\nindex dd56be1..ac3e899 100755\r\n--- a/php_5-zts/docker-php-ext-configure\r\n+++ b/php_5-zts/docker-php-ext-configure\r\n@@ -2,13 +2,12 @@\r\n set -e\r\n \r\n ext=\"$1\"\r\n-extDir=\"/usr/src/php/ext/$ext\"\r\n-if [ -z \"$ext\" ] || ! [ -d \"$extDir\" ]; then\r\n+if [ -z \"$ext\" ] || ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n \techo >&2 \"usage: $0 ext-name [configure flags]\"\r\n \techo >&2 \"   ie: $0 gd --with-jpeg-dir=/usr/local/something\"\r\n \techo >&2\r\n \techo >&2 'Possible values for ext-name:'\r\n-\techo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n \texit 1\r\n fi\r\n shift\r\n@@ -28,7 +27,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+\r\n set -x\r\n-cd \"$extDir\"\r\n+cd \"/usr/src/php/ext/$ext\"\r\n phpize\r\n ./configure \"$@\"\r\ndiff --git a/php_5-zts/docker-php-ext-install b/php_5-zts/docker-php-ext-install\r\nindex 43927b4..f7fc78d 100755\r\n--- a/php_5-zts/docker-php-ext-install\r\n+++ b/php_5-zts/docker-php-ext-install\r\n@@ -1,8 +1,6 @@\r\n #!/bin/sh\r\n set -e\r\n \r\n-cd /usr/src/php/ext\r\n-\r\n usage() {\r\n \techo \"usage: $0 [-jN] ext-name [ext-name ...]\"\r\n \techo \"   ie: $0 gd mysqli\"\r\n@@ -12,7 +10,7 @@ usage() {\r\n \techo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'\r\n \techo\r\n \techo 'Possible values for ext-name:'\r\n-\techo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n }\r\n \r\n opts=\"$(getopt -o 'h?j:' --long 'help,jobs:' -- \"$@\" || { usage >&2 && false; })\"\r\n@@ -41,8 +39,8 @@ for ext; do\r\n \tif [ -z \"$ext\" ]; then\r\n \t\tcontinue\r\n \tfi\r\n-\tif [ ! -d \"$ext\" ]; then\r\n-\t\techo >&2 \"error: $(pwd -P)/$ext does not exist\"\r\n+\tif ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n+\t\techo >&2 \"error: /usr/src/php/ext/$ext does not exist\"\r\n \t\techo >&2\r\n \t\tusage >&2\r\n \t\texit 1\r\n@@ -72,6 +70,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+cd /usr/src/php/ext\r\n+\r\n for ext in $exts; do\r\n \t(\r\n \t\tcd \"$ext\"\r\n@@ -90,3 +91,4 @@ done\r\n if [ \"$pm\" = 'apk' ] && [ -n \"$apkDel\" ]; then\r\n \tapk del $apkDel\r\n fi\r\n+docker-php-source delete\r\ndiff --git a/php_5-zts/docker-php-source b/php_5-zts/docker-php-source\r\nnew file mode 100755\r\nindex 0000000..9020385\r\n--- /dev/null\r\n+++ b/php_5-zts/docker-php-source\r\n@@ -0,0 +1,44 @@\r\n+#!/bin/sh\r\n+set -e\r\n+dir=/usr/src/php\r\n+\r\n+usage() {\r\n+\techo \"usage: $0 COMMAND\"\r\n+\techo\r\n+\techo \"Manage php source tarball lifecycle.\"\r\n+\techo\r\n+\techo \"Commands:\"\r\n+\techo \"   extract  extract php source tarball into directory $dir if not already done.\"\r\n+\techo \"   delete   delete extracted php source located into $dir if not already done.\"\r\n+\techo\r\n+}\r\n+\r\n+case \"$1\" in\r\n+\textract)\r\n+\t\tif [ -e \"$dir\" -a ! -d \"$dir\" ] ; then\r\n+\t\t\techo >&2 \"$dir exists and is not a directory\"\r\n+\t\t\texit 1\r\n+\t\tfi\r\n+\t\tif [ ! -d \"$dir\" ]; then\r\n+\t\t\tmkdir -p \"$dir\"\r\n+\t\t\ttar -Jxf /usr/src/php.tar.xz -C \"$dir\" --strip-components=1\r\n+\r\n+\t\t\tif [ ! -f /usr/src/php-available-exts ]; then\r\n+\t\t\t\tfind \"$dir/ext\" \\\r\n+\t\t\t\t\t\t-mindepth 2 \\\r\n+\t\t\t\t\t\t-maxdepth 2 \\\r\n+\t\t\t\t\t\t-type f \\\r\n+\t\t\t\t\t\t-name 'config.m4' \\\r\n+\t\t\t\t\t| xargs -n1 dirname | xargs -n1 basename | sort \\\r\n+\t\t\t\t> /usr/src/php-available-exts\r\n+\t\t\tfi\r\n+\t\tfi\r\n+\t\t;;\r\n+\tdelete)\r\n+\t\trm -rf \"$dir\"\r\n+\t\t;;\r\n+\t*)\r\n+\t\tusage\r\n+\t\texit 1\r\n+\t\t;;\r\n+esac\r\ndiff --git a/php_5.5-alpine/Dockerfile b/php_5.5-alpine/Dockerfile\r\nindex 60f87b6..68be05c 100644\r\n--- a/php_5.5-alpine/Dockerfile\r\n+++ b/php_5.5-alpine/Dockerfile\r\n@@ -12,7 +12,9 @@ ENV PHPIZE_DEPS \\\r\n \t\tre2c\r\n RUN apk add --no-cache --virtual .persistent-deps \\\r\n \t\tca-certificates \\\r\n-\t\tcurl\r\n+\t\tcurl \\\r\n+\t\ttar \\\r\n+\t\txz\r\n \r\n # ensure www-data user exists\r\n RUN set -x \\\r\n@@ -36,27 +38,32 @@ ENV PHP_FILENAME php-5.5.37.tar.xz\r\n ENV PHP_SHA256 c322444fdf6d3ba26aa67d67ee32d1e815a877f35831351c83763431a80e3612\r\n \r\n RUN set -xe \\\r\n+\t&& apk add --no-cache --virtual .fetch-deps \\\r\n+\t\tgnupg \\\r\n+\t&& mkdir -p /usr/src \\\r\n+\t&& cd /usr/src/ \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o php.tar.xz \\\r\n+\t&& echo \"$PHP_SHA256 *php.tar.xz\" | sha256sum -c - \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o php.tar.xz.asc \\\r\n+\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n+\t&& for key in $GPG_KEYS; do \\\r\n+\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n+\tdone \\\r\n+\t&& gpg --batch --verify php.tar.xz.asc php.tar.xz \\\r\n+\t&& rm -r \"$GNUPGHOME\" \\\r\n+\t&& apk del .fetch-deps\r\n+\r\n+COPY docker-php-source /usr/local/bin/\r\n+\r\n+RUN set -xe \\\r\n \t&& apk add --no-cache --virtual .build-deps \\\r\n \t\t$PHPIZE_DEPS \\\r\n \t\tcurl-dev \\\r\n-\t\tgnupg \\\r\n \t\tlibedit-dev \\\r\n \t\tlibxml2-dev \\\r\n \t\topenssl-dev \\\r\n \t\tsqlite-dev \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o \"$PHP_FILENAME\" \\\r\n-\t&& echo \"$PHP_SHA256 *$PHP_FILENAME\" | sha256sum -c - \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o \"$PHP_FILENAME.asc\" \\\r\n-\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n-\t&& for key in $GPG_KEYS; do \\\r\n-\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n-\tdone \\\r\n-\t&& gpg --batch --verify \"$PHP_FILENAME.asc\" \"$PHP_FILENAME\" \\\r\n-\t&& rm -r \"$GNUPGHOME\" \"$PHP_FILENAME.asc\" \\\r\n-\t&& mkdir -p /usr/src \\\r\n-\t&& tar -Jxf \"$PHP_FILENAME\" -C /usr/src \\\r\n-\t&& mv \"/usr/src/php-$PHP_VERSION\" /usr/src/php \\\r\n-\t&& rm \"$PHP_FILENAME\" \\\r\n+\t&& docker-php-source extract \\\r\n \t&& cd /usr/src/php \\\r\n \t&& ./configure \\\r\n \t\t--with-config-file-path=\"$PHP_INI_DIR\" \\\r\n@@ -83,7 +90,8 @@ RUN set -xe \\\r\n \t\t\t| sort -u \\\r\n \t)\" \\\r\n \t&& apk add --no-cache --virtual .php-rundeps $runDeps \\\r\n-\t&& apk del .build-deps\r\n+\t&& apk del .build-deps \\\r\n+\t&& docker-php-source delete\r\n \r\n COPY docker-php-ext-* /usr/local/bin/\r\n \r\ndiff --git a/php_5.5-alpine/docker-php-ext-configure b/php_5.5-alpine/docker-php-ext-configure\r\nindex dd56be1..ac3e899 100755\r\n--- a/php_5.5-alpine/docker-php-ext-configure\r\n+++ b/php_5.5-alpine/docker-php-ext-configure\r\n@@ -2,13 +2,12 @@\r\n set -e\r\n \r\n ext=\"$1\"\r\n-extDir=\"/usr/src/php/ext/$ext\"\r\n-if [ -z \"$ext\" ] || ! [ -d \"$extDir\" ]; then\r\n+if [ -z \"$ext\" ] || ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n \techo >&2 \"usage: $0 ext-name [configure flags]\"\r\n \techo >&2 \"   ie: $0 gd --with-jpeg-dir=/usr/local/something\"\r\n \techo >&2\r\n \techo >&2 'Possible values for ext-name:'\r\n-\techo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n \texit 1\r\n fi\r\n shift\r\n@@ -28,7 +27,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+\r\n set -x\r\n-cd \"$extDir\"\r\n+cd \"/usr/src/php/ext/$ext\"\r\n phpize\r\n ./configure \"$@\"\r\ndiff --git a/php_5.5-alpine/docker-php-ext-install b/php_5.5-alpine/docker-php-ext-install\r\nindex 43927b4..f7fc78d 100755\r\n--- a/php_5.5-alpine/docker-php-ext-install\r\n+++ b/php_5.5-alpine/docker-php-ext-install\r\n@@ -1,8 +1,6 @@\r\n #!/bin/sh\r\n set -e\r\n \r\n-cd /usr/src/php/ext\r\n-\r\n usage() {\r\n \techo \"usage: $0 [-jN] ext-name [ext-name ...]\"\r\n \techo \"   ie: $0 gd mysqli\"\r\n@@ -12,7 +10,7 @@ usage() {\r\n \techo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'\r\n \techo\r\n \techo 'Possible values for ext-name:'\r\n-\techo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n }\r\n \r\n opts=\"$(getopt -o 'h?j:' --long 'help,jobs:' -- \"$@\" || { usage >&2 && false; })\"\r\n@@ -41,8 +39,8 @@ for ext; do\r\n \tif [ -z \"$ext\" ]; then\r\n \t\tcontinue\r\n \tfi\r\n-\tif [ ! -d \"$ext\" ]; then\r\n-\t\techo >&2 \"error: $(pwd -P)/$ext does not exist\"\r\n+\tif ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n+\t\techo >&2 \"error: /usr/src/php/ext/$ext does not exist\"\r\n \t\techo >&2\r\n \t\tusage >&2\r\n \t\texit 1\r\n@@ -72,6 +70,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+cd /usr/src/php/ext\r\n+\r\n for ext in $exts; do\r\n \t(\r\n \t\tcd \"$ext\"\r\n@@ -90,3 +91,4 @@ done\r\n if [ \"$pm\" = 'apk' ] && [ -n \"$apkDel\" ]; then\r\n \tapk del $apkDel\r\n fi\r\n+docker-php-source delete\r\ndiff --git a/php_5.5-alpine/docker-php-source b/php_5.5-alpine/docker-php-source\r\nnew file mode 100755\r\nindex 0000000..9020385\r\n--- /dev/null\r\n+++ b/php_5.5-alpine/docker-php-source\r\n@@ -0,0 +1,44 @@\r\n+#!/bin/sh\r\n+set -e\r\n+dir=/usr/src/php\r\n+\r\n+usage() {\r\n+\techo \"usage: $0 COMMAND\"\r\n+\techo\r\n+\techo \"Manage php source tarball lifecycle.\"\r\n+\techo\r\n+\techo \"Commands:\"\r\n+\techo \"   extract  extract php source tarball into directory $dir if not already done.\"\r\n+\techo \"   delete   delete extracted php source located into $dir if not already done.\"\r\n+\techo\r\n+}\r\n+\r\n+case \"$1\" in\r\n+\textract)\r\n+\t\tif [ -e \"$dir\" -a ! -d \"$dir\" ] ; then\r\n+\t\t\techo >&2 \"$dir exists and is not a directory\"\r\n+\t\t\texit 1\r\n+\t\tfi\r\n+\t\tif [ ! -d \"$dir\" ]; then\r\n+\t\t\tmkdir -p \"$dir\"\r\n+\t\t\ttar -Jxf /usr/src/php.tar.xz -C \"$dir\" --strip-components=1\r\n+\r\n+\t\t\tif [ ! -f /usr/src/php-available-exts ]; then\r\n+\t\t\t\tfind \"$dir/ext\" \\\r\n+\t\t\t\t\t\t-mindepth 2 \\\r\n+\t\t\t\t\t\t-maxdepth 2 \\\r\n+\t\t\t\t\t\t-type f \\\r\n+\t\t\t\t\t\t-name 'config.m4' \\\r\n+\t\t\t\t\t| xargs -n1 dirname | xargs -n1 basename | sort \\\r\n+\t\t\t\t> /usr/src/php-available-exts\r\n+\t\t\tfi\r\n+\t\tfi\r\n+\t\t;;\r\n+\tdelete)\r\n+\t\trm -rf \"$dir\"\r\n+\t\t;;\r\n+\t*)\r\n+\t\tusage\r\n+\t\texit 1\r\n+\t\t;;\r\n+esac\r\ndiff --git a/php_5.5-apache/Dockerfile b/php_5.5-apache/Dockerfile\r\nindex 3543f47..eaf3877 100644\r\n--- a/php_5.5-apache/Dockerfile\r\n+++ b/php_5.5-apache/Dockerfile\r\n@@ -17,6 +17,7 @@ RUN apt-get update && apt-get install -y \\\r\n \t\tlibedit2 \\\r\n \t\tlibsqlite3-0 \\\r\n \t\tlibxml2 \\\r\n+\t\txz-utils \\\r\n \t--no-install-recommends && rm -r /var/lib/apt/lists/*\r\n \r\n ENV PHP_INI_DIR /usr/local/etc/php\r\n@@ -79,6 +80,20 @@ ENV PHP_FILENAME php-5.5.37.tar.xz\r\n ENV PHP_SHA256 c322444fdf6d3ba26aa67d67ee32d1e815a877f35831351c83763431a80e3612\r\n \r\n RUN set -xe \\\r\n+\t&& cd /usr/src/ \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o php.tar.xz \\\r\n+\t&& echo \"$PHP_SHA256 *php.tar.xz\" | sha256sum -c - \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o php.tar.xz.asc \\\r\n+\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n+\t&& for key in $GPG_KEYS; do \\\r\n+\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n+\tdone \\\r\n+\t&& gpg --batch --verify php.tar.xz.asc php.tar.xz \\\r\n+\t&& rm -r \"$GNUPGHOME\"\r\n+\r\n+COPY docker-php-source /usr/local/bin/\r\n+\r\n+RUN set -xe \\\r\n \t&& buildDeps=\" \\\r\n \t\t$PHP_EXTRA_BUILD_DEPS \\\r\n \t\tlibcurl4-openssl-dev \\\r\n@@ -86,21 +101,9 @@ RUN set -xe \\\r\n \t\tlibsqlite3-dev \\\r\n \t\tlibssl-dev \\\r\n \t\tlibxml2-dev \\\r\n-\t\txz-utils \\\r\n \t\" \\\r\n \t&& apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o \"$PHP_FILENAME\" \\\r\n-\t&& echo \"$PHP_SHA256 *$PHP_FILENAME\" | sha256sum -c - \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o \"$PHP_FILENAME.asc\" \\\r\n-\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n-\t&& for key in $GPG_KEYS; do \\\r\n-\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n-\tdone \\\r\n-\t&& gpg --batch --verify \"$PHP_FILENAME.asc\" \"$PHP_FILENAME\" \\\r\n-\t&& rm -r \"$GNUPGHOME\" \"$PHP_FILENAME.asc\" \\\r\n-\t&& mkdir -p /usr/src/php \\\r\n-\t&& tar -xf \"$PHP_FILENAME\" -C /usr/src/php --strip-components=1 \\\r\n-\t&& rm \"$PHP_FILENAME\" \\\r\n+\t&& docker-php-source extract \\\r\n \t&& cd /usr/src/php \\\r\n \t&& ./configure \\\r\n \t\t--with-config-file-path=\"$PHP_INI_DIR\" \\\r\n@@ -119,7 +122,8 @@ RUN set -xe \\\r\n \t&& make install \\\r\n \t&& { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \\\r\n \t&& make clean \\\r\n-\t&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps\r\n+\t&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps \\\r\n+\t&& docker-php-source delete\r\n \r\n COPY docker-php-ext-* /usr/local/bin/\r\n \r\ndiff --git a/php_5.5-apache/docker-php-ext-configure b/php_5.5-apache/docker-php-ext-configure\r\nindex dd56be1..ac3e899 100755\r\n--- a/php_5.5-apache/docker-php-ext-configure\r\n+++ b/php_5.5-apache/docker-php-ext-configure\r\n@@ -2,13 +2,12 @@\r\n set -e\r\n \r\n ext=\"$1\"\r\n-extDir=\"/usr/src/php/ext/$ext\"\r\n-if [ -z \"$ext\" ] || ! [ -d \"$extDir\" ]; then\r\n+if [ -z \"$ext\" ] || ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n \techo >&2 \"usage: $0 ext-name [configure flags]\"\r\n \techo >&2 \"   ie: $0 gd --with-jpeg-dir=/usr/local/something\"\r\n \techo >&2\r\n \techo >&2 'Possible values for ext-name:'\r\n-\techo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n \texit 1\r\n fi\r\n shift\r\n@@ -28,7 +27,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+\r\n set -x\r\n-cd \"$extDir\"\r\n+cd \"/usr/src/php/ext/$ext\"\r\n phpize\r\n ./configure \"$@\"\r\ndiff --git a/php_5.5-apache/docker-php-ext-install b/php_5.5-apache/docker-php-ext-install\r\nindex 43927b4..f7fc78d 100755\r\n--- a/php_5.5-apache/docker-php-ext-install\r\n+++ b/php_5.5-apache/docker-php-ext-install\r\n@@ -1,8 +1,6 @@\r\n #!/bin/sh\r\n set -e\r\n \r\n-cd /usr/src/php/ext\r\n-\r\n usage() {\r\n \techo \"usage: $0 [-jN] ext-name [ext-name ...]\"\r\n \techo \"   ie: $0 gd mysqli\"\r\n@@ -12,7 +10,7 @@ usage() {\r\n \techo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'\r\n \techo\r\n \techo 'Possible values for ext-name:'\r\n-\techo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n }\r\n \r\n opts=\"$(getopt -o 'h?j:' --long 'help,jobs:' -- \"$@\" || { usage >&2 && false; })\"\r\n@@ -41,8 +39,8 @@ for ext; do\r\n \tif [ -z \"$ext\" ]; then\r\n \t\tcontinue\r\n \tfi\r\n-\tif [ ! -d \"$ext\" ]; then\r\n-\t\techo >&2 \"error: $(pwd -P)/$ext does not exist\"\r\n+\tif ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n+\t\techo >&2 \"error: /usr/src/php/ext/$ext does not exist\"\r\n \t\techo >&2\r\n \t\tusage >&2\r\n \t\texit 1\r\n@@ -72,6 +70,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+cd /usr/src/php/ext\r\n+\r\n for ext in $exts; do\r\n \t(\r\n \t\tcd \"$ext\"\r\n@@ -90,3 +91,4 @@ done\r\n if [ \"$pm\" = 'apk' ] && [ -n \"$apkDel\" ]; then\r\n \tapk del $apkDel\r\n fi\r\n+docker-php-source delete\r\ndiff --git a/php_5.5-apache/docker-php-source b/php_5.5-apache/docker-php-source\r\nnew file mode 100755\r\nindex 0000000..9020385\r\n--- /dev/null\r\n+++ b/php_5.5-apache/docker-php-source\r\n@@ -0,0 +1,44 @@\r\n+#!/bin/sh\r\n+set -e\r\n+dir=/usr/src/php\r\n+\r\n+usage() {\r\n+\techo \"usage: $0 COMMAND\"\r\n+\techo\r\n+\techo \"Manage php source tarball lifecycle.\"\r\n+\techo\r\n+\techo \"Commands:\"\r\n+\techo \"   extract  extract php source tarball into directory $dir if not already done.\"\r\n+\techo \"   delete   delete extracted php source located into $dir if not already done.\"\r\n+\techo\r\n+}\r\n+\r\n+case \"$1\" in\r\n+\textract)\r\n+\t\tif [ -e \"$dir\" -a ! -d \"$dir\" ] ; then\r\n+\t\t\techo >&2 \"$dir exists and is not a directory\"\r\n+\t\t\texit 1\r\n+\t\tfi\r\n+\t\tif [ ! -d \"$dir\" ]; then\r\n+\t\t\tmkdir -p \"$dir\"\r\n+\t\t\ttar -Jxf /usr/src/php.tar.xz -C \"$dir\" --strip-components=1\r\n+\r\n+\t\t\tif [ ! -f /usr/src/php-available-exts ]; then\r\n+\t\t\t\tfind \"$dir/ext\" \\\r\n+\t\t\t\t\t\t-mindepth 2 \\\r\n+\t\t\t\t\t\t-maxdepth 2 \\\r\n+\t\t\t\t\t\t-type f \\\r\n+\t\t\t\t\t\t-name 'config.m4' \\\r\n+\t\t\t\t\t| xargs -n1 dirname | xargs -n1 basename | sort \\\r\n+\t\t\t\t> /usr/src/php-available-exts\r\n+\t\t\tfi\r\n+\t\tfi\r\n+\t\t;;\r\n+\tdelete)\r\n+\t\trm -rf \"$dir\"\r\n+\t\t;;\r\n+\t*)\r\n+\t\tusage\r\n+\t\texit 1\r\n+\t\t;;\r\n+esac\r\ndiff --git a/php_5.5-fpm-alpine/Dockerfile b/php_5.5-fpm-alpine/Dockerfile\r\nindex 230bb4b..6cec39d 100644\r\n--- a/php_5.5-fpm-alpine/Dockerfile\r\n+++ b/php_5.5-fpm-alpine/Dockerfile\r\n@@ -12,7 +12,9 @@ ENV PHPIZE_DEPS \\\r\n \t\tre2c\r\n RUN apk add --no-cache --virtual .persistent-deps \\\r\n \t\tca-certificates \\\r\n-\t\tcurl\r\n+\t\tcurl \\\r\n+\t\ttar \\\r\n+\t\txz\r\n \r\n # ensure www-data user exists\r\n RUN set -x \\\r\n@@ -37,27 +39,32 @@ ENV PHP_FILENAME php-5.5.37.tar.xz\r\n ENV PHP_SHA256 c322444fdf6d3ba26aa67d67ee32d1e815a877f35831351c83763431a80e3612\r\n \r\n RUN set -xe \\\r\n+\t&& apk add --no-cache --virtual .fetch-deps \\\r\n+\t\tgnupg \\\r\n+\t&& mkdir -p /usr/src \\\r\n+\t&& cd /usr/src/ \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o php.tar.xz \\\r\n+\t&& echo \"$PHP_SHA256 *php.tar.xz\" | sha256sum -c - \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o php.tar.xz.asc \\\r\n+\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n+\t&& for key in $GPG_KEYS; do \\\r\n+\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n+\tdone \\\r\n+\t&& gpg --batch --verify php.tar.xz.asc php.tar.xz \\\r\n+\t&& rm -r \"$GNUPGHOME\" \\\r\n+\t&& apk del .fetch-deps\r\n+\r\n+COPY docker-php-source /usr/local/bin/\r\n+\r\n+RUN set -xe \\\r\n \t&& apk add --no-cache --virtual .build-deps \\\r\n \t\t$PHPIZE_DEPS \\\r\n \t\tcurl-dev \\\r\n-\t\tgnupg \\\r\n \t\tlibedit-dev \\\r\n \t\tlibxml2-dev \\\r\n \t\topenssl-dev \\\r\n \t\tsqlite-dev \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o \"$PHP_FILENAME\" \\\r\n-\t&& echo \"$PHP_SHA256 *$PHP_FILENAME\" | sha256sum -c - \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o \"$PHP_FILENAME.asc\" \\\r\n-\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n-\t&& for key in $GPG_KEYS; do \\\r\n-\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n-\tdone \\\r\n-\t&& gpg --batch --verify \"$PHP_FILENAME.asc\" \"$PHP_FILENAME\" \\\r\n-\t&& rm -r \"$GNUPGHOME\" \"$PHP_FILENAME.asc\" \\\r\n-\t&& mkdir -p /usr/src \\\r\n-\t&& tar -Jxf \"$PHP_FILENAME\" -C /usr/src \\\r\n-\t&& mv \"/usr/src/php-$PHP_VERSION\" /usr/src/php \\\r\n-\t&& rm \"$PHP_FILENAME\" \\\r\n+\t&& docker-php-source extract \\\r\n \t&& cd /usr/src/php \\\r\n \t&& ./configure \\\r\n \t\t--with-config-file-path=\"$PHP_INI_DIR\" \\\r\n@@ -84,7 +91,8 @@ RUN set -xe \\\r\n \t\t\t| sort -u \\\r\n \t)\" \\\r\n \t&& apk add --no-cache --virtual .php-rundeps $runDeps \\\r\n-\t&& apk del .build-deps\r\n+\t&& apk del .build-deps \\\r\n+\t&& docker-php-source delete\r\n \r\n COPY docker-php-ext-* /usr/local/bin/\r\n \r\ndiff --git a/php_5.5-fpm-alpine/docker-php-ext-configure b/php_5.5-fpm-alpine/docker-php-ext-configure\r\nindex dd56be1..ac3e899 100755\r\n--- a/php_5.5-fpm-alpine/docker-php-ext-configure\r\n+++ b/php_5.5-fpm-alpine/docker-php-ext-configure\r\n@@ -2,13 +2,12 @@\r\n set -e\r\n \r\n ext=\"$1\"\r\n-extDir=\"/usr/src/php/ext/$ext\"\r\n-if [ -z \"$ext\" ] || ! [ -d \"$extDir\" ]; then\r\n+if [ -z \"$ext\" ] || ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n \techo >&2 \"usage: $0 ext-name [configure flags]\"\r\n \techo >&2 \"   ie: $0 gd --with-jpeg-dir=/usr/local/something\"\r\n \techo >&2\r\n \techo >&2 'Possible values for ext-name:'\r\n-\techo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n \texit 1\r\n fi\r\n shift\r\n@@ -28,7 +27,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+\r\n set -x\r\n-cd \"$extDir\"\r\n+cd \"/usr/src/php/ext/$ext\"\r\n phpize\r\n ./configure \"$@\"\r\ndiff --git a/php_5.5-fpm-alpine/docker-php-ext-install b/php_5.5-fpm-alpine/docker-php-ext-install\r\nindex 43927b4..f7fc78d 100755\r\n--- a/php_5.5-fpm-alpine/docker-php-ext-install\r\n+++ b/php_5.5-fpm-alpine/docker-php-ext-install\r\n@@ -1,8 +1,6 @@\r\n #!/bin/sh\r\n set -e\r\n \r\n-cd /usr/src/php/ext\r\n-\r\n usage() {\r\n \techo \"usage: $0 [-jN] ext-name [ext-name ...]\"\r\n \techo \"   ie: $0 gd mysqli\"\r\n@@ -12,7 +10,7 @@ usage() {\r\n \techo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'\r\n \techo\r\n \techo 'Possible values for ext-name:'\r\n-\techo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n }\r\n \r\n opts=\"$(getopt -o 'h?j:' --long 'help,jobs:' -- \"$@\" || { usage >&2 && false; })\"\r\n@@ -41,8 +39,8 @@ for ext; do\r\n \tif [ -z \"$ext\" ]; then\r\n \t\tcontinue\r\n \tfi\r\n-\tif [ ! -d \"$ext\" ]; then\r\n-\t\techo >&2 \"error: $(pwd -P)/$ext does not exist\"\r\n+\tif ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n+\t\techo >&2 \"error: /usr/src/php/ext/$ext does not exist\"\r\n \t\techo >&2\r\n \t\tusage >&2\r\n \t\texit 1\r\n@@ -72,6 +70,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+cd /usr/src/php/ext\r\n+\r\n for ext in $exts; do\r\n \t(\r\n \t\tcd \"$ext\"\r\n@@ -90,3 +91,4 @@ done\r\n if [ \"$pm\" = 'apk' ] && [ -n \"$apkDel\" ]; then\r\n \tapk del $apkDel\r\n fi\r\n+docker-php-source delete\r\ndiff --git a/php_5.5-fpm-alpine/docker-php-source b/php_5.5-fpm-alpine/docker-php-source\r\nnew file mode 100755\r\nindex 0000000..9020385\r\n--- /dev/null\r\n+++ b/php_5.5-fpm-alpine/docker-php-source\r\n@@ -0,0 +1,44 @@\r\n+#!/bin/sh\r\n+set -e\r\n+dir=/usr/src/php\r\n+\r\n+usage() {\r\n+\techo \"usage: $0 COMMAND\"\r\n+\techo\r\n+\techo \"Manage php source tarball lifecycle.\"\r\n+\techo\r\n+\techo \"Commands:\"\r\n+\techo \"   extract  extract php source tarball into directory $dir if not already done.\"\r\n+\techo \"   delete   delete extracted php source located into $dir if not already done.\"\r\n+\techo\r\n+}\r\n+\r\n+case \"$1\" in\r\n+\textract)\r\n+\t\tif [ -e \"$dir\" -a ! -d \"$dir\" ] ; then\r\n+\t\t\techo >&2 \"$dir exists and is not a directory\"\r\n+\t\t\texit 1\r\n+\t\tfi\r\n+\t\tif [ ! -d \"$dir\" ]; then\r\n+\t\t\tmkdir -p \"$dir\"\r\n+\t\t\ttar -Jxf /usr/src/php.tar.xz -C \"$dir\" --strip-components=1\r\n+\r\n+\t\t\tif [ ! -f /usr/src/php-available-exts ]; then\r\n+\t\t\t\tfind \"$dir/ext\" \\\r\n+\t\t\t\t\t\t-mindepth 2 \\\r\n+\t\t\t\t\t\t-maxdepth 2 \\\r\n+\t\t\t\t\t\t-type f \\\r\n+\t\t\t\t\t\t-name 'config.m4' \\\r\n+\t\t\t\t\t| xargs -n1 dirname | xargs -n1 basename | sort \\\r\n+\t\t\t\t> /usr/src/php-available-exts\r\n+\t\t\tfi\r\n+\t\tfi\r\n+\t\t;;\r\n+\tdelete)\r\n+\t\trm -rf \"$dir\"\r\n+\t\t;;\r\n+\t*)\r\n+\t\tusage\r\n+\t\texit 1\r\n+\t\t;;\r\n+esac\r\ndiff --git a/php_5.5-fpm/Dockerfile b/php_5.5-fpm/Dockerfile\r\nindex 541be00..ae7ab4a 100644\r\n--- a/php_5.5-fpm/Dockerfile\r\n+++ b/php_5.5-fpm/Dockerfile\r\n@@ -17,6 +17,7 @@ RUN apt-get update && apt-get install -y \\\r\n \t\tlibedit2 \\\r\n \t\tlibsqlite3-0 \\\r\n \t\tlibxml2 \\\r\n+\t\txz-utils \\\r\n \t--no-install-recommends && rm -r /var/lib/apt/lists/*\r\n \r\n ENV PHP_INI_DIR /usr/local/etc/php\r\n@@ -33,6 +34,20 @@ ENV PHP_FILENAME php-5.5.37.tar.xz\r\n ENV PHP_SHA256 c322444fdf6d3ba26aa67d67ee32d1e815a877f35831351c83763431a80e3612\r\n \r\n RUN set -xe \\\r\n+\t&& cd /usr/src/ \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o php.tar.xz \\\r\n+\t&& echo \"$PHP_SHA256 *php.tar.xz\" | sha256sum -c - \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o php.tar.xz.asc \\\r\n+\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n+\t&& for key in $GPG_KEYS; do \\\r\n+\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n+\tdone \\\r\n+\t&& gpg --batch --verify php.tar.xz.asc php.tar.xz \\\r\n+\t&& rm -r \"$GNUPGHOME\"\r\n+\r\n+COPY docker-php-source /usr/local/bin/\r\n+\r\n+RUN set -xe \\\r\n \t&& buildDeps=\" \\\r\n \t\t$PHP_EXTRA_BUILD_DEPS \\\r\n \t\tlibcurl4-openssl-dev \\\r\n@@ -40,21 +55,9 @@ RUN set -xe \\\r\n \t\tlibsqlite3-dev \\\r\n \t\tlibssl-dev \\\r\n \t\tlibxml2-dev \\\r\n-\t\txz-utils \\\r\n \t\" \\\r\n \t&& apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o \"$PHP_FILENAME\" \\\r\n-\t&& echo \"$PHP_SHA256 *$PHP_FILENAME\" | sha256sum -c - \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o \"$PHP_FILENAME.asc\" \\\r\n-\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n-\t&& for key in $GPG_KEYS; do \\\r\n-\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n-\tdone \\\r\n-\t&& gpg --batch --verify \"$PHP_FILENAME.asc\" \"$PHP_FILENAME\" \\\r\n-\t&& rm -r \"$GNUPGHOME\" \"$PHP_FILENAME.asc\" \\\r\n-\t&& mkdir -p /usr/src/php \\\r\n-\t&& tar -xf \"$PHP_FILENAME\" -C /usr/src/php --strip-components=1 \\\r\n-\t&& rm \"$PHP_FILENAME\" \\\r\n+\t&& docker-php-source extract \\\r\n \t&& cd /usr/src/php \\\r\n \t&& ./configure \\\r\n \t\t--with-config-file-path=\"$PHP_INI_DIR\" \\\r\n@@ -73,7 +76,8 @@ RUN set -xe \\\r\n \t&& make install \\\r\n \t&& { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \\\r\n \t&& make clean \\\r\n-\t&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps\r\n+\t&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps \\\r\n+\t&& docker-php-source delete\r\n \r\n COPY docker-php-ext-* /usr/local/bin/\r\n \r\ndiff --git a/php_5.5-fpm/docker-php-ext-configure b/php_5.5-fpm/docker-php-ext-configure\r\nindex dd56be1..ac3e899 100755\r\n--- a/php_5.5-fpm/docker-php-ext-configure\r\n+++ b/php_5.5-fpm/docker-php-ext-configure\r\n@@ -2,13 +2,12 @@\r\n set -e\r\n \r\n ext=\"$1\"\r\n-extDir=\"/usr/src/php/ext/$ext\"\r\n-if [ -z \"$ext\" ] || ! [ -d \"$extDir\" ]; then\r\n+if [ -z \"$ext\" ] || ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n \techo >&2 \"usage: $0 ext-name [configure flags]\"\r\n \techo >&2 \"   ie: $0 gd --with-jpeg-dir=/usr/local/something\"\r\n \techo >&2\r\n \techo >&2 'Possible values for ext-name:'\r\n-\techo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n \texit 1\r\n fi\r\n shift\r\n@@ -28,7 +27,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+\r\n set -x\r\n-cd \"$extDir\"\r\n+cd \"/usr/src/php/ext/$ext\"\r\n phpize\r\n ./configure \"$@\"\r\ndiff --git a/php_5.5-fpm/docker-php-ext-install b/php_5.5-fpm/docker-php-ext-install\r\nindex 43927b4..f7fc78d 100755\r\n--- a/php_5.5-fpm/docker-php-ext-install\r\n+++ b/php_5.5-fpm/docker-php-ext-install\r\n@@ -1,8 +1,6 @@\r\n #!/bin/sh\r\n set -e\r\n \r\n-cd /usr/src/php/ext\r\n-\r\n usage() {\r\n \techo \"usage: $0 [-jN] ext-name [ext-name ...]\"\r\n \techo \"   ie: $0 gd mysqli\"\r\n@@ -12,7 +10,7 @@ usage() {\r\n \techo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'\r\n \techo\r\n \techo 'Possible values for ext-name:'\r\n-\techo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n }\r\n \r\n opts=\"$(getopt -o 'h?j:' --long 'help,jobs:' -- \"$@\" || { usage >&2 && false; })\"\r\n@@ -41,8 +39,8 @@ for ext; do\r\n \tif [ -z \"$ext\" ]; then\r\n \t\tcontinue\r\n \tfi\r\n-\tif [ ! -d \"$ext\" ]; then\r\n-\t\techo >&2 \"error: $(pwd -P)/$ext does not exist\"\r\n+\tif ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n+\t\techo >&2 \"error: /usr/src/php/ext/$ext does not exist\"\r\n \t\techo >&2\r\n \t\tusage >&2\r\n \t\texit 1\r\n@@ -72,6 +70,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+cd /usr/src/php/ext\r\n+\r\n for ext in $exts; do\r\n \t(\r\n \t\tcd \"$ext\"\r\n@@ -90,3 +91,4 @@ done\r\n if [ \"$pm\" = 'apk' ] && [ -n \"$apkDel\" ]; then\r\n \tapk del $apkDel\r\n fi\r\n+docker-php-source delete\r\ndiff --git a/php_5.5-fpm/docker-php-source b/php_5.5-fpm/docker-php-source\r\nnew file mode 100755\r\nindex 0000000..9020385\r\n--- /dev/null\r\n+++ b/php_5.5-fpm/docker-php-source\r\n@@ -0,0 +1,44 @@\r\n+#!/bin/sh\r\n+set -e\r\n+dir=/usr/src/php\r\n+\r\n+usage() {\r\n+\techo \"usage: $0 COMMAND\"\r\n+\techo\r\n+\techo \"Manage php source tarball lifecycle.\"\r\n+\techo\r\n+\techo \"Commands:\"\r\n+\techo \"   extract  extract php source tarball into directory $dir if not already done.\"\r\n+\techo \"   delete   delete extracted php source located into $dir if not already done.\"\r\n+\techo\r\n+}\r\n+\r\n+case \"$1\" in\r\n+\textract)\r\n+\t\tif [ -e \"$dir\" -a ! -d \"$dir\" ] ; then\r\n+\t\t\techo >&2 \"$dir exists and is not a directory\"\r\n+\t\t\texit 1\r\n+\t\tfi\r\n+\t\tif [ ! -d \"$dir\" ]; then\r\n+\t\t\tmkdir -p \"$dir\"\r\n+\t\t\ttar -Jxf /usr/src/php.tar.xz -C \"$dir\" --strip-components=1\r\n+\r\n+\t\t\tif [ ! -f /usr/src/php-available-exts ]; then\r\n+\t\t\t\tfind \"$dir/ext\" \\\r\n+\t\t\t\t\t\t-mindepth 2 \\\r\n+\t\t\t\t\t\t-maxdepth 2 \\\r\n+\t\t\t\t\t\t-type f \\\r\n+\t\t\t\t\t\t-name 'config.m4' \\\r\n+\t\t\t\t\t| xargs -n1 dirname | xargs -n1 basename | sort \\\r\n+\t\t\t\t> /usr/src/php-available-exts\r\n+\t\t\tfi\r\n+\t\tfi\r\n+\t\t;;\r\n+\tdelete)\r\n+\t\trm -rf \"$dir\"\r\n+\t\t;;\r\n+\t*)\r\n+\t\tusage\r\n+\t\texit 1\r\n+\t\t;;\r\n+esac\r\ndiff --git a/php_5.5-zts-alpine/Dockerfile b/php_5.5-zts-alpine/Dockerfile\r\nindex eb3bc50..17b3cd8 100644\r\n--- a/php_5.5-zts-alpine/Dockerfile\r\n+++ b/php_5.5-zts-alpine/Dockerfile\r\n@@ -12,7 +12,9 @@ ENV PHPIZE_DEPS \\\r\n \t\tre2c\r\n RUN apk add --no-cache --virtual .persistent-deps \\\r\n \t\tca-certificates \\\r\n-\t\tcurl\r\n+\t\tcurl \\\r\n+\t\ttar \\\r\n+\t\txz\r\n \r\n # ensure www-data user exists\r\n RUN set -x \\\r\n@@ -37,27 +39,32 @@ ENV PHP_FILENAME php-5.5.37.tar.xz\r\n ENV PHP_SHA256 c322444fdf6d3ba26aa67d67ee32d1e815a877f35831351c83763431a80e3612\r\n \r\n RUN set -xe \\\r\n+\t&& apk add --no-cache --virtual .fetch-deps \\\r\n+\t\tgnupg \\\r\n+\t&& mkdir -p /usr/src \\\r\n+\t&& cd /usr/src/ \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o php.tar.xz \\\r\n+\t&& echo \"$PHP_SHA256 *php.tar.xz\" | sha256sum -c - \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o php.tar.xz.asc \\\r\n+\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n+\t&& for key in $GPG_KEYS; do \\\r\n+\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n+\tdone \\\r\n+\t&& gpg --batch --verify php.tar.xz.asc php.tar.xz \\\r\n+\t&& rm -r \"$GNUPGHOME\" \\\r\n+\t&& apk del .fetch-deps\r\n+\r\n+COPY docker-php-source /usr/local/bin/\r\n+\r\n+RUN set -xe \\\r\n \t&& apk add --no-cache --virtual .build-deps \\\r\n \t\t$PHPIZE_DEPS \\\r\n \t\tcurl-dev \\\r\n-\t\tgnupg \\\r\n \t\tlibedit-dev \\\r\n \t\tlibxml2-dev \\\r\n \t\topenssl-dev \\\r\n \t\tsqlite-dev \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o \"$PHP_FILENAME\" \\\r\n-\t&& echo \"$PHP_SHA256 *$PHP_FILENAME\" | sha256sum -c - \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o \"$PHP_FILENAME.asc\" \\\r\n-\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n-\t&& for key in $GPG_KEYS; do \\\r\n-\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n-\tdone \\\r\n-\t&& gpg --batch --verify \"$PHP_FILENAME.asc\" \"$PHP_FILENAME\" \\\r\n-\t&& rm -r \"$GNUPGHOME\" \"$PHP_FILENAME.asc\" \\\r\n-\t&& mkdir -p /usr/src \\\r\n-\t&& tar -Jxf \"$PHP_FILENAME\" -C /usr/src \\\r\n-\t&& mv \"/usr/src/php-$PHP_VERSION\" /usr/src/php \\\r\n-\t&& rm \"$PHP_FILENAME\" \\\r\n+\t&& docker-php-source extract \\\r\n \t&& cd /usr/src/php \\\r\n \t&& ./configure \\\r\n \t\t--with-config-file-path=\"$PHP_INI_DIR\" \\\r\n@@ -84,7 +91,8 @@ RUN set -xe \\\r\n \t\t\t| sort -u \\\r\n \t)\" \\\r\n \t&& apk add --no-cache --virtual .php-rundeps $runDeps \\\r\n-\t&& apk del .build-deps\r\n+\t&& apk del .build-deps \\\r\n+\t&& docker-php-source delete\r\n \r\n COPY docker-php-ext-* /usr/local/bin/\r\n \r\ndiff --git a/php_5.5-zts-alpine/docker-php-ext-configure b/php_5.5-zts-alpine/docker-php-ext-configure\r\nindex dd56be1..ac3e899 100755\r\n--- a/php_5.5-zts-alpine/docker-php-ext-configure\r\n+++ b/php_5.5-zts-alpine/docker-php-ext-configure\r\n@@ -2,13 +2,12 @@\r\n set -e\r\n \r\n ext=\"$1\"\r\n-extDir=\"/usr/src/php/ext/$ext\"\r\n-if [ -z \"$ext\" ] || ! [ -d \"$extDir\" ]; then\r\n+if [ -z \"$ext\" ] || ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n \techo >&2 \"usage: $0 ext-name [configure flags]\"\r\n \techo >&2 \"   ie: $0 gd --with-jpeg-dir=/usr/local/something\"\r\n \techo >&2\r\n \techo >&2 'Possible values for ext-name:'\r\n-\techo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n \texit 1\r\n fi\r\n shift\r\n@@ -28,7 +27,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+\r\n set -x\r\n-cd \"$extDir\"\r\n+cd \"/usr/src/php/ext/$ext\"\r\n phpize\r\n ./configure \"$@\"\r\ndiff --git a/php_5.5-zts-alpine/docker-php-ext-install b/php_5.5-zts-alpine/docker-php-ext-install\r\nindex 43927b4..f7fc78d 100755\r\n--- a/php_5.5-zts-alpine/docker-php-ext-install\r\n+++ b/php_5.5-zts-alpine/docker-php-ext-install\r\n@@ -1,8 +1,6 @@\r\n #!/bin/sh\r\n set -e\r\n \r\n-cd /usr/src/php/ext\r\n-\r\n usage() {\r\n \techo \"usage: $0 [-jN] ext-name [ext-name ...]\"\r\n \techo \"   ie: $0 gd mysqli\"\r\n@@ -12,7 +10,7 @@ usage() {\r\n \techo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'\r\n \techo\r\n \techo 'Possible values for ext-name:'\r\n-\techo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n }\r\n \r\n opts=\"$(getopt -o 'h?j:' --long 'help,jobs:' -- \"$@\" || { usage >&2 && false; })\"\r\n@@ -41,8 +39,8 @@ for ext; do\r\n \tif [ -z \"$ext\" ]; then\r\n \t\tcontinue\r\n \tfi\r\n-\tif [ ! -d \"$ext\" ]; then\r\n-\t\techo >&2 \"error: $(pwd -P)/$ext does not exist\"\r\n+\tif ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n+\t\techo >&2 \"error: /usr/src/php/ext/$ext does not exist\"\r\n \t\techo >&2\r\n \t\tusage >&2\r\n \t\texit 1\r\n@@ -72,6 +70,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+cd /usr/src/php/ext\r\n+\r\n for ext in $exts; do\r\n \t(\r\n \t\tcd \"$ext\"\r\n@@ -90,3 +91,4 @@ done\r\n if [ \"$pm\" = 'apk' ] && [ -n \"$apkDel\" ]; then\r\n \tapk del $apkDel\r\n fi\r\n+docker-php-source delete\r\ndiff --git a/php_5.5-zts-alpine/docker-php-source b/php_5.5-zts-alpine/docker-php-source\r\nnew file mode 100755\r\nindex 0000000..9020385\r\n--- /dev/null\r\n+++ b/php_5.5-zts-alpine/docker-php-source\r\n@@ -0,0 +1,44 @@\r\n+#!/bin/sh\r\n+set -e\r\n+dir=/usr/src/php\r\n+\r\n+usage() {\r\n+\techo \"usage: $0 COMMAND\"\r\n+\techo\r\n+\techo \"Manage php source tarball lifecycle.\"\r\n+\techo\r\n+\techo \"Commands:\"\r\n+\techo \"   extract  extract php source tarball into directory $dir if not already done.\"\r\n+\techo \"   delete   delete extracted php source located into $dir if not already done.\"\r\n+\techo\r\n+}\r\n+\r\n+case \"$1\" in\r\n+\textract)\r\n+\t\tif [ -e \"$dir\" -a ! -d \"$dir\" ] ; then\r\n+\t\t\techo >&2 \"$dir exists and is not a directory\"\r\n+\t\t\texit 1\r\n+\t\tfi\r\n+\t\tif [ ! -d \"$dir\" ]; then\r\n+\t\t\tmkdir -p \"$dir\"\r\n+\t\t\ttar -Jxf /usr/src/php.tar.xz -C \"$dir\" --strip-components=1\r\n+\r\n+\t\t\tif [ ! -f /usr/src/php-available-exts ]; then\r\n+\t\t\t\tfind \"$dir/ext\" \\\r\n+\t\t\t\t\t\t-mindepth 2 \\\r\n+\t\t\t\t\t\t-maxdepth 2 \\\r\n+\t\t\t\t\t\t-type f \\\r\n+\t\t\t\t\t\t-name 'config.m4' \\\r\n+\t\t\t\t\t| xargs -n1 dirname | xargs -n1 basename | sort \\\r\n+\t\t\t\t> /usr/src/php-available-exts\r\n+\t\t\tfi\r\n+\t\tfi\r\n+\t\t;;\r\n+\tdelete)\r\n+\t\trm -rf \"$dir\"\r\n+\t\t;;\r\n+\t*)\r\n+\t\tusage\r\n+\t\texit 1\r\n+\t\t;;\r\n+esac\r\ndiff --git a/php_5.5-zts/Dockerfile b/php_5.5-zts/Dockerfile\r\nindex ed83bff..58602a7 100644\r\n--- a/php_5.5-zts/Dockerfile\r\n+++ b/php_5.5-zts/Dockerfile\r\n@@ -17,6 +17,7 @@ RUN apt-get update && apt-get install -y \\\r\n \t\tlibedit2 \\\r\n \t\tlibsqlite3-0 \\\r\n \t\tlibxml2 \\\r\n+\t\txz-utils \\\r\n \t--no-install-recommends && rm -r /var/lib/apt/lists/*\r\n \r\n ENV PHP_INI_DIR /usr/local/etc/php\r\n@@ -33,6 +34,20 @@ ENV PHP_FILENAME php-5.5.37.tar.xz\r\n ENV PHP_SHA256 c322444fdf6d3ba26aa67d67ee32d1e815a877f35831351c83763431a80e3612\r\n \r\n RUN set -xe \\\r\n+\t&& cd /usr/src/ \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o php.tar.xz \\\r\n+\t&& echo \"$PHP_SHA256 *php.tar.xz\" | sha256sum -c - \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o php.tar.xz.asc \\\r\n+\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n+\t&& for key in $GPG_KEYS; do \\\r\n+\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n+\tdone \\\r\n+\t&& gpg --batch --verify php.tar.xz.asc php.tar.xz \\\r\n+\t&& rm -r \"$GNUPGHOME\"\r\n+\r\n+COPY docker-php-source /usr/local/bin/\r\n+\r\n+RUN set -xe \\\r\n \t&& buildDeps=\" \\\r\n \t\t$PHP_EXTRA_BUILD_DEPS \\\r\n \t\tlibcurl4-openssl-dev \\\r\n@@ -40,21 +55,9 @@ RUN set -xe \\\r\n \t\tlibsqlite3-dev \\\r\n \t\tlibssl-dev \\\r\n \t\tlibxml2-dev \\\r\n-\t\txz-utils \\\r\n \t\" \\\r\n \t&& apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o \"$PHP_FILENAME\" \\\r\n-\t&& echo \"$PHP_SHA256 *$PHP_FILENAME\" | sha256sum -c - \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o \"$PHP_FILENAME.asc\" \\\r\n-\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n-\t&& for key in $GPG_KEYS; do \\\r\n-\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n-\tdone \\\r\n-\t&& gpg --batch --verify \"$PHP_FILENAME.asc\" \"$PHP_FILENAME\" \\\r\n-\t&& rm -r \"$GNUPGHOME\" \"$PHP_FILENAME.asc\" \\\r\n-\t&& mkdir -p /usr/src/php \\\r\n-\t&& tar -xf \"$PHP_FILENAME\" -C /usr/src/php --strip-components=1 \\\r\n-\t&& rm \"$PHP_FILENAME\" \\\r\n+\t&& docker-php-source extract \\\r\n \t&& cd /usr/src/php \\\r\n \t&& ./configure \\\r\n \t\t--with-config-file-path=\"$PHP_INI_DIR\" \\\r\n@@ -73,7 +76,8 @@ RUN set -xe \\\r\n \t&& make install \\\r\n \t&& { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \\\r\n \t&& make clean \\\r\n-\t&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps\r\n+\t&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps \\\r\n+\t&& docker-php-source delete\r\n \r\n COPY docker-php-ext-* /usr/local/bin/\r\n \r\ndiff --git a/php_5.5-zts/docker-php-ext-configure b/php_5.5-zts/docker-php-ext-configure\r\nindex dd56be1..ac3e899 100755\r\n--- a/php_5.5-zts/docker-php-ext-configure\r\n+++ b/php_5.5-zts/docker-php-ext-configure\r\n@@ -2,13 +2,12 @@\r\n set -e\r\n \r\n ext=\"$1\"\r\n-extDir=\"/usr/src/php/ext/$ext\"\r\n-if [ -z \"$ext\" ] || ! [ -d \"$extDir\" ]; then\r\n+if [ -z \"$ext\" ] || ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n \techo >&2 \"usage: $0 ext-name [configure flags]\"\r\n \techo >&2 \"   ie: $0 gd --with-jpeg-dir=/usr/local/something\"\r\n \techo >&2\r\n \techo >&2 'Possible values for ext-name:'\r\n-\techo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n \texit 1\r\n fi\r\n shift\r\n@@ -28,7 +27,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+\r\n set -x\r\n-cd \"$extDir\"\r\n+cd \"/usr/src/php/ext/$ext\"\r\n phpize\r\n ./configure \"$@\"\r\ndiff --git a/php_5.5-zts/docker-php-ext-install b/php_5.5-zts/docker-php-ext-install\r\nindex 43927b4..f7fc78d 100755\r\n--- a/php_5.5-zts/docker-php-ext-install\r\n+++ b/php_5.5-zts/docker-php-ext-install\r\n@@ -1,8 +1,6 @@\r\n #!/bin/sh\r\n set -e\r\n \r\n-cd /usr/src/php/ext\r\n-\r\n usage() {\r\n \techo \"usage: $0 [-jN] ext-name [ext-name ...]\"\r\n \techo \"   ie: $0 gd mysqli\"\r\n@@ -12,7 +10,7 @@ usage() {\r\n \techo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'\r\n \techo\r\n \techo 'Possible values for ext-name:'\r\n-\techo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n }\r\n \r\n opts=\"$(getopt -o 'h?j:' --long 'help,jobs:' -- \"$@\" || { usage >&2 && false; })\"\r\n@@ -41,8 +39,8 @@ for ext; do\r\n \tif [ -z \"$ext\" ]; then\r\n \t\tcontinue\r\n \tfi\r\n-\tif [ ! -d \"$ext\" ]; then\r\n-\t\techo >&2 \"error: $(pwd -P)/$ext does not exist\"\r\n+\tif ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n+\t\techo >&2 \"error: /usr/src/php/ext/$ext does not exist\"\r\n \t\techo >&2\r\n \t\tusage >&2\r\n \t\texit 1\r\n@@ -72,6 +70,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+cd /usr/src/php/ext\r\n+\r\n for ext in $exts; do\r\n \t(\r\n \t\tcd \"$ext\"\r\n@@ -90,3 +91,4 @@ done\r\n if [ \"$pm\" = 'apk' ] && [ -n \"$apkDel\" ]; then\r\n \tapk del $apkDel\r\n fi\r\n+docker-php-source delete\r\ndiff --git a/php_5.5-zts/docker-php-source b/php_5.5-zts/docker-php-source\r\nnew file mode 100755\r\nindex 0000000..9020385\r\n--- /dev/null\r\n+++ b/php_5.5-zts/docker-php-source\r\n@@ -0,0 +1,44 @@\r\n+#!/bin/sh\r\n+set -e\r\n+dir=/usr/src/php\r\n+\r\n+usage() {\r\n+\techo \"usage: $0 COMMAND\"\r\n+\techo\r\n+\techo \"Manage php source tarball lifecycle.\"\r\n+\techo\r\n+\techo \"Commands:\"\r\n+\techo \"   extract  extract php source tarball into directory $dir if not already done.\"\r\n+\techo \"   delete   delete extracted php source located into $dir if not already done.\"\r\n+\techo\r\n+}\r\n+\r\n+case \"$1\" in\r\n+\textract)\r\n+\t\tif [ -e \"$dir\" -a ! -d \"$dir\" ] ; then\r\n+\t\t\techo >&2 \"$dir exists and is not a directory\"\r\n+\t\t\texit 1\r\n+\t\tfi\r\n+\t\tif [ ! -d \"$dir\" ]; then\r\n+\t\t\tmkdir -p \"$dir\"\r\n+\t\t\ttar -Jxf /usr/src/php.tar.xz -C \"$dir\" --strip-components=1\r\n+\r\n+\t\t\tif [ ! -f /usr/src/php-available-exts ]; then\r\n+\t\t\t\tfind \"$dir/ext\" \\\r\n+\t\t\t\t\t\t-mindepth 2 \\\r\n+\t\t\t\t\t\t-maxdepth 2 \\\r\n+\t\t\t\t\t\t-type f \\\r\n+\t\t\t\t\t\t-name 'config.m4' \\\r\n+\t\t\t\t\t| xargs -n1 dirname | xargs -n1 basename | sort \\\r\n+\t\t\t\t> /usr/src/php-available-exts\r\n+\t\t\tfi\r\n+\t\tfi\r\n+\t\t;;\r\n+\tdelete)\r\n+\t\trm -rf \"$dir\"\r\n+\t\t;;\r\n+\t*)\r\n+\t\tusage\r\n+\t\texit 1\r\n+\t\t;;\r\n+esac\r\ndiff --git a/php_5.5/Dockerfile b/php_5.5/Dockerfile\r\nindex 2ee386b..6146e3f 100644\r\n--- a/php_5.5/Dockerfile\r\n+++ b/php_5.5/Dockerfile\r\n@@ -17,6 +17,7 @@ RUN apt-get update && apt-get install -y \\\r\n \t\tlibedit2 \\\r\n \t\tlibsqlite3-0 \\\r\n \t\tlibxml2 \\\r\n+\t\txz-utils \\\r\n \t--no-install-recommends && rm -r /var/lib/apt/lists/*\r\n \r\n ENV PHP_INI_DIR /usr/local/etc/php\r\n@@ -32,6 +33,20 @@ ENV PHP_FILENAME php-5.5.37.tar.xz\r\n ENV PHP_SHA256 c322444fdf6d3ba26aa67d67ee32d1e815a877f35831351c83763431a80e3612\r\n \r\n RUN set -xe \\\r\n+\t&& cd /usr/src/ \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o php.tar.xz \\\r\n+\t&& echo \"$PHP_SHA256 *php.tar.xz\" | sha256sum -c - \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o php.tar.xz.asc \\\r\n+\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n+\t&& for key in $GPG_KEYS; do \\\r\n+\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n+\tdone \\\r\n+\t&& gpg --batch --verify php.tar.xz.asc php.tar.xz \\\r\n+\t&& rm -r \"$GNUPGHOME\"\r\n+\r\n+COPY docker-php-source /usr/local/bin/\r\n+\r\n+RUN set -xe \\\r\n \t&& buildDeps=\" \\\r\n \t\t$PHP_EXTRA_BUILD_DEPS \\\r\n \t\tlibcurl4-openssl-dev \\\r\n@@ -39,21 +54,9 @@ RUN set -xe \\\r\n \t\tlibsqlite3-dev \\\r\n \t\tlibssl-dev \\\r\n \t\tlibxml2-dev \\\r\n-\t\txz-utils \\\r\n \t\" \\\r\n \t&& apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o \"$PHP_FILENAME\" \\\r\n-\t&& echo \"$PHP_SHA256 *$PHP_FILENAME\" | sha256sum -c - \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o \"$PHP_FILENAME.asc\" \\\r\n-\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n-\t&& for key in $GPG_KEYS; do \\\r\n-\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n-\tdone \\\r\n-\t&& gpg --batch --verify \"$PHP_FILENAME.asc\" \"$PHP_FILENAME\" \\\r\n-\t&& rm -r \"$GNUPGHOME\" \"$PHP_FILENAME.asc\" \\\r\n-\t&& mkdir -p /usr/src/php \\\r\n-\t&& tar -xf \"$PHP_FILENAME\" -C /usr/src/php --strip-components=1 \\\r\n-\t&& rm \"$PHP_FILENAME\" \\\r\n+\t&& docker-php-source extract \\\r\n \t&& cd /usr/src/php \\\r\n \t&& ./configure \\\r\n \t\t--with-config-file-path=\"$PHP_INI_DIR\" \\\r\n@@ -72,7 +75,8 @@ RUN set -xe \\\r\n \t&& make install \\\r\n \t&& { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \\\r\n \t&& make clean \\\r\n-\t&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps\r\n+\t&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps \\\r\n+\t&& docker-php-source delete\r\n \r\n COPY docker-php-ext-* /usr/local/bin/\r\n \r\ndiff --git a/php_5.5/docker-php-ext-configure b/php_5.5/docker-php-ext-configure\r\nindex dd56be1..ac3e899 100755\r\n--- a/php_5.5/docker-php-ext-configure\r\n+++ b/php_5.5/docker-php-ext-configure\r\n@@ -2,13 +2,12 @@\r\n set -e\r\n \r\n ext=\"$1\"\r\n-extDir=\"/usr/src/php/ext/$ext\"\r\n-if [ -z \"$ext\" ] || ! [ -d \"$extDir\" ]; then\r\n+if [ -z \"$ext\" ] || ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n \techo >&2 \"usage: $0 ext-name [configure flags]\"\r\n \techo >&2 \"   ie: $0 gd --with-jpeg-dir=/usr/local/something\"\r\n \techo >&2\r\n \techo >&2 'Possible values for ext-name:'\r\n-\techo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n \texit 1\r\n fi\r\n shift\r\n@@ -28,7 +27,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+\r\n set -x\r\n-cd \"$extDir\"\r\n+cd \"/usr/src/php/ext/$ext\"\r\n phpize\r\n ./configure \"$@\"\r\ndiff --git a/php_5.5/docker-php-ext-install b/php_5.5/docker-php-ext-install\r\nindex 43927b4..f7fc78d 100755\r\n--- a/php_5.5/docker-php-ext-install\r\n+++ b/php_5.5/docker-php-ext-install\r\n@@ -1,8 +1,6 @@\r\n #!/bin/sh\r\n set -e\r\n \r\n-cd /usr/src/php/ext\r\n-\r\n usage() {\r\n \techo \"usage: $0 [-jN] ext-name [ext-name ...]\"\r\n \techo \"   ie: $0 gd mysqli\"\r\n@@ -12,7 +10,7 @@ usage() {\r\n \techo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'\r\n \techo\r\n \techo 'Possible values for ext-name:'\r\n-\techo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n }\r\n \r\n opts=\"$(getopt -o 'h?j:' --long 'help,jobs:' -- \"$@\" || { usage >&2 && false; })\"\r\n@@ -41,8 +39,8 @@ for ext; do\r\n \tif [ -z \"$ext\" ]; then\r\n \t\tcontinue\r\n \tfi\r\n-\tif [ ! -d \"$ext\" ]; then\r\n-\t\techo >&2 \"error: $(pwd -P)/$ext does not exist\"\r\n+\tif ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n+\t\techo >&2 \"error: /usr/src/php/ext/$ext does not exist\"\r\n \t\techo >&2\r\n \t\tusage >&2\r\n \t\texit 1\r\n@@ -72,6 +70,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+cd /usr/src/php/ext\r\n+\r\n for ext in $exts; do\r\n \t(\r\n \t\tcd \"$ext\"\r\n@@ -90,3 +91,4 @@ done\r\n if [ \"$pm\" = 'apk' ] && [ -n \"$apkDel\" ]; then\r\n \tapk del $apkDel\r\n fi\r\n+docker-php-source delete\r\ndiff --git a/php_5.5/docker-php-source b/php_5.5/docker-php-source\r\nnew file mode 100755\r\nindex 0000000..9020385\r\n--- /dev/null\r\n+++ b/php_5.5/docker-php-source\r\n@@ -0,0 +1,44 @@\r\n+#!/bin/sh\r\n+set -e\r\n+dir=/usr/src/php\r\n+\r\n+usage() {\r\n+\techo \"usage: $0 COMMAND\"\r\n+\techo\r\n+\techo \"Manage php source tarball lifecycle.\"\r\n+\techo\r\n+\techo \"Commands:\"\r\n+\techo \"   extract  extract php source tarball into directory $dir if not already done.\"\r\n+\techo \"   delete   delete extracted php source located into $dir if not already done.\"\r\n+\techo\r\n+}\r\n+\r\n+case \"$1\" in\r\n+\textract)\r\n+\t\tif [ -e \"$dir\" -a ! -d \"$dir\" ] ; then\r\n+\t\t\techo >&2 \"$dir exists and is not a directory\"\r\n+\t\t\texit 1\r\n+\t\tfi\r\n+\t\tif [ ! -d \"$dir\" ]; then\r\n+\t\t\tmkdir -p \"$dir\"\r\n+\t\t\ttar -Jxf /usr/src/php.tar.xz -C \"$dir\" --strip-components=1\r\n+\r\n+\t\t\tif [ ! -f /usr/src/php-available-exts ]; then\r\n+\t\t\t\tfind \"$dir/ext\" \\\r\n+\t\t\t\t\t\t-mindepth 2 \\\r\n+\t\t\t\t\t\t-maxdepth 2 \\\r\n+\t\t\t\t\t\t-type f \\\r\n+\t\t\t\t\t\t-name 'config.m4' \\\r\n+\t\t\t\t\t| xargs -n1 dirname | xargs -n1 basename | sort \\\r\n+\t\t\t\t> /usr/src/php-available-exts\r\n+\t\t\tfi\r\n+\t\tfi\r\n+\t\t;;\r\n+\tdelete)\r\n+\t\trm -rf \"$dir\"\r\n+\t\t;;\r\n+\t*)\r\n+\t\tusage\r\n+\t\texit 1\r\n+\t\t;;\r\n+esac\r\ndiff --git a/php_5/Dockerfile b/php_5/Dockerfile\r\nindex f407eef..fd20418 100644\r\n--- a/php_5/Dockerfile\r\n+++ b/php_5/Dockerfile\r\n@@ -17,6 +17,7 @@ RUN apt-get update && apt-get install -y \\\r\n \t\tlibedit2 \\\r\n \t\tlibsqlite3-0 \\\r\n \t\tlibxml2 \\\r\n+\t\txz-utils \\\r\n \t--no-install-recommends && rm -r /var/lib/apt/lists/*\r\n \r\n ENV PHP_INI_DIR /usr/local/etc/php\r\n@@ -32,6 +33,20 @@ ENV PHP_FILENAME php-5.6.23.tar.xz\r\n ENV PHP_SHA256 39141e9a617af172aedbbacee7a63eb15502850f7cea20d759a9cffa7cfb0a1a\r\n \r\n RUN set -xe \\\r\n+\t&& cd /usr/src/ \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o php.tar.xz \\\r\n+\t&& echo \"$PHP_SHA256 *php.tar.xz\" | sha256sum -c - \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o php.tar.xz.asc \\\r\n+\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n+\t&& for key in $GPG_KEYS; do \\\r\n+\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n+\tdone \\\r\n+\t&& gpg --batch --verify php.tar.xz.asc php.tar.xz \\\r\n+\t&& rm -r \"$GNUPGHOME\"\r\n+\r\n+COPY docker-php-source /usr/local/bin/\r\n+\r\n+RUN set -xe \\\r\n \t&& buildDeps=\" \\\r\n \t\t$PHP_EXTRA_BUILD_DEPS \\\r\n \t\tlibcurl4-openssl-dev \\\r\n@@ -39,21 +54,9 @@ RUN set -xe \\\r\n \t\tlibsqlite3-dev \\\r\n \t\tlibssl-dev \\\r\n \t\tlibxml2-dev \\\r\n-\t\txz-utils \\\r\n \t\" \\\r\n \t&& apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o \"$PHP_FILENAME\" \\\r\n-\t&& echo \"$PHP_SHA256 *$PHP_FILENAME\" | sha256sum -c - \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o \"$PHP_FILENAME.asc\" \\\r\n-\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n-\t&& for key in $GPG_KEYS; do \\\r\n-\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n-\tdone \\\r\n-\t&& gpg --batch --verify \"$PHP_FILENAME.asc\" \"$PHP_FILENAME\" \\\r\n-\t&& rm -r \"$GNUPGHOME\" \"$PHP_FILENAME.asc\" \\\r\n-\t&& mkdir -p /usr/src/php \\\r\n-\t&& tar -xf \"$PHP_FILENAME\" -C /usr/src/php --strip-components=1 \\\r\n-\t&& rm \"$PHP_FILENAME\" \\\r\n+\t&& docker-php-source extract \\\r\n \t&& cd /usr/src/php \\\r\n \t&& ./configure \\\r\n \t\t--with-config-file-path=\"$PHP_INI_DIR\" \\\r\n@@ -72,7 +75,8 @@ RUN set -xe \\\r\n \t&& make install \\\r\n \t&& { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \\\r\n \t&& make clean \\\r\n-\t&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps\r\n+\t&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps \\\r\n+\t&& docker-php-source delete\r\n \r\n COPY docker-php-ext-* /usr/local/bin/\r\n \r\ndiff --git a/php_5/docker-php-ext-configure b/php_5/docker-php-ext-configure\r\nindex dd56be1..ac3e899 100755\r\n--- a/php_5/docker-php-ext-configure\r\n+++ b/php_5/docker-php-ext-configure\r\n@@ -2,13 +2,12 @@\r\n set -e\r\n \r\n ext=\"$1\"\r\n-extDir=\"/usr/src/php/ext/$ext\"\r\n-if [ -z \"$ext\" ] || ! [ -d \"$extDir\" ]; then\r\n+if [ -z \"$ext\" ] || ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n \techo >&2 \"usage: $0 ext-name [configure flags]\"\r\n \techo >&2 \"   ie: $0 gd --with-jpeg-dir=/usr/local/something\"\r\n \techo >&2\r\n \techo >&2 'Possible values for ext-name:'\r\n-\techo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n \texit 1\r\n fi\r\n shift\r\n@@ -28,7 +27,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+\r\n set -x\r\n-cd \"$extDir\"\r\n+cd \"/usr/src/php/ext/$ext\"\r\n phpize\r\n ./configure \"$@\"\r\ndiff --git a/php_5/docker-php-ext-install b/php_5/docker-php-ext-install\r\nindex 43927b4..f7fc78d 100755\r\n--- a/php_5/docker-php-ext-install\r\n+++ b/php_5/docker-php-ext-install\r\n@@ -1,8 +1,6 @@\r\n #!/bin/sh\r\n set -e\r\n \r\n-cd /usr/src/php/ext\r\n-\r\n usage() {\r\n \techo \"usage: $0 [-jN] ext-name [ext-name ...]\"\r\n \techo \"   ie: $0 gd mysqli\"\r\n@@ -12,7 +10,7 @@ usage() {\r\n \techo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'\r\n \techo\r\n \techo 'Possible values for ext-name:'\r\n-\techo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n }\r\n \r\n opts=\"$(getopt -o 'h?j:' --long 'help,jobs:' -- \"$@\" || { usage >&2 && false; })\"\r\n@@ -41,8 +39,8 @@ for ext; do\r\n \tif [ -z \"$ext\" ]; then\r\n \t\tcontinue\r\n \tfi\r\n-\tif [ ! -d \"$ext\" ]; then\r\n-\t\techo >&2 \"error: $(pwd -P)/$ext does not exist\"\r\n+\tif ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n+\t\techo >&2 \"error: /usr/src/php/ext/$ext does not exist\"\r\n \t\techo >&2\r\n \t\tusage >&2\r\n \t\texit 1\r\n@@ -72,6 +70,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+cd /usr/src/php/ext\r\n+\r\n for ext in $exts; do\r\n \t(\r\n \t\tcd \"$ext\"\r\n@@ -90,3 +91,4 @@ done\r\n if [ \"$pm\" = 'apk' ] && [ -n \"$apkDel\" ]; then\r\n \tapk del $apkDel\r\n fi\r\n+docker-php-source delete\r\ndiff --git a/php_5/docker-php-source b/php_5/docker-php-source\r\nnew file mode 100755\r\nindex 0000000..9020385\r\n--- /dev/null\r\n+++ b/php_5/docker-php-source\r\n@@ -0,0 +1,44 @@\r\n+#!/bin/sh\r\n+set -e\r\n+dir=/usr/src/php\r\n+\r\n+usage() {\r\n+\techo \"usage: $0 COMMAND\"\r\n+\techo\r\n+\techo \"Manage php source tarball lifecycle.\"\r\n+\techo\r\n+\techo \"Commands:\"\r\n+\techo \"   extract  extract php source tarball into directory $dir if not already done.\"\r\n+\techo \"   delete   delete extracted php source located into $dir if not already done.\"\r\n+\techo\r\n+}\r\n+\r\n+case \"$1\" in\r\n+\textract)\r\n+\t\tif [ -e \"$dir\" -a ! -d \"$dir\" ] ; then\r\n+\t\t\techo >&2 \"$dir exists and is not a directory\"\r\n+\t\t\texit 1\r\n+\t\tfi\r\n+\t\tif [ ! -d \"$dir\" ]; then\r\n+\t\t\tmkdir -p \"$dir\"\r\n+\t\t\ttar -Jxf /usr/src/php.tar.xz -C \"$dir\" --strip-components=1\r\n+\r\n+\t\t\tif [ ! -f /usr/src/php-available-exts ]; then\r\n+\t\t\t\tfind \"$dir/ext\" \\\r\n+\t\t\t\t\t\t-mindepth 2 \\\r\n+\t\t\t\t\t\t-maxdepth 2 \\\r\n+\t\t\t\t\t\t-type f \\\r\n+\t\t\t\t\t\t-name 'config.m4' \\\r\n+\t\t\t\t\t| xargs -n1 dirname | xargs -n1 basename | sort \\\r\n+\t\t\t\t> /usr/src/php-available-exts\r\n+\t\t\tfi\r\n+\t\tfi\r\n+\t\t;;\r\n+\tdelete)\r\n+\t\trm -rf \"$dir\"\r\n+\t\t;;\r\n+\t*)\r\n+\t\tusage\r\n+\t\texit 1\r\n+\t\t;;\r\n+esac\r\ndiff --git a/php_alpine/Dockerfile b/php_alpine/Dockerfile\r\nindex 3404a67..2472dd0 100644\r\n--- a/php_alpine/Dockerfile\r\n+++ b/php_alpine/Dockerfile\r\n@@ -12,7 +12,9 @@ ENV PHPIZE_DEPS \\\r\n \t\tre2c\r\n RUN apk add --no-cache --virtual .persistent-deps \\\r\n \t\tca-certificates \\\r\n-\t\tcurl\r\n+\t\tcurl \\\r\n+\t\ttar \\\r\n+\t\txz\r\n \r\n # ensure www-data user exists\r\n RUN set -x \\\r\n@@ -36,27 +38,32 @@ ENV PHP_FILENAME php-7.0.8.tar.xz\r\n ENV PHP_SHA256 0a2142c458b0846f556b16da1c927d74c101aa951bb840549abe5c58584fb394\r\n \r\n RUN set -xe \\\r\n+\t&& apk add --no-cache --virtual .fetch-deps \\\r\n+\t\tgnupg \\\r\n+\t&& mkdir -p /usr/src \\\r\n+\t&& cd /usr/src/ \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o php.tar.xz \\\r\n+\t&& echo \"$PHP_SHA256 *php.tar.xz\" | sha256sum -c - \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o php.tar.xz.asc \\\r\n+\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n+\t&& for key in $GPG_KEYS; do \\\r\n+\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n+\tdone \\\r\n+\t&& gpg --batch --verify php.tar.xz.asc php.tar.xz \\\r\n+\t&& rm -r \"$GNUPGHOME\" \\\r\n+\t&& apk del .fetch-deps\r\n+\r\n+COPY docker-php-source /usr/local/bin/\r\n+\r\n+RUN set -xe \\\r\n \t&& apk add --no-cache --virtual .build-deps \\\r\n \t\t$PHPIZE_DEPS \\\r\n \t\tcurl-dev \\\r\n-\t\tgnupg \\\r\n \t\tlibedit-dev \\\r\n \t\tlibxml2-dev \\\r\n \t\topenssl-dev \\\r\n \t\tsqlite-dev \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o \"$PHP_FILENAME\" \\\r\n-\t&& echo \"$PHP_SHA256 *$PHP_FILENAME\" | sha256sum -c - \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o \"$PHP_FILENAME.asc\" \\\r\n-\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n-\t&& for key in $GPG_KEYS; do \\\r\n-\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n-\tdone \\\r\n-\t&& gpg --batch --verify \"$PHP_FILENAME.asc\" \"$PHP_FILENAME\" \\\r\n-\t&& rm -r \"$GNUPGHOME\" \"$PHP_FILENAME.asc\" \\\r\n-\t&& mkdir -p /usr/src \\\r\n-\t&& tar -Jxf \"$PHP_FILENAME\" -C /usr/src \\\r\n-\t&& mv \"/usr/src/php-$PHP_VERSION\" /usr/src/php \\\r\n-\t&& rm \"$PHP_FILENAME\" \\\r\n+\t&& docker-php-source extract \\\r\n \t&& cd /usr/src/php \\\r\n \t&& ./configure \\\r\n \t\t--with-config-file-path=\"$PHP_INI_DIR\" \\\r\n@@ -83,7 +90,8 @@ RUN set -xe \\\r\n \t\t\t| sort -u \\\r\n \t)\" \\\r\n \t&& apk add --no-cache --virtual .php-rundeps $runDeps \\\r\n-\t&& apk del .build-deps\r\n+\t&& apk del .build-deps \\\r\n+\t&& docker-php-source delete\r\n \r\n COPY docker-php-ext-* /usr/local/bin/\r\n \r\ndiff --git a/php_alpine/docker-php-ext-configure b/php_alpine/docker-php-ext-configure\r\nindex dd56be1..ac3e899 100755\r\n--- a/php_alpine/docker-php-ext-configure\r\n+++ b/php_alpine/docker-php-ext-configure\r\n@@ -2,13 +2,12 @@\r\n set -e\r\n \r\n ext=\"$1\"\r\n-extDir=\"/usr/src/php/ext/$ext\"\r\n-if [ -z \"$ext\" ] || ! [ -d \"$extDir\" ]; then\r\n+if [ -z \"$ext\" ] || ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n \techo >&2 \"usage: $0 ext-name [configure flags]\"\r\n \techo >&2 \"   ie: $0 gd --with-jpeg-dir=/usr/local/something\"\r\n \techo >&2\r\n \techo >&2 'Possible values for ext-name:'\r\n-\techo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n \texit 1\r\n fi\r\n shift\r\n@@ -28,7 +27,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+\r\n set -x\r\n-cd \"$extDir\"\r\n+cd \"/usr/src/php/ext/$ext\"\r\n phpize\r\n ./configure \"$@\"\r\ndiff --git a/php_alpine/docker-php-ext-install b/php_alpine/docker-php-ext-install\r\nindex 43927b4..f7fc78d 100755\r\n--- a/php_alpine/docker-php-ext-install\r\n+++ b/php_alpine/docker-php-ext-install\r\n@@ -1,8 +1,6 @@\r\n #!/bin/sh\r\n set -e\r\n \r\n-cd /usr/src/php/ext\r\n-\r\n usage() {\r\n \techo \"usage: $0 [-jN] ext-name [ext-name ...]\"\r\n \techo \"   ie: $0 gd mysqli\"\r\n@@ -12,7 +10,7 @@ usage() {\r\n \techo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'\r\n \techo\r\n \techo 'Possible values for ext-name:'\r\n-\techo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n }\r\n \r\n opts=\"$(getopt -o 'h?j:' --long 'help,jobs:' -- \"$@\" || { usage >&2 && false; })\"\r\n@@ -41,8 +39,8 @@ for ext; do\r\n \tif [ -z \"$ext\" ]; then\r\n \t\tcontinue\r\n \tfi\r\n-\tif [ ! -d \"$ext\" ]; then\r\n-\t\techo >&2 \"error: $(pwd -P)/$ext does not exist\"\r\n+\tif ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n+\t\techo >&2 \"error: /usr/src/php/ext/$ext does not exist\"\r\n \t\techo >&2\r\n \t\tusage >&2\r\n \t\texit 1\r\n@@ -72,6 +70,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+cd /usr/src/php/ext\r\n+\r\n for ext in $exts; do\r\n \t(\r\n \t\tcd \"$ext\"\r\n@@ -90,3 +91,4 @@ done\r\n if [ \"$pm\" = 'apk' ] && [ -n \"$apkDel\" ]; then\r\n \tapk del $apkDel\r\n fi\r\n+docker-php-source delete\r\ndiff --git a/php_alpine/docker-php-source b/php_alpine/docker-php-source\r\nnew file mode 100755\r\nindex 0000000..9020385\r\n--- /dev/null\r\n+++ b/php_alpine/docker-php-source\r\n@@ -0,0 +1,44 @@\r\n+#!/bin/sh\r\n+set -e\r\n+dir=/usr/src/php\r\n+\r\n+usage() {\r\n+\techo \"usage: $0 COMMAND\"\r\n+\techo\r\n+\techo \"Manage php source tarball lifecycle.\"\r\n+\techo\r\n+\techo \"Commands:\"\r\n+\techo \"   extract  extract php source tarball into directory $dir if not already done.\"\r\n+\techo \"   delete   delete extracted php source located into $dir if not already done.\"\r\n+\techo\r\n+}\r\n+\r\n+case \"$1\" in\r\n+\textract)\r\n+\t\tif [ -e \"$dir\" -a ! -d \"$dir\" ] ; then\r\n+\t\t\techo >&2 \"$dir exists and is not a directory\"\r\n+\t\t\texit 1\r\n+\t\tfi\r\n+\t\tif [ ! -d \"$dir\" ]; then\r\n+\t\t\tmkdir -p \"$dir\"\r\n+\t\t\ttar -Jxf /usr/src/php.tar.xz -C \"$dir\" --strip-components=1\r\n+\r\n+\t\t\tif [ ! -f /usr/src/php-available-exts ]; then\r\n+\t\t\t\tfind \"$dir/ext\" \\\r\n+\t\t\t\t\t\t-mindepth 2 \\\r\n+\t\t\t\t\t\t-maxdepth 2 \\\r\n+\t\t\t\t\t\t-type f \\\r\n+\t\t\t\t\t\t-name 'config.m4' \\\r\n+\t\t\t\t\t| xargs -n1 dirname | xargs -n1 basename | sort \\\r\n+\t\t\t\t> /usr/src/php-available-exts\r\n+\t\t\tfi\r\n+\t\tfi\r\n+\t\t;;\r\n+\tdelete)\r\n+\t\trm -rf \"$dir\"\r\n+\t\t;;\r\n+\t*)\r\n+\t\tusage\r\n+\t\texit 1\r\n+\t\t;;\r\n+esac\r\ndiff --git a/php_apache/Dockerfile b/php_apache/Dockerfile\r\nindex b927781..b97d082 100644\r\n--- a/php_apache/Dockerfile\r\n+++ b/php_apache/Dockerfile\r\n@@ -17,6 +17,7 @@ RUN apt-get update && apt-get install -y \\\r\n \t\tlibedit2 \\\r\n \t\tlibsqlite3-0 \\\r\n \t\tlibxml2 \\\r\n+\t\txz-utils \\\r\n \t--no-install-recommends && rm -r /var/lib/apt/lists/*\r\n \r\n ENV PHP_INI_DIR /usr/local/etc/php\r\n@@ -79,6 +80,20 @@ ENV PHP_FILENAME php-7.0.8.tar.xz\r\n ENV PHP_SHA256 0a2142c458b0846f556b16da1c927d74c101aa951bb840549abe5c58584fb394\r\n \r\n RUN set -xe \\\r\n+\t&& cd /usr/src/ \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o php.tar.xz \\\r\n+\t&& echo \"$PHP_SHA256 *php.tar.xz\" | sha256sum -c - \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o php.tar.xz.asc \\\r\n+\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n+\t&& for key in $GPG_KEYS; do \\\r\n+\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n+\tdone \\\r\n+\t&& gpg --batch --verify php.tar.xz.asc php.tar.xz \\\r\n+\t&& rm -r \"$GNUPGHOME\"\r\n+\r\n+COPY docker-php-source /usr/local/bin/\r\n+\r\n+RUN set -xe \\\r\n \t&& buildDeps=\" \\\r\n \t\t$PHP_EXTRA_BUILD_DEPS \\\r\n \t\tlibcurl4-openssl-dev \\\r\n@@ -86,21 +101,9 @@ RUN set -xe \\\r\n \t\tlibsqlite3-dev \\\r\n \t\tlibssl-dev \\\r\n \t\tlibxml2-dev \\\r\n-\t\txz-utils \\\r\n \t\" \\\r\n \t&& apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o \"$PHP_FILENAME\" \\\r\n-\t&& echo \"$PHP_SHA256 *$PHP_FILENAME\" | sha256sum -c - \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o \"$PHP_FILENAME.asc\" \\\r\n-\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n-\t&& for key in $GPG_KEYS; do \\\r\n-\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n-\tdone \\\r\n-\t&& gpg --batch --verify \"$PHP_FILENAME.asc\" \"$PHP_FILENAME\" \\\r\n-\t&& rm -r \"$GNUPGHOME\" \"$PHP_FILENAME.asc\" \\\r\n-\t&& mkdir -p /usr/src/php \\\r\n-\t&& tar -xf \"$PHP_FILENAME\" -C /usr/src/php --strip-components=1 \\\r\n-\t&& rm \"$PHP_FILENAME\" \\\r\n+\t&& docker-php-source extract \\\r\n \t&& cd /usr/src/php \\\r\n \t&& ./configure \\\r\n \t\t--with-config-file-path=\"$PHP_INI_DIR\" \\\r\n@@ -119,7 +122,8 @@ RUN set -xe \\\r\n \t&& make install \\\r\n \t&& { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \\\r\n \t&& make clean \\\r\n-\t&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps\r\n+\t&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps \\\r\n+\t&& docker-php-source delete\r\n \r\n COPY docker-php-ext-* /usr/local/bin/\r\n \r\ndiff --git a/php_apache/docker-php-ext-configure b/php_apache/docker-php-ext-configure\r\nindex dd56be1..ac3e899 100755\r\n--- a/php_apache/docker-php-ext-configure\r\n+++ b/php_apache/docker-php-ext-configure\r\n@@ -2,13 +2,12 @@\r\n set -e\r\n \r\n ext=\"$1\"\r\n-extDir=\"/usr/src/php/ext/$ext\"\r\n-if [ -z \"$ext\" ] || ! [ -d \"$extDir\" ]; then\r\n+if [ -z \"$ext\" ] || ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n \techo >&2 \"usage: $0 ext-name [configure flags]\"\r\n \techo >&2 \"   ie: $0 gd --with-jpeg-dir=/usr/local/something\"\r\n \techo >&2\r\n \techo >&2 'Possible values for ext-name:'\r\n-\techo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n \texit 1\r\n fi\r\n shift\r\n@@ -28,7 +27,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+\r\n set -x\r\n-cd \"$extDir\"\r\n+cd \"/usr/src/php/ext/$ext\"\r\n phpize\r\n ./configure \"$@\"\r\ndiff --git a/php_apache/docker-php-ext-install b/php_apache/docker-php-ext-install\r\nindex 43927b4..f7fc78d 100755\r\n--- a/php_apache/docker-php-ext-install\r\n+++ b/php_apache/docker-php-ext-install\r\n@@ -1,8 +1,6 @@\r\n #!/bin/sh\r\n set -e\r\n \r\n-cd /usr/src/php/ext\r\n-\r\n usage() {\r\n \techo \"usage: $0 [-jN] ext-name [ext-name ...]\"\r\n \techo \"   ie: $0 gd mysqli\"\r\n@@ -12,7 +10,7 @@ usage() {\r\n \techo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'\r\n \techo\r\n \techo 'Possible values for ext-name:'\r\n-\techo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n }\r\n \r\n opts=\"$(getopt -o 'h?j:' --long 'help,jobs:' -- \"$@\" || { usage >&2 && false; })\"\r\n@@ -41,8 +39,8 @@ for ext; do\r\n \tif [ -z \"$ext\" ]; then\r\n \t\tcontinue\r\n \tfi\r\n-\tif [ ! -d \"$ext\" ]; then\r\n-\t\techo >&2 \"error: $(pwd -P)/$ext does not exist\"\r\n+\tif ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n+\t\techo >&2 \"error: /usr/src/php/ext/$ext does not exist\"\r\n \t\techo >&2\r\n \t\tusage >&2\r\n \t\texit 1\r\n@@ -72,6 +70,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+cd /usr/src/php/ext\r\n+\r\n for ext in $exts; do\r\n \t(\r\n \t\tcd \"$ext\"\r\n@@ -90,3 +91,4 @@ done\r\n if [ \"$pm\" = 'apk' ] && [ -n \"$apkDel\" ]; then\r\n \tapk del $apkDel\r\n fi\r\n+docker-php-source delete\r\ndiff --git a/php_apache/docker-php-source b/php_apache/docker-php-source\r\nnew file mode 100755\r\nindex 0000000..9020385\r\n--- /dev/null\r\n+++ b/php_apache/docker-php-source\r\n@@ -0,0 +1,44 @@\r\n+#!/bin/sh\r\n+set -e\r\n+dir=/usr/src/php\r\n+\r\n+usage() {\r\n+\techo \"usage: $0 COMMAND\"\r\n+\techo\r\n+\techo \"Manage php source tarball lifecycle.\"\r\n+\techo\r\n+\techo \"Commands:\"\r\n+\techo \"   extract  extract php source tarball into directory $dir if not already done.\"\r\n+\techo \"   delete   delete extracted php source located into $dir if not already done.\"\r\n+\techo\r\n+}\r\n+\r\n+case \"$1\" in\r\n+\textract)\r\n+\t\tif [ -e \"$dir\" -a ! -d \"$dir\" ] ; then\r\n+\t\t\techo >&2 \"$dir exists and is not a directory\"\r\n+\t\t\texit 1\r\n+\t\tfi\r\n+\t\tif [ ! -d \"$dir\" ]; then\r\n+\t\t\tmkdir -p \"$dir\"\r\n+\t\t\ttar -Jxf /usr/src/php.tar.xz -C \"$dir\" --strip-components=1\r\n+\r\n+\t\t\tif [ ! -f /usr/src/php-available-exts ]; then\r\n+\t\t\t\tfind \"$dir/ext\" \\\r\n+\t\t\t\t\t\t-mindepth 2 \\\r\n+\t\t\t\t\t\t-maxdepth 2 \\\r\n+\t\t\t\t\t\t-type f \\\r\n+\t\t\t\t\t\t-name 'config.m4' \\\r\n+\t\t\t\t\t| xargs -n1 dirname | xargs -n1 basename | sort \\\r\n+\t\t\t\t> /usr/src/php-available-exts\r\n+\t\t\tfi\r\n+\t\tfi\r\n+\t\t;;\r\n+\tdelete)\r\n+\t\trm -rf \"$dir\"\r\n+\t\t;;\r\n+\t*)\r\n+\t\tusage\r\n+\t\texit 1\r\n+\t\t;;\r\n+esac\r\ndiff --git a/php_fpm-alpine/Dockerfile b/php_fpm-alpine/Dockerfile\r\nindex 9f0d923..4dab77a 100644\r\n--- a/php_fpm-alpine/Dockerfile\r\n+++ b/php_fpm-alpine/Dockerfile\r\n@@ -12,7 +12,9 @@ ENV PHPIZE_DEPS \\\r\n \t\tre2c\r\n RUN apk add --no-cache --virtual .persistent-deps \\\r\n \t\tca-certificates \\\r\n-\t\tcurl\r\n+\t\tcurl \\\r\n+\t\ttar \\\r\n+\t\txz\r\n \r\n # ensure www-data user exists\r\n RUN set -x \\\r\n@@ -37,27 +39,32 @@ ENV PHP_FILENAME php-7.0.8.tar.xz\r\n ENV PHP_SHA256 0a2142c458b0846f556b16da1c927d74c101aa951bb840549abe5c58584fb394\r\n \r\n RUN set -xe \\\r\n+\t&& apk add --no-cache --virtual .fetch-deps \\\r\n+\t\tgnupg \\\r\n+\t&& mkdir -p /usr/src \\\r\n+\t&& cd /usr/src/ \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o php.tar.xz \\\r\n+\t&& echo \"$PHP_SHA256 *php.tar.xz\" | sha256sum -c - \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o php.tar.xz.asc \\\r\n+\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n+\t&& for key in $GPG_KEYS; do \\\r\n+\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n+\tdone \\\r\n+\t&& gpg --batch --verify php.tar.xz.asc php.tar.xz \\\r\n+\t&& rm -r \"$GNUPGHOME\" \\\r\n+\t&& apk del .fetch-deps\r\n+\r\n+COPY docker-php-source /usr/local/bin/\r\n+\r\n+RUN set -xe \\\r\n \t&& apk add --no-cache --virtual .build-deps \\\r\n \t\t$PHPIZE_DEPS \\\r\n \t\tcurl-dev \\\r\n-\t\tgnupg \\\r\n \t\tlibedit-dev \\\r\n \t\tlibxml2-dev \\\r\n \t\topenssl-dev \\\r\n \t\tsqlite-dev \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o \"$PHP_FILENAME\" \\\r\n-\t&& echo \"$PHP_SHA256 *$PHP_FILENAME\" | sha256sum -c - \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o \"$PHP_FILENAME.asc\" \\\r\n-\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n-\t&& for key in $GPG_KEYS; do \\\r\n-\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n-\tdone \\\r\n-\t&& gpg --batch --verify \"$PHP_FILENAME.asc\" \"$PHP_FILENAME\" \\\r\n-\t&& rm -r \"$GNUPGHOME\" \"$PHP_FILENAME.asc\" \\\r\n-\t&& mkdir -p /usr/src \\\r\n-\t&& tar -Jxf \"$PHP_FILENAME\" -C /usr/src \\\r\n-\t&& mv \"/usr/src/php-$PHP_VERSION\" /usr/src/php \\\r\n-\t&& rm \"$PHP_FILENAME\" \\\r\n+\t&& docker-php-source extract \\\r\n \t&& cd /usr/src/php \\\r\n \t&& ./configure \\\r\n \t\t--with-config-file-path=\"$PHP_INI_DIR\" \\\r\n@@ -84,7 +91,8 @@ RUN set -xe \\\r\n \t\t\t| sort -u \\\r\n \t)\" \\\r\n \t&& apk add --no-cache --virtual .php-rundeps $runDeps \\\r\n-\t&& apk del .build-deps\r\n+\t&& apk del .build-deps \\\r\n+\t&& docker-php-source delete\r\n \r\n COPY docker-php-ext-* /usr/local/bin/\r\n \r\ndiff --git a/php_fpm-alpine/docker-php-ext-configure b/php_fpm-alpine/docker-php-ext-configure\r\nindex dd56be1..ac3e899 100755\r\n--- a/php_fpm-alpine/docker-php-ext-configure\r\n+++ b/php_fpm-alpine/docker-php-ext-configure\r\n@@ -2,13 +2,12 @@\r\n set -e\r\n \r\n ext=\"$1\"\r\n-extDir=\"/usr/src/php/ext/$ext\"\r\n-if [ -z \"$ext\" ] || ! [ -d \"$extDir\" ]; then\r\n+if [ -z \"$ext\" ] || ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n \techo >&2 \"usage: $0 ext-name [configure flags]\"\r\n \techo >&2 \"   ie: $0 gd --with-jpeg-dir=/usr/local/something\"\r\n \techo >&2\r\n \techo >&2 'Possible values for ext-name:'\r\n-\techo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n \texit 1\r\n fi\r\n shift\r\n@@ -28,7 +27,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+\r\n set -x\r\n-cd \"$extDir\"\r\n+cd \"/usr/src/php/ext/$ext\"\r\n phpize\r\n ./configure \"$@\"\r\ndiff --git a/php_fpm-alpine/docker-php-ext-install b/php_fpm-alpine/docker-php-ext-install\r\nindex 43927b4..f7fc78d 100755\r\n--- a/php_fpm-alpine/docker-php-ext-install\r\n+++ b/php_fpm-alpine/docker-php-ext-install\r\n@@ -1,8 +1,6 @@\r\n #!/bin/sh\r\n set -e\r\n \r\n-cd /usr/src/php/ext\r\n-\r\n usage() {\r\n \techo \"usage: $0 [-jN] ext-name [ext-name ...]\"\r\n \techo \"   ie: $0 gd mysqli\"\r\n@@ -12,7 +10,7 @@ usage() {\r\n \techo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'\r\n \techo\r\n \techo 'Possible values for ext-name:'\r\n-\techo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n }\r\n \r\n opts=\"$(getopt -o 'h?j:' --long 'help,jobs:' -- \"$@\" || { usage >&2 && false; })\"\r\n@@ -41,8 +39,8 @@ for ext; do\r\n \tif [ -z \"$ext\" ]; then\r\n \t\tcontinue\r\n \tfi\r\n-\tif [ ! -d \"$ext\" ]; then\r\n-\t\techo >&2 \"error: $(pwd -P)/$ext does not exist\"\r\n+\tif ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n+\t\techo >&2 \"error: /usr/src/php/ext/$ext does not exist\"\r\n \t\techo >&2\r\n \t\tusage >&2\r\n \t\texit 1\r\n@@ -72,6 +70,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+cd /usr/src/php/ext\r\n+\r\n for ext in $exts; do\r\n \t(\r\n \t\tcd \"$ext\"\r\n@@ -90,3 +91,4 @@ done\r\n if [ \"$pm\" = 'apk' ] && [ -n \"$apkDel\" ]; then\r\n \tapk del $apkDel\r\n fi\r\n+docker-php-source delete\r\ndiff --git a/php_fpm-alpine/docker-php-source b/php_fpm-alpine/docker-php-source\r\nnew file mode 100755\r\nindex 0000000..9020385\r\n--- /dev/null\r\n+++ b/php_fpm-alpine/docker-php-source\r\n@@ -0,0 +1,44 @@\r\n+#!/bin/sh\r\n+set -e\r\n+dir=/usr/src/php\r\n+\r\n+usage() {\r\n+\techo \"usage: $0 COMMAND\"\r\n+\techo\r\n+\techo \"Manage php source tarball lifecycle.\"\r\n+\techo\r\n+\techo \"Commands:\"\r\n+\techo \"   extract  extract php source tarball into directory $dir if not already done.\"\r\n+\techo \"   delete   delete extracted php source located into $dir if not already done.\"\r\n+\techo\r\n+}\r\n+\r\n+case \"$1\" in\r\n+\textract)\r\n+\t\tif [ -e \"$dir\" -a ! -d \"$dir\" ] ; then\r\n+\t\t\techo >&2 \"$dir exists and is not a directory\"\r\n+\t\t\texit 1\r\n+\t\tfi\r\n+\t\tif [ ! -d \"$dir\" ]; then\r\n+\t\t\tmkdir -p \"$dir\"\r\n+\t\t\ttar -Jxf /usr/src/php.tar.xz -C \"$dir\" --strip-components=1\r\n+\r\n+\t\t\tif [ ! -f /usr/src/php-available-exts ]; then\r\n+\t\t\t\tfind \"$dir/ext\" \\\r\n+\t\t\t\t\t\t-mindepth 2 \\\r\n+\t\t\t\t\t\t-maxdepth 2 \\\r\n+\t\t\t\t\t\t-type f \\\r\n+\t\t\t\t\t\t-name 'config.m4' \\\r\n+\t\t\t\t\t| xargs -n1 dirname | xargs -n1 basename | sort \\\r\n+\t\t\t\t> /usr/src/php-available-exts\r\n+\t\t\tfi\r\n+\t\tfi\r\n+\t\t;;\r\n+\tdelete)\r\n+\t\trm -rf \"$dir\"\r\n+\t\t;;\r\n+\t*)\r\n+\t\tusage\r\n+\t\texit 1\r\n+\t\t;;\r\n+esac\r\ndiff --git a/php_fpm/Dockerfile b/php_fpm/Dockerfile\r\nindex e7761c5..b692973 100644\r\n--- a/php_fpm/Dockerfile\r\n+++ b/php_fpm/Dockerfile\r\n@@ -17,6 +17,7 @@ RUN apt-get update && apt-get install -y \\\r\n \t\tlibedit2 \\\r\n \t\tlibsqlite3-0 \\\r\n \t\tlibxml2 \\\r\n+\t\txz-utils \\\r\n \t--no-install-recommends && rm -r /var/lib/apt/lists/*\r\n \r\n ENV PHP_INI_DIR /usr/local/etc/php\r\n@@ -33,6 +34,20 @@ ENV PHP_FILENAME php-7.0.8.tar.xz\r\n ENV PHP_SHA256 0a2142c458b0846f556b16da1c927d74c101aa951bb840549abe5c58584fb394\r\n \r\n RUN set -xe \\\r\n+\t&& cd /usr/src/ \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o php.tar.xz \\\r\n+\t&& echo \"$PHP_SHA256 *php.tar.xz\" | sha256sum -c - \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o php.tar.xz.asc \\\r\n+\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n+\t&& for key in $GPG_KEYS; do \\\r\n+\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n+\tdone \\\r\n+\t&& gpg --batch --verify php.tar.xz.asc php.tar.xz \\\r\n+\t&& rm -r \"$GNUPGHOME\"\r\n+\r\n+COPY docker-php-source /usr/local/bin/\r\n+\r\n+RUN set -xe \\\r\n \t&& buildDeps=\" \\\r\n \t\t$PHP_EXTRA_BUILD_DEPS \\\r\n \t\tlibcurl4-openssl-dev \\\r\n@@ -40,21 +55,9 @@ RUN set -xe \\\r\n \t\tlibsqlite3-dev \\\r\n \t\tlibssl-dev \\\r\n \t\tlibxml2-dev \\\r\n-\t\txz-utils \\\r\n \t\" \\\r\n \t&& apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o \"$PHP_FILENAME\" \\\r\n-\t&& echo \"$PHP_SHA256 *$PHP_FILENAME\" | sha256sum -c - \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o \"$PHP_FILENAME.asc\" \\\r\n-\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n-\t&& for key in $GPG_KEYS; do \\\r\n-\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n-\tdone \\\r\n-\t&& gpg --batch --verify \"$PHP_FILENAME.asc\" \"$PHP_FILENAME\" \\\r\n-\t&& rm -r \"$GNUPGHOME\" \"$PHP_FILENAME.asc\" \\\r\n-\t&& mkdir -p /usr/src/php \\\r\n-\t&& tar -xf \"$PHP_FILENAME\" -C /usr/src/php --strip-components=1 \\\r\n-\t&& rm \"$PHP_FILENAME\" \\\r\n+\t&& docker-php-source extract \\\r\n \t&& cd /usr/src/php \\\r\n \t&& ./configure \\\r\n \t\t--with-config-file-path=\"$PHP_INI_DIR\" \\\r\n@@ -73,7 +76,8 @@ RUN set -xe \\\r\n \t&& make install \\\r\n \t&& { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \\\r\n \t&& make clean \\\r\n-\t&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps\r\n+\t&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps \\\r\n+\t&& docker-php-source delete\r\n \r\n COPY docker-php-ext-* /usr/local/bin/\r\n \r\ndiff --git a/php_fpm/docker-php-ext-configure b/php_fpm/docker-php-ext-configure\r\nindex dd56be1..ac3e899 100755\r\n--- a/php_fpm/docker-php-ext-configure\r\n+++ b/php_fpm/docker-php-ext-configure\r\n@@ -2,13 +2,12 @@\r\n set -e\r\n \r\n ext=\"$1\"\r\n-extDir=\"/usr/src/php/ext/$ext\"\r\n-if [ -z \"$ext\" ] || ! [ -d \"$extDir\" ]; then\r\n+if [ -z \"$ext\" ] || ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n \techo >&2 \"usage: $0 ext-name [configure flags]\"\r\n \techo >&2 \"   ie: $0 gd --with-jpeg-dir=/usr/local/something\"\r\n \techo >&2\r\n \techo >&2 'Possible values for ext-name:'\r\n-\techo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n \texit 1\r\n fi\r\n shift\r\n@@ -28,7 +27,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+\r\n set -x\r\n-cd \"$extDir\"\r\n+cd \"/usr/src/php/ext/$ext\"\r\n phpize\r\n ./configure \"$@\"\r\ndiff --git a/php_fpm/docker-php-ext-install b/php_fpm/docker-php-ext-install\r\nindex 43927b4..f7fc78d 100755\r\n--- a/php_fpm/docker-php-ext-install\r\n+++ b/php_fpm/docker-php-ext-install\r\n@@ -1,8 +1,6 @@\r\n #!/bin/sh\r\n set -e\r\n \r\n-cd /usr/src/php/ext\r\n-\r\n usage() {\r\n \techo \"usage: $0 [-jN] ext-name [ext-name ...]\"\r\n \techo \"   ie: $0 gd mysqli\"\r\n@@ -12,7 +10,7 @@ usage() {\r\n \techo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'\r\n \techo\r\n \techo 'Possible values for ext-name:'\r\n-\techo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n }\r\n \r\n opts=\"$(getopt -o 'h?j:' --long 'help,jobs:' -- \"$@\" || { usage >&2 && false; })\"\r\n@@ -41,8 +39,8 @@ for ext; do\r\n \tif [ -z \"$ext\" ]; then\r\n \t\tcontinue\r\n \tfi\r\n-\tif [ ! -d \"$ext\" ]; then\r\n-\t\techo >&2 \"error: $(pwd -P)/$ext does not exist\"\r\n+\tif ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n+\t\techo >&2 \"error: /usr/src/php/ext/$ext does not exist\"\r\n \t\techo >&2\r\n \t\tusage >&2\r\n \t\texit 1\r\n@@ -72,6 +70,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+cd /usr/src/php/ext\r\n+\r\n for ext in $exts; do\r\n \t(\r\n \t\tcd \"$ext\"\r\n@@ -90,3 +91,4 @@ done\r\n if [ \"$pm\" = 'apk' ] && [ -n \"$apkDel\" ]; then\r\n \tapk del $apkDel\r\n fi\r\n+docker-php-source delete\r\ndiff --git a/php_fpm/docker-php-source b/php_fpm/docker-php-source\r\nnew file mode 100755\r\nindex 0000000..9020385\r\n--- /dev/null\r\n+++ b/php_fpm/docker-php-source\r\n@@ -0,0 +1,44 @@\r\n+#!/bin/sh\r\n+set -e\r\n+dir=/usr/src/php\r\n+\r\n+usage() {\r\n+\techo \"usage: $0 COMMAND\"\r\n+\techo\r\n+\techo \"Manage php source tarball lifecycle.\"\r\n+\techo\r\n+\techo \"Commands:\"\r\n+\techo \"   extract  extract php source tarball into directory $dir if not already done.\"\r\n+\techo \"   delete   delete extracted php source located into $dir if not already done.\"\r\n+\techo\r\n+}\r\n+\r\n+case \"$1\" in\r\n+\textract)\r\n+\t\tif [ -e \"$dir\" -a ! -d \"$dir\" ] ; then\r\n+\t\t\techo >&2 \"$dir exists and is not a directory\"\r\n+\t\t\texit 1\r\n+\t\tfi\r\n+\t\tif [ ! -d \"$dir\" ]; then\r\n+\t\t\tmkdir -p \"$dir\"\r\n+\t\t\ttar -Jxf /usr/src/php.tar.xz -C \"$dir\" --strip-components=1\r\n+\r\n+\t\t\tif [ ! -f /usr/src/php-available-exts ]; then\r\n+\t\t\t\tfind \"$dir/ext\" \\\r\n+\t\t\t\t\t\t-mindepth 2 \\\r\n+\t\t\t\t\t\t-maxdepth 2 \\\r\n+\t\t\t\t\t\t-type f \\\r\n+\t\t\t\t\t\t-name 'config.m4' \\\r\n+\t\t\t\t\t| xargs -n1 dirname | xargs -n1 basename | sort \\\r\n+\t\t\t\t> /usr/src/php-available-exts\r\n+\t\t\tfi\r\n+\t\tfi\r\n+\t\t;;\r\n+\tdelete)\r\n+\t\trm -rf \"$dir\"\r\n+\t\t;;\r\n+\t*)\r\n+\t\tusage\r\n+\t\texit 1\r\n+\t\t;;\r\n+esac\r\ndiff --git a/php_latest/Dockerfile b/php_latest/Dockerfile\r\nindex db603e7..3d46395 100644\r\n--- a/php_latest/Dockerfile\r\n+++ b/php_latest/Dockerfile\r\n@@ -17,6 +17,7 @@ RUN apt-get update && apt-get install -y \\\r\n \t\tlibedit2 \\\r\n \t\tlibsqlite3-0 \\\r\n \t\tlibxml2 \\\r\n+\t\txz-utils \\\r\n \t--no-install-recommends && rm -r /var/lib/apt/lists/*\r\n \r\n ENV PHP_INI_DIR /usr/local/etc/php\r\n@@ -32,6 +33,20 @@ ENV PHP_FILENAME php-7.0.8.tar.xz\r\n ENV PHP_SHA256 0a2142c458b0846f556b16da1c927d74c101aa951bb840549abe5c58584fb394\r\n \r\n RUN set -xe \\\r\n+\t&& cd /usr/src/ \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o php.tar.xz \\\r\n+\t&& echo \"$PHP_SHA256 *php.tar.xz\" | sha256sum -c - \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o php.tar.xz.asc \\\r\n+\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n+\t&& for key in $GPG_KEYS; do \\\r\n+\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n+\tdone \\\r\n+\t&& gpg --batch --verify php.tar.xz.asc php.tar.xz \\\r\n+\t&& rm -r \"$GNUPGHOME\"\r\n+\r\n+COPY docker-php-source /usr/local/bin/\r\n+\r\n+RUN set -xe \\\r\n \t&& buildDeps=\" \\\r\n \t\t$PHP_EXTRA_BUILD_DEPS \\\r\n \t\tlibcurl4-openssl-dev \\\r\n@@ -39,21 +54,9 @@ RUN set -xe \\\r\n \t\tlibsqlite3-dev \\\r\n \t\tlibssl-dev \\\r\n \t\tlibxml2-dev \\\r\n-\t\txz-utils \\\r\n \t\" \\\r\n \t&& apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o \"$PHP_FILENAME\" \\\r\n-\t&& echo \"$PHP_SHA256 *$PHP_FILENAME\" | sha256sum -c - \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o \"$PHP_FILENAME.asc\" \\\r\n-\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n-\t&& for key in $GPG_KEYS; do \\\r\n-\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n-\tdone \\\r\n-\t&& gpg --batch --verify \"$PHP_FILENAME.asc\" \"$PHP_FILENAME\" \\\r\n-\t&& rm -r \"$GNUPGHOME\" \"$PHP_FILENAME.asc\" \\\r\n-\t&& mkdir -p /usr/src/php \\\r\n-\t&& tar -xf \"$PHP_FILENAME\" -C /usr/src/php --strip-components=1 \\\r\n-\t&& rm \"$PHP_FILENAME\" \\\r\n+\t&& docker-php-source extract \\\r\n \t&& cd /usr/src/php \\\r\n \t&& ./configure \\\r\n \t\t--with-config-file-path=\"$PHP_INI_DIR\" \\\r\n@@ -72,7 +75,8 @@ RUN set -xe \\\r\n \t&& make install \\\r\n \t&& { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \\\r\n \t&& make clean \\\r\n-\t&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps\r\n+\t&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps \\\r\n+\t&& docker-php-source delete\r\n \r\n COPY docker-php-ext-* /usr/local/bin/\r\n \r\ndiff --git a/php_latest/docker-php-ext-configure b/php_latest/docker-php-ext-configure\r\nindex dd56be1..ac3e899 100755\r\n--- a/php_latest/docker-php-ext-configure\r\n+++ b/php_latest/docker-php-ext-configure\r\n@@ -2,13 +2,12 @@\r\n set -e\r\n \r\n ext=\"$1\"\r\n-extDir=\"/usr/src/php/ext/$ext\"\r\n-if [ -z \"$ext\" ] || ! [ -d \"$extDir\" ]; then\r\n+if [ -z \"$ext\" ] || ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n \techo >&2 \"usage: $0 ext-name [configure flags]\"\r\n \techo >&2 \"   ie: $0 gd --with-jpeg-dir=/usr/local/something\"\r\n \techo >&2\r\n \techo >&2 'Possible values for ext-name:'\r\n-\techo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n \texit 1\r\n fi\r\n shift\r\n@@ -28,7 +27,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+\r\n set -x\r\n-cd \"$extDir\"\r\n+cd \"/usr/src/php/ext/$ext\"\r\n phpize\r\n ./configure \"$@\"\r\ndiff --git a/php_latest/docker-php-ext-install b/php_latest/docker-php-ext-install\r\nindex 43927b4..f7fc78d 100755\r\n--- a/php_latest/docker-php-ext-install\r\n+++ b/php_latest/docker-php-ext-install\r\n@@ -1,8 +1,6 @@\r\n #!/bin/sh\r\n set -e\r\n \r\n-cd /usr/src/php/ext\r\n-\r\n usage() {\r\n \techo \"usage: $0 [-jN] ext-name [ext-name ...]\"\r\n \techo \"   ie: $0 gd mysqli\"\r\n@@ -12,7 +10,7 @@ usage() {\r\n \techo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'\r\n \techo\r\n \techo 'Possible values for ext-name:'\r\n-\techo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n }\r\n \r\n opts=\"$(getopt -o 'h?j:' --long 'help,jobs:' -- \"$@\" || { usage >&2 && false; })\"\r\n@@ -41,8 +39,8 @@ for ext; do\r\n \tif [ -z \"$ext\" ]; then\r\n \t\tcontinue\r\n \tfi\r\n-\tif [ ! -d \"$ext\" ]; then\r\n-\t\techo >&2 \"error: $(pwd -P)/$ext does not exist\"\r\n+\tif ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n+\t\techo >&2 \"error: /usr/src/php/ext/$ext does not exist\"\r\n \t\techo >&2\r\n \t\tusage >&2\r\n \t\texit 1\r\n@@ -72,6 +70,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+cd /usr/src/php/ext\r\n+\r\n for ext in $exts; do\r\n \t(\r\n \t\tcd \"$ext\"\r\n@@ -90,3 +91,4 @@ done\r\n if [ \"$pm\" = 'apk' ] && [ -n \"$apkDel\" ]; then\r\n \tapk del $apkDel\r\n fi\r\n+docker-php-source delete\r\ndiff --git a/php_latest/docker-php-source b/php_latest/docker-php-source\r\nnew file mode 100755\r\nindex 0000000..9020385\r\n--- /dev/null\r\n+++ b/php_latest/docker-php-source\r\n@@ -0,0 +1,44 @@\r\n+#!/bin/sh\r\n+set -e\r\n+dir=/usr/src/php\r\n+\r\n+usage() {\r\n+\techo \"usage: $0 COMMAND\"\r\n+\techo\r\n+\techo \"Manage php source tarball lifecycle.\"\r\n+\techo\r\n+\techo \"Commands:\"\r\n+\techo \"   extract  extract php source tarball into directory $dir if not already done.\"\r\n+\techo \"   delete   delete extracted php source located into $dir if not already done.\"\r\n+\techo\r\n+}\r\n+\r\n+case \"$1\" in\r\n+\textract)\r\n+\t\tif [ -e \"$dir\" -a ! -d \"$dir\" ] ; then\r\n+\t\t\techo >&2 \"$dir exists and is not a directory\"\r\n+\t\t\texit 1\r\n+\t\tfi\r\n+\t\tif [ ! -d \"$dir\" ]; then\r\n+\t\t\tmkdir -p \"$dir\"\r\n+\t\t\ttar -Jxf /usr/src/php.tar.xz -C \"$dir\" --strip-components=1\r\n+\r\n+\t\t\tif [ ! -f /usr/src/php-available-exts ]; then\r\n+\t\t\t\tfind \"$dir/ext\" \\\r\n+\t\t\t\t\t\t-mindepth 2 \\\r\n+\t\t\t\t\t\t-maxdepth 2 \\\r\n+\t\t\t\t\t\t-type f \\\r\n+\t\t\t\t\t\t-name 'config.m4' \\\r\n+\t\t\t\t\t| xargs -n1 dirname | xargs -n1 basename | sort \\\r\n+\t\t\t\t> /usr/src/php-available-exts\r\n+\t\t\tfi\r\n+\t\tfi\r\n+\t\t;;\r\n+\tdelete)\r\n+\t\trm -rf \"$dir\"\r\n+\t\t;;\r\n+\t*)\r\n+\t\tusage\r\n+\t\texit 1\r\n+\t\t;;\r\n+esac\r\ndiff --git a/php_zts-alpine/Dockerfile b/php_zts-alpine/Dockerfile\r\nindex 77b7376..13b0279 100644\r\n--- a/php_zts-alpine/Dockerfile\r\n+++ b/php_zts-alpine/Dockerfile\r\n@@ -12,7 +12,9 @@ ENV PHPIZE_DEPS \\\r\n \t\tre2c\r\n RUN apk add --no-cache --virtual .persistent-deps \\\r\n \t\tca-certificates \\\r\n-\t\tcurl\r\n+\t\tcurl \\\r\n+\t\ttar \\\r\n+\t\txz\r\n \r\n # ensure www-data user exists\r\n RUN set -x \\\r\n@@ -37,27 +39,32 @@ ENV PHP_FILENAME php-7.0.8.tar.xz\r\n ENV PHP_SHA256 0a2142c458b0846f556b16da1c927d74c101aa951bb840549abe5c58584fb394\r\n \r\n RUN set -xe \\\r\n+\t&& apk add --no-cache --virtual .fetch-deps \\\r\n+\t\tgnupg \\\r\n+\t&& mkdir -p /usr/src \\\r\n+\t&& cd /usr/src/ \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o php.tar.xz \\\r\n+\t&& echo \"$PHP_SHA256 *php.tar.xz\" | sha256sum -c - \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o php.tar.xz.asc \\\r\n+\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n+\t&& for key in $GPG_KEYS; do \\\r\n+\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n+\tdone \\\r\n+\t&& gpg --batch --verify php.tar.xz.asc php.tar.xz \\\r\n+\t&& rm -r \"$GNUPGHOME\" \\\r\n+\t&& apk del .fetch-deps\r\n+\r\n+COPY docker-php-source /usr/local/bin/\r\n+\r\n+RUN set -xe \\\r\n \t&& apk add --no-cache --virtual .build-deps \\\r\n \t\t$PHPIZE_DEPS \\\r\n \t\tcurl-dev \\\r\n-\t\tgnupg \\\r\n \t\tlibedit-dev \\\r\n \t\tlibxml2-dev \\\r\n \t\topenssl-dev \\\r\n \t\tsqlite-dev \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o \"$PHP_FILENAME\" \\\r\n-\t&& echo \"$PHP_SHA256 *$PHP_FILENAME\" | sha256sum -c - \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o \"$PHP_FILENAME.asc\" \\\r\n-\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n-\t&& for key in $GPG_KEYS; do \\\r\n-\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n-\tdone \\\r\n-\t&& gpg --batch --verify \"$PHP_FILENAME.asc\" \"$PHP_FILENAME\" \\\r\n-\t&& rm -r \"$GNUPGHOME\" \"$PHP_FILENAME.asc\" \\\r\n-\t&& mkdir -p /usr/src \\\r\n-\t&& tar -Jxf \"$PHP_FILENAME\" -C /usr/src \\\r\n-\t&& mv \"/usr/src/php-$PHP_VERSION\" /usr/src/php \\\r\n-\t&& rm \"$PHP_FILENAME\" \\\r\n+\t&& docker-php-source extract \\\r\n \t&& cd /usr/src/php \\\r\n \t&& ./configure \\\r\n \t\t--with-config-file-path=\"$PHP_INI_DIR\" \\\r\n@@ -84,7 +91,8 @@ RUN set -xe \\\r\n \t\t\t| sort -u \\\r\n \t)\" \\\r\n \t&& apk add --no-cache --virtual .php-rundeps $runDeps \\\r\n-\t&& apk del .build-deps\r\n+\t&& apk del .build-deps \\\r\n+\t&& docker-php-source delete\r\n \r\n COPY docker-php-ext-* /usr/local/bin/\r\n \r\ndiff --git a/php_zts-alpine/docker-php-ext-configure b/php_zts-alpine/docker-php-ext-configure\r\nindex dd56be1..ac3e899 100755\r\n--- a/php_zts-alpine/docker-php-ext-configure\r\n+++ b/php_zts-alpine/docker-php-ext-configure\r\n@@ -2,13 +2,12 @@\r\n set -e\r\n \r\n ext=\"$1\"\r\n-extDir=\"/usr/src/php/ext/$ext\"\r\n-if [ -z \"$ext\" ] || ! [ -d \"$extDir\" ]; then\r\n+if [ -z \"$ext\" ] || ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n \techo >&2 \"usage: $0 ext-name [configure flags]\"\r\n \techo >&2 \"   ie: $0 gd --with-jpeg-dir=/usr/local/something\"\r\n \techo >&2\r\n \techo >&2 'Possible values for ext-name:'\r\n-\techo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n \texit 1\r\n fi\r\n shift\r\n@@ -28,7 +27,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+\r\n set -x\r\n-cd \"$extDir\"\r\n+cd \"/usr/src/php/ext/$ext\"\r\n phpize\r\n ./configure \"$@\"\r\ndiff --git a/php_zts-alpine/docker-php-ext-install b/php_zts-alpine/docker-php-ext-install\r\nindex 43927b4..f7fc78d 100755\r\n--- a/php_zts-alpine/docker-php-ext-install\r\n+++ b/php_zts-alpine/docker-php-ext-install\r\n@@ -1,8 +1,6 @@\r\n #!/bin/sh\r\n set -e\r\n \r\n-cd /usr/src/php/ext\r\n-\r\n usage() {\r\n \techo \"usage: $0 [-jN] ext-name [ext-name ...]\"\r\n \techo \"   ie: $0 gd mysqli\"\r\n@@ -12,7 +10,7 @@ usage() {\r\n \techo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'\r\n \techo\r\n \techo 'Possible values for ext-name:'\r\n-\techo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n }\r\n \r\n opts=\"$(getopt -o 'h?j:' --long 'help,jobs:' -- \"$@\" || { usage >&2 && false; })\"\r\n@@ -41,8 +39,8 @@ for ext; do\r\n \tif [ -z \"$ext\" ]; then\r\n \t\tcontinue\r\n \tfi\r\n-\tif [ ! -d \"$ext\" ]; then\r\n-\t\techo >&2 \"error: $(pwd -P)/$ext does not exist\"\r\n+\tif ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n+\t\techo >&2 \"error: /usr/src/php/ext/$ext does not exist\"\r\n \t\techo >&2\r\n \t\tusage >&2\r\n \t\texit 1\r\n@@ -72,6 +70,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+cd /usr/src/php/ext\r\n+\r\n for ext in $exts; do\r\n \t(\r\n \t\tcd \"$ext\"\r\n@@ -90,3 +91,4 @@ done\r\n if [ \"$pm\" = 'apk' ] && [ -n \"$apkDel\" ]; then\r\n \tapk del $apkDel\r\n fi\r\n+docker-php-source delete\r\ndiff --git a/php_zts-alpine/docker-php-source b/php_zts-alpine/docker-php-source\r\nnew file mode 100755\r\nindex 0000000..9020385\r\n--- /dev/null\r\n+++ b/php_zts-alpine/docker-php-source\r\n@@ -0,0 +1,44 @@\r\n+#!/bin/sh\r\n+set -e\r\n+dir=/usr/src/php\r\n+\r\n+usage() {\r\n+\techo \"usage: $0 COMMAND\"\r\n+\techo\r\n+\techo \"Manage php source tarball lifecycle.\"\r\n+\techo\r\n+\techo \"Commands:\"\r\n+\techo \"   extract  extract php source tarball into directory $dir if not already done.\"\r\n+\techo \"   delete   delete extracted php source located into $dir if not already done.\"\r\n+\techo\r\n+}\r\n+\r\n+case \"$1\" in\r\n+\textract)\r\n+\t\tif [ -e \"$dir\" -a ! -d \"$dir\" ] ; then\r\n+\t\t\techo >&2 \"$dir exists and is not a directory\"\r\n+\t\t\texit 1\r\n+\t\tfi\r\n+\t\tif [ ! -d \"$dir\" ]; then\r\n+\t\t\tmkdir -p \"$dir\"\r\n+\t\t\ttar -Jxf /usr/src/php.tar.xz -C \"$dir\" --strip-components=1\r\n+\r\n+\t\t\tif [ ! -f /usr/src/php-available-exts ]; then\r\n+\t\t\t\tfind \"$dir/ext\" \\\r\n+\t\t\t\t\t\t-mindepth 2 \\\r\n+\t\t\t\t\t\t-maxdepth 2 \\\r\n+\t\t\t\t\t\t-type f \\\r\n+\t\t\t\t\t\t-name 'config.m4' \\\r\n+\t\t\t\t\t| xargs -n1 dirname | xargs -n1 basename | sort \\\r\n+\t\t\t\t> /usr/src/php-available-exts\r\n+\t\t\tfi\r\n+\t\tfi\r\n+\t\t;;\r\n+\tdelete)\r\n+\t\trm -rf \"$dir\"\r\n+\t\t;;\r\n+\t*)\r\n+\t\tusage\r\n+\t\texit 1\r\n+\t\t;;\r\n+esac\r\ndiff --git a/php_zts/Dockerfile b/php_zts/Dockerfile\r\nindex 0d276d3..5d43061 100644\r\n--- a/php_zts/Dockerfile\r\n+++ b/php_zts/Dockerfile\r\n@@ -17,6 +17,7 @@ RUN apt-get update && apt-get install -y \\\r\n \t\tlibedit2 \\\r\n \t\tlibsqlite3-0 \\\r\n \t\tlibxml2 \\\r\n+\t\txz-utils \\\r\n \t--no-install-recommends && rm -r /var/lib/apt/lists/*\r\n \r\n ENV PHP_INI_DIR /usr/local/etc/php\r\n@@ -33,6 +34,20 @@ ENV PHP_FILENAME php-7.0.8.tar.xz\r\n ENV PHP_SHA256 0a2142c458b0846f556b16da1c927d74c101aa951bb840549abe5c58584fb394\r\n \r\n RUN set -xe \\\r\n+\t&& cd /usr/src/ \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o php.tar.xz \\\r\n+\t&& echo \"$PHP_SHA256 *php.tar.xz\" | sha256sum -c - \\\r\n+\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o php.tar.xz.asc \\\r\n+\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n+\t&& for key in $GPG_KEYS; do \\\r\n+\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n+\tdone \\\r\n+\t&& gpg --batch --verify php.tar.xz.asc php.tar.xz \\\r\n+\t&& rm -r \"$GNUPGHOME\"\r\n+\r\n+COPY docker-php-source /usr/local/bin/\r\n+\r\n+RUN set -xe \\\r\n \t&& buildDeps=\" \\\r\n \t\t$PHP_EXTRA_BUILD_DEPS \\\r\n \t\tlibcurl4-openssl-dev \\\r\n@@ -40,21 +55,9 @@ RUN set -xe \\\r\n \t\tlibsqlite3-dev \\\r\n \t\tlibssl-dev \\\r\n \t\tlibxml2-dev \\\r\n-\t\txz-utils \\\r\n \t\" \\\r\n \t&& apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME/from/this/mirror\" -o \"$PHP_FILENAME\" \\\r\n-\t&& echo \"$PHP_SHA256 *$PHP_FILENAME\" | sha256sum -c - \\\r\n-\t&& curl -fSL \"http://php.net/get/$PHP_FILENAME.asc/from/this/mirror\" -o \"$PHP_FILENAME.asc\" \\\r\n-\t&& export GNUPGHOME=\"$(mktemp -d)\" \\\r\n-\t&& for key in $GPG_KEYS; do \\\r\n-\t\tgpg --keyserver ha.pool.sks-keyservers.net --recv-keys \"$key\"; \\\r\n-\tdone \\\r\n-\t&& gpg --batch --verify \"$PHP_FILENAME.asc\" \"$PHP_FILENAME\" \\\r\n-\t&& rm -r \"$GNUPGHOME\" \"$PHP_FILENAME.asc\" \\\r\n-\t&& mkdir -p /usr/src/php \\\r\n-\t&& tar -xf \"$PHP_FILENAME\" -C /usr/src/php --strip-components=1 \\\r\n-\t&& rm \"$PHP_FILENAME\" \\\r\n+\t&& docker-php-source extract \\\r\n \t&& cd /usr/src/php \\\r\n \t&& ./configure \\\r\n \t\t--with-config-file-path=\"$PHP_INI_DIR\" \\\r\n@@ -73,7 +76,8 @@ RUN set -xe \\\r\n \t&& make install \\\r\n \t&& { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \\\r\n \t&& make clean \\\r\n-\t&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps\r\n+\t&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps \\\r\n+\t&& docker-php-source delete\r\n \r\n COPY docker-php-ext-* /usr/local/bin/\r\n \r\ndiff --git a/php_zts/docker-php-ext-configure b/php_zts/docker-php-ext-configure\r\nindex dd56be1..ac3e899 100755\r\n--- a/php_zts/docker-php-ext-configure\r\n+++ b/php_zts/docker-php-ext-configure\r\n@@ -2,13 +2,12 @@\r\n set -e\r\n \r\n ext=\"$1\"\r\n-extDir=\"/usr/src/php/ext/$ext\"\r\n-if [ -z \"$ext\" ] || ! [ -d \"$extDir\" ]; then\r\n+if [ -z \"$ext\" ] || ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n \techo >&2 \"usage: $0 ext-name [configure flags]\"\r\n \techo >&2 \"   ie: $0 gd --with-jpeg-dir=/usr/local/something\"\r\n \techo >&2\r\n \techo >&2 'Possible values for ext-name:'\r\n-\techo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n \texit 1\r\n fi\r\n shift\r\n@@ -28,7 +27,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+\r\n set -x\r\n-cd \"$extDir\"\r\n+cd \"/usr/src/php/ext/$ext\"\r\n phpize\r\n ./configure \"$@\"\r\ndiff --git a/php_zts/docker-php-ext-install b/php_zts/docker-php-ext-install\r\nindex 43927b4..f7fc78d 100755\r\n--- a/php_zts/docker-php-ext-install\r\n+++ b/php_zts/docker-php-ext-install\r\n@@ -1,8 +1,6 @@\r\n #!/bin/sh\r\n set -e\r\n \r\n-cd /usr/src/php/ext\r\n-\r\n usage() {\r\n \techo \"usage: $0 [-jN] ext-name [ext-name ...]\"\r\n \techo \"   ie: $0 gd mysqli\"\r\n@@ -12,7 +10,7 @@ usage() {\r\n \techo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'\r\n \techo\r\n \techo 'Possible values for ext-name:'\r\n-\techo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)\r\n+\techo $(cat /usr/src/php-available-exts)\r\n }\r\n \r\n opts=\"$(getopt -o 'h?j:' --long 'help,jobs:' -- \"$@\" || { usage >&2 && false; })\"\r\n@@ -41,8 +39,8 @@ for ext; do\r\n \tif [ -z \"$ext\" ]; then\r\n \t\tcontinue\r\n \tfi\r\n-\tif [ ! -d \"$ext\" ]; then\r\n-\t\techo >&2 \"error: $(pwd -P)/$ext does not exist\"\r\n+\tif ! grep -qE \"^$ext$\" /usr/src/php-available-exts; then\r\n+\t\techo >&2 \"error: /usr/src/php/ext/$ext does not exist\"\r\n \t\techo >&2\r\n \t\tusage >&2\r\n \t\texit 1\r\n@@ -72,6 +70,9 @@ if [ \"$pm\" = 'apk' ]; then\r\n \tfi\r\n fi\r\n \r\n+docker-php-source extract\r\n+cd /usr/src/php/ext\r\n+\r\n for ext in $exts; do\r\n \t(\r\n \t\tcd \"$ext\"\r\n@@ -90,3 +91,4 @@ done\r\n if [ \"$pm\" = 'apk' ] && [ -n \"$apkDel\" ]; then\r\n \tapk del $apkDel\r\n fi\r\n+docker-php-source delete\r\ndiff --git a/php_zts/docker-php-source b/php_zts/docker-php-source\r\nnew file mode 100755\r\nindex 0000000..9020385\r\n--- /dev/null\r\n+++ b/php_zts/docker-php-source\r\n@@ -0,0 +1,44 @@\r\n+#!/bin/sh\r\n+set -e\r\n+dir=/usr/src/php\r\n+\r\n+usage() {\r\n+\techo \"usage: $0 COMMAND\"\r\n+\techo\r\n+\techo \"Manage php source tarball lifecycle.\"\r\n+\techo\r\n+\techo \"Commands:\"\r\n+\techo \"   extract  extract php source tarball into directory $dir if not already done.\"\r\n+\techo \"   delete   delete extracted php source located into $dir if not already done.\"\r\n+\techo\r\n+}\r\n+\r\n+case \"$1\" in\r\n+\textract)\r\n+\t\tif [ -e \"$dir\" -a ! -d \"$dir\" ] ; then\r\n+\t\t\techo >&2 \"$dir exists and is not a directory\"\r\n+\t\t\texit 1\r\n+\t\tfi\r\n+\t\tif [ ! -d \"$dir\" ]; then\r\n+\t\t\tmkdir -p \"$dir\"\r\n+\t\t\ttar -Jxf /usr/src/php.tar.xz -C \"$dir\" --strip-components=1\r\n+\r\n+\t\t\tif [ ! -f /usr/src/php-available-exts ]; then\r\n+\t\t\t\tfind \"$dir/ext\" \\\r\n+\t\t\t\t\t\t-mindepth 2 \\\r\n+\t\t\t\t\t\t-maxdepth 2 \\\r\n+\t\t\t\t\t\t-type f \\\r\n+\t\t\t\t\t\t-name 'config.m4' \\\r\n+\t\t\t\t\t| xargs -n1 dirname | xargs -n1 basename | sort \\\r\n+\t\t\t\t> /usr/src/php-available-exts\r\n+\t\t\tfi\r\n+\t\tfi\r\n+\t\t;;\r\n+\tdelete)\r\n+\t\trm -rf \"$dir\"\r\n+\t\t;;\r\n+\t*)\r\n+\t\tusage\r\n+\t\texit 1\r\n+\t\t;;\r\n+esac\r\ndiff --git a/tomcat_8.5-alpine/Dockerfile b/tomcat_8.5-alpine/Dockerfile\r\nindex f92a095..fcd3b4e 100644\r\n--- a/tomcat_8.5-alpine/Dockerfile\r\n+++ b/tomcat_8.5-alpine/Dockerfile\r\n@@ -32,7 +32,7 @@ RUN set -ex \\\r\n \tdone\r\n \r\n ENV TOMCAT_MAJOR 8\r\n-ENV TOMCAT_VERSION 8.5.3\r\n+ENV TOMCAT_VERSION 8.5.4\r\n ENV TOMCAT_TGZ_URL https://www.apache.org/dist/tomcat/tomcat-$TOMCAT_MAJOR/v$TOMCAT_VERSION/bin/apache-tomcat-$TOMCAT_VERSION.tar.gz\r\n \r\n RUN set -x \\\r\ndiff --git a/tomcat_8.5/Dockerfile b/tomcat_8.5/Dockerfile\r\nindex 799d643..e77d312 100644\r\n--- a/tomcat_8.5/Dockerfile\r\n+++ b/tomcat_8.5/Dockerfile\r\n@@ -53,7 +53,7 @@ RUN set -ex \\\r\n \tdone\r\n \r\n ENV TOMCAT_MAJOR 8\r\n-ENV TOMCAT_VERSION 8.5.3\r\n+ENV TOMCAT_VERSION 8.5.4\r\n ENV TOMCAT_TGZ_URL https://www.apache.org/dist/tomcat/tomcat-$TOMCAT_MAJOR/v$TOMCAT_VERSION/bin/apache-tomcat-$TOMCAT_VERSION.tar.gz\r\n \r\n RUN set -x \\\r\ndiff --git a/tomcat_9-alpine/Dockerfile b/tomcat_9-alpine/Dockerfile\r\nindex 16f6c70..29ddeea 100644\r\n--- a/tomcat_9-alpine/Dockerfile\r\n+++ b/tomcat_9-alpine/Dockerfile\r\n@@ -32,7 +32,7 @@ RUN set -ex \\\r\n \tdone\r\n \r\n ENV TOMCAT_MAJOR 9\r\n-ENV TOMCAT_VERSION 9.0.0.M8\r\n+ENV TOMCAT_VERSION 9.0.0.M9\r\n ENV TOMCAT_TGZ_URL https://www.apache.org/dist/tomcat/tomcat-$TOMCAT_MAJOR/v$TOMCAT_VERSION/bin/apache-tomcat-$TOMCAT_VERSION.tar.gz\r\n \r\n RUN set -x \\\r\ndiff --git a/tomcat_9/Dockerfile b/tomcat_9/Dockerfile\r\nindex 1b8e26c..72d91fe 100644\r\n--- a/tomcat_9/Dockerfile\r\n+++ b/tomcat_9/Dockerfile\r\n@@ -53,7 +53,7 @@ RUN set -ex \\\r\n \tdone\r\n \r\n ENV TOMCAT_MAJOR 9\r\n-ENV TOMCAT_VERSION 9.0.0.M8\r\n+ENV TOMCAT_VERSION 9.0.0.M9\r\n ENV TOMCAT_TGZ_URL https://www.apache.org/dist/tomcat/tomcat-$TOMCAT_MAJOR/v$TOMCAT_VERSION/bin/apache-tomcat-$TOMCAT_VERSION.tar.gz\r\n \r\n RUN set -x \\\r\n```"}}
{"actor":{"display_login":"tianon"}}