diff --git a/5.4/Dockerfile b/5.4/Dockerfile
index 65c3b6aa..1625e3f3 100644
--- a/5.4/Dockerfile
+++ b/5.4/Dockerfile
@@ -3,6 +3,12 @@ FROM debian:jessie
# persistent / runtime deps
RUN apt-get update && apt-get install -y ca-certificates curl libxml2 --no-install-recommends && rm -r /var/lib/apt/lists/*
+# phpize deps
+RUN apt-get update && apt-get install -y autoconf gcc pkg-config --no-install-recommends && rm -r /var/lib/apt/lists/*
+
+ENV PHP_INI_DIR /usr/local/etc/php
+RUN mkdir -p $PHP_INI_DIR/conf.d
+
####
####
@@ -10,18 +16,15 @@ RUN gpg --keyserver pgp.mit.edu --recv-keys F38252826ACD957EF380D39F2F7956BC5DA0
ENV PHP_VERSION 5.4.34
+# --enable-mysqlnd is included below because it's harder to compile after the fact the extensions are (since it's a plugin for several extensions, not an extension in itself)
RUN buildDeps=" \
$PHP_EXTRA_BUILD_DEPS \
- build-essential \
bzip2 \
file \
libcurl4-openssl-dev \
- libpng12-dev \
libreadline6-dev \
libssl-dev \
libxml2-dev \
- m4 \
- pkg-config \
"; \
set -x \
&& apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \
@@ -32,22 +35,23 @@ RUN buildDeps=" \
&& tar -xf php.tar.bz2 -C /usr/src/php --strip-components=1 \
&& rm php.tar.bz2* \
&& cd /usr/src/php \
- && ./configure --disable-cgi \
+ && ./configure \
+ --with-config-file-path="$PHP_INI_DIR" \
+ --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \
$PHP_EXTRA_CONFIGURE_ARGS \
- --enable-soap \
+ --disable-cgi \
+ --enable-mysqlnd \
--with-curl \
- --with-gd \
- --with-mysql \
- --with-mysqli \
--with-openssl \
- --with-pdo-mysql \
--with-readline \
--with-zlib \
&& make -j"$(nproc)" \
&& make install \
&& { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \
&& apt-get purge -y --auto-remove $buildDeps \
- && rm -r /usr/src/php
+ && make clean
+
+COPY docker-php-ext-* /usr/local/bin/
####
CMD ["php", "-a"]
diff --git a/5.4/apache/Dockerfile b/5.4/apache/Dockerfile
index 44c22990..3b88c227 100644
--- a/5.4/apache/Dockerfile
+++ b/5.4/apache/Dockerfile
@@ -3,6 +3,12 @@ FROM debian:jessie
# persistent / runtime deps
RUN apt-get update && apt-get install -y ca-certificates curl libxml2 --no-install-recommends && rm -r /var/lib/apt/lists/*
+# phpize deps
+RUN apt-get update && apt-get install -y autoconf gcc pkg-config --no-install-recommends && rm -r /var/lib/apt/lists/*
+
+ENV PHP_INI_DIR /usr/local/etc/php
+RUN mkdir -p $PHP_INI_DIR/conf.d
+
####
RUN apt-get update && apt-get install -y apache2-bin apache2.2-common --no-install-recommends && rm -rf /var/lib/apt/lists/*
@@ -23,18 +29,15 @@ RUN gpg --keyserver pgp.mit.edu --recv-keys F38252826ACD957EF380D39F2F7956BC5DA0
ENV PHP_VERSION 5.4.34
+# --enable-mysqlnd is included below because it's harder to compile after the fact the extensions are (since it's a plugin for several extensions, not an extension in itself)
RUN buildDeps=" \
$PHP_EXTRA_BUILD_DEPS \
- build-essential \
bzip2 \
file \
libcurl4-openssl-dev \
- libpng12-dev \
libreadline6-dev \
libssl-dev \
libxml2-dev \
- m4 \
- pkg-config \
"; \
set -x \
&& apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \
@@ -45,22 +48,23 @@ RUN buildDeps=" \
&& tar -xf php.tar.bz2 -C /usr/src/php --strip-components=1 \
&& rm php.tar.bz2* \
&& cd /usr/src/php \
- && ./configure --disable-cgi \
+ && ./configure \
+ --with-config-file-path="$PHP_INI_DIR" \
+ --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \
$PHP_EXTRA_CONFIGURE_ARGS \
- --enable-soap \
+ --disable-cgi \
+ --enable-mysqlnd \
--with-curl \
- --with-gd \
- --with-mysql \
- --with-mysqli \
--with-openssl \
- --with-pdo-mysql \
--with-readline \
--with-zlib \
&& make -j"$(nproc)" \
&& make install \
&& { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \
&& apt-get purge -y --auto-remove $buildDeps \
- && rm -r /usr/src/php
+ && make clean
+
+COPY docker-php-ext-* /usr/local/bin/
####
WORKDIR /var/www/html
diff --git a/5.4/apache/docker-php-ext-configure b/5.4/apache/docker-php-ext-configure
new file mode 100755
index 00000000..3d21b5bb
--- /dev/null
+++ b/5.4/apache/docker-php-ext-configure
@@ -0,0 +1,19 @@
+#!/bin/bash
+set -e
+
+ext="$1"
+extDir="/usr/src/php/ext/$ext"
+if [ -z "$ext" -o ! -d "$extDir" ]; then
+ echo >&2 "usage: $0 ext-name [configure flags]"
+ echo >&2 " ie: $0 gd --with-jpeg-dir=/usr/local/something"
+ echo >&2
+ echo >&2 'Possible values for ext-name:'
+ echo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)
+ exit 1
+fi
+shift
+
+set -x
+cd "$extDir"
+phpize
+./configure "$@"
diff --git a/5.4/apache/docker-php-ext-install b/5.4/apache/docker-php-ext-install
new file mode 100755
index 00000000..abca7fff
--- /dev/null
+++ b/5.4/apache/docker-php-ext-install
@@ -0,0 +1,55 @@
+#!/bin/bash
+set -e
+
+cd /usr/src/php/ext
+
+usage() {
+ echo "usage: $0 ext-name [ext-name ...]"
+ echo " ie: $0 gd mysqli"
+ echo " $0 pdo pdo_mysql"
+ echo
+ echo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'
+ echo
+ echo 'Possible values for ext-name:'
+ echo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)
+}
+
+exts=()
+while [ $# -gt 0 ]; do
+ ext="$1"
+ shift
+ if [ -z "$ext" ]; then
+ continue
+ fi
+ if [ ! -d "$ext" ]; then
+ echo >&2 "error: $(pwd -P)/$ext does not exist"
+ echo >&2
+ usage >&2
+ exit 1
+ fi
+ exts+=( "$ext" )
+done
+
+if [ "${#exts[@]}" -eq 0 ]; then
+ usage >&2
+ exit 1
+fi
+
+for ext in "${exts[@]}"; do
+ (
+ cd "$ext"
+ [ -e Makefile ] || docker-php-ext-configure "$ext"
+ make
+ make install
+ ini="/usr/local/etc/php/conf.d/docker-php-ext-$ext.ini"
+ for module in modules/*.so; do
+ if [ -f "$module" ]; then
+ line="extension=$(basename "$module")"
+ if ! grep -q "$line" "$ini"; then
+ echo "$line" >> "/usr/local/etc/php/conf.d/ext-$ext.ini"
+ fi
+ fi
+ done
+ make clean
+ )
+done
diff --git a/5.4/docker-php-ext-configure b/5.4/docker-php-ext-configure
new file mode 100755
index 00000000..3d21b5bb
--- /dev/null
+++ b/5.4/docker-php-ext-configure
@@ -0,0 +1,19 @@
+#!/bin/bash
+set -e
+
+ext="$1"
+extDir="/usr/src/php/ext/$ext"
+if [ -z "$ext" -o ! -d "$extDir" ]; then
+ echo >&2 "usage: $0 ext-name [configure flags]"
+ echo >&2 " ie: $0 gd --with-jpeg-dir=/usr/local/something"
+ echo >&2
+ echo >&2 'Possible values for ext-name:'
+ echo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)
+ exit 1
+fi
+shift
+
+set -x
+cd "$extDir"
+phpize
+./configure "$@"
diff --git a/5.4/docker-php-ext-install b/5.4/docker-php-ext-install
new file mode 100755
index 00000000..abca7fff
--- /dev/null
+++ b/5.4/docker-php-ext-install
@@ -0,0 +1,55 @@
+#!/bin/bash
+set -e
+
+cd /usr/src/php/ext
+
+usage() {
+ echo "usage: $0 ext-name [ext-name ...]"
+ echo " ie: $0 gd mysqli"
+ echo " $0 pdo pdo_mysql"
+ echo
+ echo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'
+ echo
+ echo 'Possible values for ext-name:'
+ echo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)
+}
+
+exts=()
+while [ $# -gt 0 ]; do
+ ext="$1"
+ shift
+ if [ -z "$ext" ]; then
+ continue
+ fi
+ if [ ! -d "$ext" ]; then
+ echo >&2 "error: $(pwd -P)/$ext does not exist"
+ echo >&2
+ usage >&2
+ exit 1
+ fi
+ exts+=( "$ext" )
+done
+
+if [ "${#exts[@]}" -eq 0 ]; then
+ usage >&2
+ exit 1
+fi
+
+for ext in "${exts[@]}"; do
+ (
+ cd "$ext"
+ [ -e Makefile ] || docker-php-ext-configure "$ext"
+ make
+ make install
+ ini="/usr/local/etc/php/conf.d/docker-php-ext-$ext.ini"
+ for module in modules/*.so; do
+ if [ -f "$module" ]; then
+ line="extension=$(basename "$module")"
+ if ! grep -q "$line" "$ini"; then
+ echo "$line" >> "/usr/local/etc/php/conf.d/ext-$ext.ini"
+ fi
+ fi
+ done
+ make clean
+ )
+done
diff --git a/5.5/Dockerfile b/5.5/Dockerfile
index eb54eb27..43888454 100644
--- a/5.5/Dockerfile
+++ b/5.5/Dockerfile
@@ -3,6 +3,12 @@ FROM debian:jessie
# persistent / runtime deps
RUN apt-get update && apt-get install -y ca-certificates curl libxml2 --no-install-recommends && rm -r /var/lib/apt/lists/*
+# phpize deps
+RUN apt-get update && apt-get install -y autoconf gcc pkg-config --no-install-recommends && rm -r /var/lib/apt/lists/*
+
+ENV PHP_INI_DIR /usr/local/etc/php
+RUN mkdir -p $PHP_INI_DIR/conf.d
+
####
####
@@ -10,18 +16,15 @@ RUN gpg --keyserver pgp.mit.edu --recv-keys 0BD78B5F97500D450838F95DFE857D9A90D9
ENV PHP_VERSION 5.5.18
+# --enable-mysqlnd is included below because it's harder to compile after the fact the extensions are (since it's a plugin for several extensions, not an extension in itself)
RUN buildDeps=" \
$PHP_EXTRA_BUILD_DEPS \
- build-essential \
bzip2 \
file \
libcurl4-openssl-dev \
- libpng12-dev \
libreadline6-dev \
libssl-dev \
libxml2-dev \
- m4 \
- pkg-config \
"; \
set -x \
&& apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \
@@ -32,22 +35,23 @@ RUN buildDeps=" \
&& tar -xf php.tar.bz2 -C /usr/src/php --strip-components=1 \
&& rm php.tar.bz2* \
&& cd /usr/src/php \
- && ./configure --disable-cgi \
+ && ./configure \
+ --with-config-file-path="$PHP_INI_DIR" \
+ --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \
$PHP_EXTRA_CONFIGURE_ARGS \
- --enable-soap \
+ --disable-cgi \
+ --enable-mysqlnd \
--with-curl \
- --with-gd \
- --with-mysql \
- --with-mysqli \
--with-openssl \
- --with-pdo-mysql \
--with-readline \
--with-zlib \
&& make -j"$(nproc)" \
&& make install \
&& { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \
&& apt-get purge -y --auto-remove $buildDeps \
- && rm -r /usr/src/php
+ && make clean
+
+COPY docker-php-ext-* /usr/local/bin/
####
CMD ["php", "-a"]
diff --git a/5.5/apache/Dockerfile b/5.5/apache/Dockerfile
index 32d70fc1..1aa4e8f4 100644
--- a/5.5/apache/Dockerfile
+++ b/5.5/apache/Dockerfile
@@ -3,6 +3,12 @@ FROM debian:jessie
# persistent / runtime deps
RUN apt-get update && apt-get install -y ca-certificates curl libxml2 --no-install-recommends && rm -r /var/lib/apt/lists/*
+# phpize deps
+RUN apt-get update && apt-get install -y autoconf gcc pkg-config --no-install-recommends && rm -r /var/lib/apt/lists/*
+
+ENV PHP_INI_DIR /usr/local/etc/php
+RUN mkdir -p $PHP_INI_DIR/conf.d
+
####
RUN apt-get update && apt-get install -y apache2-bin apache2.2-common --no-install-recommends && rm -rf /var/lib/apt/lists/*
@@ -23,18 +29,15 @@ RUN gpg --keyserver pgp.mit.edu --recv-keys 0BD78B5F97500D450838F95DFE857D9A90D9
ENV PHP_VERSION 5.5.18
+# --enable-mysqlnd is included below because it's harder to compile after the fact the extensions are (since it's a plugin for several extensions, not an extension in itself)
RUN buildDeps=" \
$PHP_EXTRA_BUILD_DEPS \
- build-essential \
bzip2 \
file \
libcurl4-openssl-dev \
- libpng12-dev \
libreadline6-dev \
libssl-dev \
libxml2-dev \
- m4 \
- pkg-config \
"; \
set -x \
&& apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \
@@ -45,22 +48,23 @@ RUN buildDeps=" \
&& tar -xf php.tar.bz2 -C /usr/src/php --strip-components=1 \
&& rm php.tar.bz2* \
&& cd /usr/src/php \
- && ./configure --disable-cgi \
+ && ./configure \
+ --with-config-file-path="$PHP_INI_DIR" \
+ --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \
$PHP_EXTRA_CONFIGURE_ARGS \
- --enable-soap \
+ --disable-cgi \
+ --enable-mysqlnd \
--with-curl \
- --with-gd \
- --with-mysql \
- --with-mysqli \
--with-openssl \
- --with-pdo-mysql \
--with-readline \
--with-zlib \
&& make -j"$(nproc)" \
&& make install \
&& { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \
&& apt-get purge -y --auto-remove $buildDeps \
- && rm -r /usr/src/php
+ && make clean
+
+COPY docker-php-ext-* /usr/local/bin/
####
WORKDIR /var/www/html
diff --git a/5.5/apache/docker-php-ext-configure b/5.5/apache/docker-php-ext-configure
new file mode 100755
index 00000000..3d21b5bb
--- /dev/null
+++ b/5.5/apache/docker-php-ext-configure
@@ -0,0 +1,19 @@
+#!/bin/bash
+set -e
+
+ext="$1"
+extDir="/usr/src/php/ext/$ext"
+if [ -z "$ext" -o ! -d "$extDir" ]; then
+ echo >&2 "usage: $0 ext-name [configure flags]"
+ echo >&2 " ie: $0 gd --with-jpeg-dir=/usr/local/something"
+ echo >&2
+ echo >&2 'Possible values for ext-name:'
+ echo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)
+ exit 1
+fi
+shift
+
+set -x
+cd "$extDir"
+phpize
+./configure "$@"
diff --git a/5.5/apache/docker-php-ext-install b/5.5/apache/docker-php-ext-install
new file mode 100755
index 00000000..abca7fff
--- /dev/null
+++ b/5.5/apache/docker-php-ext-install
@@ -0,0 +1,55 @@
+#!/bin/bash
+set -e
+
+cd /usr/src/php/ext
+
+usage() {
+ echo "usage: $0 ext-name [ext-name ...]"
+ echo " ie: $0 gd mysqli"
+ echo " $0 pdo pdo_mysql"
+ echo
+ echo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'
+ echo
+ echo 'Possible values for ext-name:'
+ echo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)
+}
+
+exts=()
+while [ $# -gt 0 ]; do
+ ext="$1"
+ shift
+ if [ -z "$ext" ]; then
+ continue
+ fi
+ if [ ! -d "$ext" ]; then
+ echo >&2 "error: $(pwd -P)/$ext does not exist"
+ echo >&2
+ usage >&2
+ exit 1
+ fi
+ exts+=( "$ext" )
+done
+
+if [ "${#exts[@]}" -eq 0 ]; then
+ usage >&2
+ exit 1
+fi
+
+for ext in "${exts[@]}"; do
+ (
+ cd "$ext"
+ [ -e Makefile ] || docker-php-ext-configure "$ext"
+ make
+ make install
+ ini="/usr/local/etc/php/conf.d/docker-php-ext-$ext.ini"
+ for module in modules/*.so; do
+ if [ -f "$module" ]; then
+ line="extension=$(basename "$module")"
+ if ! grep -q "$line" "$ini"; then
+ echo "$line" >> "/usr/local/etc/php/conf.d/ext-$ext.ini"
+ fi
+ fi
+ done
+ make clean
+ )
+done
diff --git a/5.5/docker-php-ext-configure b/5.5/docker-php-ext-configure
new file mode 100755
index 00000000..3d21b5bb
--- /dev/null
+++ b/5.5/docker-php-ext-configure
@@ -0,0 +1,19 @@
+#!/bin/bash
+set -e
+
+ext="$1"
+extDir="/usr/src/php/ext/$ext"
+if [ -z "$ext" -o ! -d "$extDir" ]; then
+ echo >&2 "usage: $0 ext-name [configure flags]"
+ echo >&2 " ie: $0 gd --with-jpeg-dir=/usr/local/something"
+ echo >&2
+ echo >&2 'Possible values for ext-name:'
+ echo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)
+ exit 1
+fi
+shift
+
+set -x
+cd "$extDir"
+phpize
+./configure "$@"
diff --git a/5.5/docker-php-ext-install b/5.5/docker-php-ext-install
new file mode 100755
index 00000000..abca7fff
--- /dev/null
+++ b/5.5/docker-php-ext-install
@@ -0,0 +1,55 @@
+#!/bin/bash
+set -e
+
+cd /usr/src/php/ext
+
+usage() {
+ echo "usage: $0 ext-name [ext-name ...]"
+ echo " ie: $0 gd mysqli"
+ echo " $0 pdo pdo_mysql"
+ echo
+ echo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'
+ echo
+ echo 'Possible values for ext-name:'
+ echo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)
+}
+
+exts=()
+while [ $# -gt 0 ]; do
+ ext="$1"
+ shift
+ if [ -z "$ext" ]; then
+ continue
+ fi
+ if [ ! -d "$ext" ]; then
+ echo >&2 "error: $(pwd -P)/$ext does not exist"
+ echo >&2
+ usage >&2
+ exit 1
+ fi
+ exts+=( "$ext" )
+done
+
+if [ "${#exts[@]}" -eq 0 ]; then
+ usage >&2
+ exit 1
+fi
+
+for ext in "${exts[@]}"; do
+ (
+ cd "$ext"
+ [ -e Makefile ] || docker-php-ext-configure "$ext"
+ make
+ make install
+ ini="/usr/local/etc/php/conf.d/docker-php-ext-$ext.ini"
+ for module in modules/*.so; do
+ if [ -f "$module" ]; then
+ line="extension=$(basename "$module")"
+ if ! grep -q "$line" "$ini"; then
+ echo "$line" >> "/usr/local/etc/php/conf.d/ext-$ext.ini"
+ fi
+ fi
+ done
+ make clean
+ )
+done
diff --git a/5.6/Dockerfile b/5.6/Dockerfile
index afbd82c9..7a660e26 100644
--- a/5.6/Dockerfile
+++ b/5.6/Dockerfile
@@ -3,6 +3,12 @@ FROM debian:jessie
# persistent / runtime deps
RUN apt-get update && apt-get install -y ca-certificates curl libxml2 --no-install-recommends && rm -r /var/lib/apt/lists/*
+# phpize deps
+RUN apt-get update && apt-get install -y autoconf gcc pkg-config --no-install-recommends && rm -r /var/lib/apt/lists/*
+
+ENV PHP_INI_DIR /usr/local/etc/php
+RUN mkdir -p $PHP_INI_DIR/conf.d
+
####
####
@@ -10,18 +16,15 @@ RUN gpg --keyserver pgp.mit.edu --recv-keys 6E4F6AB321FDC07F2C332E3AC2BF0BC433CF
ENV PHP_VERSION 5.6.2
+# --enable-mysqlnd is included below because it's harder to compile after the fact the extensions are (since it's a plugin for several extensions, not an extension in itself)
RUN buildDeps=" \
$PHP_EXTRA_BUILD_DEPS \
- build-essential \
bzip2 \
file \
libcurl4-openssl-dev \
- libpng12-dev \
libreadline6-dev \
libssl-dev \
libxml2-dev \
- m4 \
- pkg-config \
"; \
set -x \
&& apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \
@@ -32,22 +35,23 @@ RUN buildDeps=" \
&& tar -xf php.tar.bz2 -C /usr/src/php --strip-components=1 \
&& rm php.tar.bz2* \
&& cd /usr/src/php \
- && ./configure --disable-cgi \
+ && ./configure \
+ --with-config-file-path="$PHP_INI_DIR" \
+ --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \
$PHP_EXTRA_CONFIGURE_ARGS \
- --enable-soap \
+ --disable-cgi \
+ --enable-mysqlnd \
--with-curl \
- --with-gd \
- --with-mysql \
- --with-mysqli \
--with-openssl \
- --with-pdo-mysql \
--with-readline \
--with-zlib \
&& make -j"$(nproc)" \
&& make install \
&& { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \
&& apt-get purge -y --auto-remove $buildDeps \
- && rm -r /usr/src/php
+ && make clean
+
+COPY docker-php-ext-* /usr/local/bin/
####
CMD ["php", "-a"]
diff --git a/5.6/apache/Dockerfile b/5.6/apache/Dockerfile
index 527bcf18..8a21997e 100644
--- a/5.6/apache/Dockerfile
+++ b/5.6/apache/Dockerfile
@@ -3,6 +3,12 @@ FROM debian:jessie
# persistent / runtime deps
RUN apt-get update && apt-get install -y ca-certificates curl libxml2 --no-install-recommends && rm -r /var/lib/apt/lists/*
+# phpize deps
+RUN apt-get update && apt-get install -y autoconf gcc pkg-config --no-install-recommends && rm -r /var/lib/apt/lists/*
+
+ENV PHP_INI_DIR /usr/local/etc/php
+RUN mkdir -p $PHP_INI_DIR/conf.d
+
####
RUN apt-get update && apt-get install -y apache2-bin apache2.2-common --no-install-recommends && rm -rf /var/lib/apt/lists/*
@@ -23,18 +29,15 @@ RUN gpg --keyserver pgp.mit.edu --recv-keys 6E4F6AB321FDC07F2C332E3AC2BF0BC433CF
ENV PHP_VERSION 5.6.2
+# --enable-mysqlnd is included below because it's harder to compile after the fact the extensions are (since it's a plugin for several extensions, not an extension in itself)
RUN buildDeps=" \
$PHP_EXTRA_BUILD_DEPS \
- build-essential \
bzip2 \
file \
libcurl4-openssl-dev \
- libpng12-dev \
libreadline6-dev \
libssl-dev \
libxml2-dev \
- m4 \
- pkg-config \
"; \
set -x \
&& apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \
@@ -45,22 +48,23 @@ RUN buildDeps=" \
&& tar -xf php.tar.bz2 -C /usr/src/php --strip-components=1 \
&& rm php.tar.bz2* \
&& cd /usr/src/php \
- && ./configure --disable-cgi \
+ && ./configure \
+ --with-config-file-path="$PHP_INI_DIR" \
+ --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \
$PHP_EXTRA_CONFIGURE_ARGS \
- --enable-soap \
+ --disable-cgi \
+ --enable-mysqlnd \
--with-curl \
- --with-gd \
- --with-mysql \
- --with-mysqli \
--with-openssl \
- --with-pdo-mysql \
--with-readline \
--with-zlib \
&& make -j"$(nproc)" \
&& make install \
&& { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \
&& apt-get purge -y --auto-remove $buildDeps \
- && rm -r /usr/src/php
+ && make clean
+
+COPY docker-php-ext-* /usr/local/bin/
####
WORKDIR /var/www/html
diff --git a/5.6/apache/docker-php-ext-configure b/5.6/apache/docker-php-ext-configure
new file mode 100755
index 00000000..3d21b5bb
--- /dev/null
+++ b/5.6/apache/docker-php-ext-configure
@@ -0,0 +1,19 @@
+#!/bin/bash
+set -e
+
+ext="$1"
+extDir="/usr/src/php/ext/$ext"
+if [ -z "$ext" -o ! -d "$extDir" ]; then
+ echo >&2 "usage: $0 ext-name [configure flags]"
+ echo >&2 " ie: $0 gd --with-jpeg-dir=/usr/local/something"
+ echo >&2
+ echo >&2 'Possible values for ext-name:'
+ echo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)
+ exit 1
+fi
+shift
+
+set -x
+cd "$extDir"
+phpize
+./configure "$@"
diff --git a/5.6/apache/docker-php-ext-install b/5.6/apache/docker-php-ext-install
new file mode 100755
index 00000000..abca7fff
--- /dev/null
+++ b/5.6/apache/docker-php-ext-install
@@ -0,0 +1,55 @@
+#!/bin/bash
+set -e
+
+cd /usr/src/php/ext
+
+usage() {
+ echo "usage: $0 ext-name [ext-name ...]"
+ echo " ie: $0 gd mysqli"
+ echo " $0 pdo pdo_mysql"
+ echo
+ echo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'
+ echo
+ echo 'Possible values for ext-name:'
+ echo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)
+}
+
+exts=()
+while [ $# -gt 0 ]; do
+ ext="$1"
+ shift
+ if [ -z "$ext" ]; then
+ continue
+ fi
+ if [ ! -d "$ext" ]; then
+ echo >&2 "error: $(pwd -P)/$ext does not exist"
+ echo >&2
+ usage >&2
+ exit 1
+ fi
+ exts+=( "$ext" )
+done
+
+if [ "${#exts[@]}" -eq 0 ]; then
+ usage >&2
+ exit 1
+fi
+
+for ext in "${exts[@]}"; do
+ (
+ cd "$ext"
+ [ -e Makefile ] || docker-php-ext-configure "$ext"
+ make
+ make install
+ ini="/usr/local/etc/php/conf.d/docker-php-ext-$ext.ini"
+ for module in modules/*.so; do
+ if [ -f "$module" ]; then
+ line="extension=$(basename "$module")"
+ if ! grep -q "$line" "$ini"; then
+ echo "$line" >> "/usr/local/etc/php/conf.d/ext-$ext.ini"
+ fi
+ fi
+ done
+ make clean
+ )
+done
diff --git a/5.6/docker-php-ext-configure b/5.6/docker-php-ext-configure
new file mode 100755
index 00000000..3d21b5bb
--- /dev/null
+++ b/5.6/docker-php-ext-configure
@@ -0,0 +1,19 @@
+#!/bin/bash
+set -e
+
+ext="$1"
+extDir="/usr/src/php/ext/$ext"
+if [ -z "$ext" -o ! -d "$extDir" ]; then
+ echo >&2 "usage: $0 ext-name [configure flags]"
+ echo >&2 " ie: $0 gd --with-jpeg-dir=/usr/local/something"
+ echo >&2
+ echo >&2 'Possible values for ext-name:'
+ echo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)
+ exit 1
+fi
+shift
+
+set -x
+cd "$extDir"
+phpize
+./configure "$@"
diff --git a/5.6/docker-php-ext-install b/5.6/docker-php-ext-install
new file mode 100755
index 00000000..abca7fff
--- /dev/null
+++ b/5.6/docker-php-ext-install
@@ -0,0 +1,55 @@
+#!/bin/bash
+set -e
+
+cd /usr/src/php/ext
+
+usage() {
+ echo "usage: $0 ext-name [ext-name ...]"
+ echo " ie: $0 gd mysqli"
+ echo " $0 pdo pdo_mysql"
+ echo
+ echo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'
+ echo
+ echo 'Possible values for ext-name:'
+ echo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)
+}
+
+exts=()
+while [ $# -gt 0 ]; do
+ ext="$1"
+ shift
+ if [ -z "$ext" ]; then
+ continue
+ fi
+ if [ ! -d "$ext" ]; then
+ echo >&2 "error: $(pwd -P)/$ext does not exist"
+ echo >&2
+ usage >&2
+ exit 1
+ fi
+ exts+=( "$ext" )
+done
+
+if [ "${#exts[@]}" -eq 0 ]; then
+ usage >&2
+ exit 1
+fi
+
+for ext in "${exts[@]}"; do
+ (
+ cd "$ext"
+ [ -e Makefile ] || docker-php-ext-configure "$ext"
+ make
+ make install
+ ini="/usr/local/etc/php/conf.d/docker-php-ext-$ext.ini"
+ for module in modules/*.so; do
+ if [ -f "$module" ]; then
+ line="extension=$(basename "$module")"
+ if ! grep -q "$line" "$ini"; then
+ echo "$line" >> "/usr/local/etc/php/conf.d/ext-$ext.ini"
+ fi
+ fi
+ done
+ make clean
+ )
+done
diff --git a/docker-php-ext-configure b/docker-php-ext-configure
new file mode 100755
index 00000000..3d21b5bb
--- /dev/null
+++ b/docker-php-ext-configure
@@ -0,0 +1,19 @@
+#!/bin/bash
+set -e
+
+ext="$1"
+extDir="/usr/src/php/ext/$ext"
+if [ -z "$ext" -o ! -d "$extDir" ]; then
+ echo >&2 "usage: $0 ext-name [configure flags]"
+ echo >&2 " ie: $0 gd --with-jpeg-dir=/usr/local/something"
+ echo >&2
+ echo >&2 'Possible values for ext-name:'
+ echo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)
+ exit 1
+fi
+shift
+
+set -x
+cd "$extDir"
+phpize
+./configure "$@"
diff --git a/docker-php-ext-install b/docker-php-ext-install
new file mode 100755
index 00000000..abca7fff
--- /dev/null
+++ b/docker-php-ext-install
@@ -0,0 +1,55 @@
+#!/bin/bash
+set -e
+
+cd /usr/src/php/ext
+
+usage() {
+ echo "usage: $0 ext-name [ext-name ...]"
+ echo " ie: $0 gd mysqli"
+ echo " $0 pdo pdo_mysql"
+ echo
+ echo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'
+ echo
+ echo 'Possible values for ext-name:'
+ echo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)
+}
+
+exts=()
+while [ $# -gt 0 ]; do
+ ext="$1"
+ shift
+ if [ -z "$ext" ]; then
+ continue
+ fi
+ if [ ! -d "$ext" ]; then
+ echo >&2 "error: $(pwd -P)/$ext does not exist"
+ echo >&2
+ usage >&2
+ exit 1
+ fi
+ exts+=( "$ext" )
+done
+
+if [ "${#exts[@]}" -eq 0 ]; then
+ usage >&2
+ exit 1
+fi
+
+for ext in "${exts[@]}"; do
+ (
+ cd "$ext"
+ [ -e Makefile ] || docker-php-ext-configure "$ext"
+ make
+ make install
+ ini="/usr/local/etc/php/conf.d/docker-php-ext-$ext.ini"
+ for module in modules/*.so; do
+ if [ -f "$module" ]; then
+ line="extension=$(basename "$module")"
+ if ! grep -q "$line" "$ini"; then
+ echo "$line" >> "/usr/local/etc/php/conf.d/ext-$ext.ini"
+ fi
+ fi
+ done
+ make clean
+ )
+done
diff --git a/update.sh b/update.sh
index 5c7b2545..b5e29c78 100755
--- a/update.sh
+++ b/update.sh
@@ -49,6 +49,8 @@ for version in "${versions[@]}"; do
s/^(RUN gpg .* --recv-keys) [0-9a-fA-F ]*$/\1 '"$gpgKey"'/
' "$version/Dockerfile"
+ cp docker-php-ext-* "$version/"
+ cp docker-php-ext-* "$version/apache/"
cp apache2.conf "$version/apache/"
)
done