-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from devilbox/release-0.54
Shrink images
- Loading branch information
Showing
2 changed files
with
241 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,78 +2,79 @@ FROM debian:jessie-slim | |
MAINTAINER "cytopia" <[email protected]> | ||
|
||
|
||
ENV PHP_VERSION 5.2.17 | ||
ENV PHP_INI_DIR /usr/local/etc/php | ||
|
||
ENV BUILD_DEPS \ | ||
autoconf2.13 \ | ||
libbison-dev \ | ||
libcurl4-openssl-dev \ | ||
libfl-dev \ | ||
libmysqlclient-dev \ | ||
libpcre3-dev \ | ||
libreadline6-dev \ | ||
librecode-dev \ | ||
libsqlite3-dev \ | ||
libssl-dev \ | ||
libxml2-dev \ | ||
patch | ||
|
||
|
||
# Setup directories | ||
RUN set -eux \ | ||
&& mkdir -p ${PHP_INI_DIR}/conf.d \ | ||
&& mkdir -p /usr/src/php | ||
|
||
|
||
# persistent / runtime deps | ||
ENV PHP_VERSION=5.2.17 | ||
ENV PHP_INI_DIR=/usr/local/etc/php | ||
|
||
ENV OPENSSL_VERSION=1.0.2g | ||
|
||
ENV PHP_BUILD_DEPS \ | ||
autoconf2.13 \ | ||
libbison-dev \ | ||
libcurl4-openssl-dev \ | ||
libfl-dev \ | ||
libmysqlclient-dev \ | ||
libpcre3-dev \ | ||
libreadline6-dev \ | ||
librecode-dev \ | ||
libsqlite3-dev \ | ||
libssl-dev \ | ||
libxml2-dev | ||
|
||
ENV PHP_RUNTIME_DEPS \ | ||
libmysqlclient18 \ | ||
libpcre3 \ | ||
librecode0 \ | ||
libsqlite3-0 \ | ||
libssl1.0.0 \ | ||
libxml2 \ | ||
xz-utils | ||
|
||
ENV BUILD_TOOLS \ | ||
autoconf \ | ||
ca-certificates \ | ||
curl \ | ||
dpkg-dev \ | ||
file \ | ||
flex \ | ||
g++ \ | ||
gcc \ | ||
libc-dev \ | ||
make \ | ||
patch \ | ||
pkg-config \ | ||
re2c \ | ||
xz-utils | ||
|
||
ENV BUILD_TOOLS_32 \ | ||
g++-multilib \ | ||
gcc-multilib | ||
|
||
ENV RUNTIME_TOOLS \ | ||
ca-certificates \ | ||
curl | ||
|
||
|
||
### | ||
### Build OpenSSL | ||
### | ||
RUN set -eux \ | ||
# Install Dependencies | ||
&& apt-get update \ | ||
&& apt-get install -y --no-install-recommends --no-install-suggests \ | ||
ca-certificates \ | ||
curl \ | ||
libpcre3 \ | ||
librecode0 \ | ||
libmysqlclient18 \ | ||
libsqlite3-0 \ | ||
libxml2 \ | ||
&& apt-get clean \ | ||
&& rm -r /var/lib/apt/lists/* | ||
|
||
|
||
# phpize deps | ||
RUN set -eux \ | ||
&& apt-get update \ | ||
&& apt-get install -y --no-install-recommends --no-install-suggests \ | ||
autoconf \ | ||
dpkg-dev \ | ||
file \ | ||
g++ \ | ||
gcc \ | ||
libc-dev \ | ||
make \ | ||
pkg-config \ | ||
re2c \ | ||
xz-utils \ | ||
${BUILD_TOOLS} \ | ||
&& if [ "$(dpkg-architecture --query DEB_HOST_ARCH)" = "i386" ]; then \ | ||
apt-get install -y --no-install-recommends --no-install-suggests \ | ||
g++-multilib \ | ||
gcc-multilib; \ | ||
${BUILD_TOOLS_32}; \ | ||
fi \ | ||
&& apt-get clean \ | ||
&& rm -r /var/lib/apt/lists/* | ||
|
||
|
||
# compile openssl, otherwise --with-openssl won't work | ||
RUN set -eux \ | ||
&& OPENSSL_VERSION="1.0.2g" \ | ||
# Fetch OpenSSL | ||
&& cd /tmp \ | ||
&& mkdir openssl \ | ||
&& update-ca-certificates \ | ||
&& curl -sS -k -L --fail "https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz" -o openssl.tar.gz \ | ||
&& curl -sS -k -L --fail "https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz.asc" -o openssl.tar.gz.asc \ | ||
&& tar -xzf openssl.tar.gz -C openssl --strip-components=1 \ | ||
&& cd /tmp/openssl \ | ||
# Build OpenSSL | ||
&& if [ "$(dpkg-architecture --query DEB_HOST_ARCH)" = "i386" ]; then \ | ||
setarch i386 ./config -m32; \ | ||
else \ | ||
|
@@ -82,27 +83,53 @@ RUN set -eux \ | |
&& make depend \ | ||
&& make -j"$(nproc)" \ | ||
&& make install \ | ||
&& rm -rf /tmp/openssl* \ | ||
# Cleanup | ||
&& rm -rf /tmp/* \ | ||
# Ensure libs are linked to correct architecture directory | ||
&& debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)" \ | ||
&& mkdir -p "/usr/local/ssl/lib/${debMultiarch}" \ | ||
&& ln -s /usr/local/ssl/lib/* "/usr/local/ssl/lib/${debMultiarch}/" | ||
&& ln -s /usr/local/ssl/lib/* "/usr/local/ssl/lib/${debMultiarch}/" \ | ||
# Remove Dependencies | ||
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false \ | ||
${BUILD_TOOLS} \ | ||
&& if [ "$(dpkg-architecture --query DEB_HOST_ARCH)" = "i386" ]; then \ | ||
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false \ | ||
${BUILD_TOOLS_32}; \ | ||
fi \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
|
||
# php 5.2 needs older autoconf | ||
### | ||
### Setup PHP directories | ||
### | ||
RUN set -eux \ | ||
&& set -x \ | ||
&& apt-get update \ | ||
&& apt-get install -y --no-install-recommends --no-install-suggests \ | ||
${BUILD_DEPS} \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
&& mkdir -p ${PHP_INI_DIR}/conf.d \ | ||
&& mkdir -p /usr/src/php | ||
|
||
|
||
# Copy and apply patches to PHP | ||
### | ||
### Copy PHP scripts and patches | ||
### | ||
COPY data/docker-php-source /usr/local/bin/ | ||
COPY data/php-${PHP_VERSION}*.patch /tmp/ | ||
|
||
|
||
### | ||
### Build PHP | ||
### | ||
RUN set -eux \ | ||
# Install Dependencies | ||
&& apt-get update \ | ||
&& apt-get install -y --no-install-recommends --no-install-suggests \ | ||
${PHP_BUILD_DEPS} \ | ||
${BUILD_TOOLS} \ | ||
&& if [ "$(dpkg-architecture --query DEB_HOST_ARCH)" = "i386" ]; then \ | ||
apt-get install -y --no-install-recommends --no-install-suggests \ | ||
${BUILD_TOOLS_32}; \ | ||
fi \ | ||
# Fetch PHP | ||
&& curl -sS -k -L --fail "http://museum.php.net/php5/php-${PHP_VERSION}.tar.gz" -o /usr/src/php.tar.gz \ | ||
\ | ||
# Extract artifacts | ||
&& tar -xf /usr/src/php.tar.gz -C /usr/src/php --strip-components=1 \ | ||
# Apply patches | ||
|
@@ -114,65 +141,75 @@ RUN set -eux \ | |
# Create php.tar.xz | ||
&& cd /usr/src \ | ||
&& tar -cJf php.tar.xz php \ | ||
# Clean-up | ||
&& rm -rf php php.tar.gz \ | ||
&& rm -rf /tmp/php-* | ||
|
||
|
||
COPY data/docker-php-source /usr/local/bin/ | ||
RUN set -eux \ | ||
&& rm -rf /tmp/php-* \ | ||
# Setup Requirements | ||
&& apt update \ | ||
&& apt install --no-install-recommends --no-install-suggests \ | ||
flex -y \ | ||
&& docker-php-source extract \ | ||
&& cd /usr/src/php \ | ||
\ | ||
&& gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \ | ||
&& debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)" \ | ||
\ | ||
# https://bugs.php.net/bug.php?id=74125 | ||
&& if [ ! -d /usr/include/curl ]; then \ | ||
ln -sT "/usr/include/${debMultiarch}/curl" /usr/local/include/curl; \ | ||
fi \ | ||
\ | ||
# Build PHP | ||
&& ./configure \ | ||
--host="${gnuArch}" \ | ||
--with-libdir="/lib/${debMultiarch}/" \ | ||
--with-config-file-path="${PHP_INI_DIR}" \ | ||
--with-config-file-scan-dir="${PHP_INI_DIR}/conf.d" \ | ||
--with-fpm-conf="/usr/local/etc/php-fpm.conf" \ | ||
--enable-fpm \ | ||
\ | ||
--enable-fastcgi \ | ||
--enable-fpm \ | ||
--enable-force-cgi-redirect \ | ||
\ | ||
--enable-mbstring \ | ||
--enable-pdo \ | ||
--enable-soap \ | ||
--enable-pdo \ | ||
\ | ||
--with-curl \ | ||
--with-mysql \ | ||
--with-mysqli \ | ||
--with-curl \ | ||
--with-openssl=/usr/local/ssl \ | ||
--with-pdo-mysql \ | ||
--with-readline \ | ||
--with-zlib \ | ||
&& make -j"$(nproc)" \ | ||
&& make install \ | ||
&& php -v \ | ||
# Clean-up | ||
&& { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \ | ||
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false ${BUILD_DEPS} \ | ||
# Cleanup | ||
&& make clean \ | ||
&& cd / \ | ||
&& docker-php-source delete | ||
&& { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \ | ||
&& docker-php-source delete \ | ||
# Remove Dependencies | ||
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false \ | ||
${PHP_BUILD_DEPS} \ | ||
${BUILD_TOOLS} \ | ||
&& if [ "$(dpkg-architecture --query DEB_HOST_ARCH)" = "i386" ]; then \ | ||
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false \ | ||
${BUILD_TOOLS_32}; \ | ||
fi \ | ||
# Install Run-time requirements | ||
&& apt-get update \ | ||
&& apt-get install -y --no-install-recommends --no-install-suggests \ | ||
${PHP_RUNTIME_DEPS} \ | ||
${RUNTIME_TOOLS} \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
|
||
WORKDIR /var/www/html | ||
COPY data/docker-php-* /usr/local/bin/ | ||
COPY data/php-fpm /usr/local/sbin/php-fpm | ||
|
||
WORKDIR /var/www/html | ||
COPY data/php-fpm.conf /usr/local/etc/ | ||
COPY data/php.ini /usr/local/etc/php/php.ini | ||
|
||
|
||
EXPOSE 9000 | ||
ENTRYPOINT ["php-fpm"] | ||
CMD ["php-fpm"] |
Oops, something went wrong.