From 11f5f37233854969999f225cc5c668a7c4795d0b Mon Sep 17 00:00:00 2001 From: Marcelo Andrade Date: Mon, 29 Jun 2015 23:34:47 +0000 Subject: [PATCH] Add php-7.0.0alpha2 (Issue #108) Adding 7.0 to travis Fixes for the reviewed code Fixes to have the directory as 7.0 Change version on travis Remove GPG from Dockerfile on 7.0 --- .travis.yml | 3 ++ 7.0/Dockerfile | 58 ++++++++++++++++++++++ 7.0/apache/Dockerfile | 75 +++++++++++++++++++++++++++++ 7.0/apache/apache2-foreground | 7 +++ 7.0/apache/apache2.conf | 64 ++++++++++++++++++++++++ 7.0/apache/docker-php-ext-configure | 19 ++++++++ 7.0/apache/docker-php-ext-install | 60 +++++++++++++++++++++++ 7.0/docker-php-ext-configure | 19 ++++++++ 7.0/docker-php-ext-install | 60 +++++++++++++++++++++++ 7.0/fpm/Dockerfile | 63 ++++++++++++++++++++++++ 7.0/fpm/docker-php-ext-configure | 19 ++++++++ 7.0/fpm/docker-php-ext-install | 60 +++++++++++++++++++++++ 7.0/fpm/php-fpm.conf | 25 ++++++++++ update.sh | 13 +++-- 14 files changed, 542 insertions(+), 3 deletions(-) create mode 100644 7.0/Dockerfile create mode 100644 7.0/apache/Dockerfile create mode 100755 7.0/apache/apache2-foreground create mode 100644 7.0/apache/apache2.conf create mode 100755 7.0/apache/docker-php-ext-configure create mode 100755 7.0/apache/docker-php-ext-install create mode 100755 7.0/docker-php-ext-configure create mode 100755 7.0/docker-php-ext-install create mode 100644 7.0/fpm/Dockerfile create mode 100755 7.0/fpm/docker-php-ext-configure create mode 100755 7.0/fpm/docker-php-ext-install create mode 100644 7.0/fpm/php-fpm.conf diff --git a/.travis.yml b/.travis.yml index 1af50336..9126615d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,9 @@ language: bash dist: trusty env: + - VERSION=7.0 VARIANT= + - VERSION=7.0 VARIANT=apache + - VERSION=7.0 VARIANT=fpm - VERSION=5.6 VARIANT= - VERSION=5.6 VARIANT=apache - VERSION=5.6 VARIANT=fpm diff --git a/7.0/Dockerfile b/7.0/Dockerfile new file mode 100644 index 00000000..39af698e --- /dev/null +++ b/7.0/Dockerfile @@ -0,0 +1,58 @@ +FROM debian:jessie + +# persistent / runtime deps +RUN apt-get update && apt-get install -y ca-certificates curl libpcre3 librecode0 libsqlite3-0 libxml2 --no-install-recommends && rm -r /var/lib/apt/lists/* + +# phpize deps +RUN apt-get update && apt-get install -y autoconf file g++ gcc libc-dev make pkg-config re2c --no-install-recommends && rm -r /var/lib/apt/lists/* + +ENV PHP_INI_DIR /usr/local/etc/php +RUN mkdir -p $PHP_INI_DIR/conf.d + +#### +#### + +ENV PHP_VERSION 7.0.0alpha2 + +# --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 \ + libcurl4-openssl-dev \ + libpcre3-dev \ + libreadline6-dev \ + librecode-dev \ + libsqlite3-dev \ + libssl-dev \ + libxml2-dev \ + xz-utils \ + " \ + && set -x \ + && apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \ + && curl -SL "https://downloads.php.net/~ab/php-$PHP_VERSION.tar.xz" -o php.tar.xz \ + && mkdir -p /usr/src/php \ + && tar -xof php.tar.xz -C /usr/src/php --strip-components=1 \ + && rm php.tar.xz* \ + && cd /usr/src/php \ + && ./configure \ + --with-config-file-path="$PHP_INI_DIR" \ + --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \ + $PHP_EXTRA_CONFIGURE_ARGS \ + --disable-cgi \ + --enable-mysqlnd \ + --with-curl \ + --with-openssl \ + --with-pcre \ + --with-readline \ + --with-recode \ + --with-zlib \ + && make -j"$(nproc)" \ + && make install \ + && { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \ + && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps \ + && make clean + +COPY docker-php-ext-* /usr/local/bin/ + +#### +CMD ["php", "-a"] +#### diff --git a/7.0/apache/Dockerfile b/7.0/apache/Dockerfile new file mode 100644 index 00000000..a4b41bd4 --- /dev/null +++ b/7.0/apache/Dockerfile @@ -0,0 +1,75 @@ +FROM debian:jessie + +# persistent / runtime deps +RUN apt-get update && apt-get install -y ca-certificates curl libpcre3 librecode0 libsqlite3-0 libxml2 --no-install-recommends && rm -r /var/lib/apt/lists/* + +# phpize deps +RUN apt-get update && apt-get install -y autoconf file g++ gcc libc-dev make pkg-config re2c --no-install-recommends && rm -r /var/lib/apt/lists/* + +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/* + +RUN rm -rf /var/www/html && mkdir -p /var/lock/apache2 /var/run/apache2 /var/log/apache2 /var/www/html && chown -R www-data:www-data /var/lock/apache2 /var/run/apache2 /var/log/apache2 /var/www/html + +# Apache + PHP requires preforking Apache for best results +RUN a2dismod mpm_event && a2enmod mpm_prefork + +RUN mv /etc/apache2/apache2.conf /etc/apache2/apache2.conf.dist && rm /etc/apache2/conf-enabled/* /etc/apache2/sites-enabled/* +COPY apache2.conf /etc/apache2/apache2.conf +# it'd be nice if we could not COPY apache2.conf until the end of the Dockerfile, but its contents are checked by PHP during compilation + +ENV PHP_EXTRA_BUILD_DEPS apache2-dev +ENV PHP_EXTRA_CONFIGURE_ARGS --with-apxs2 +#### + +ENV PHP_VERSION 7.0.0alpha2 + +# --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 \ + libcurl4-openssl-dev \ + libpcre3-dev \ + libreadline6-dev \ + librecode-dev \ + libsqlite3-dev \ + libssl-dev \ + libxml2-dev \ + xz-utils \ + " \ + && set -x \ + && apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \ + && curl -SL "https://downloads.php.net/~ab/php-$PHP_VERSION.tar.xz" -o php.tar.xz \ + && mkdir -p /usr/src/php \ + && tar -xof php.tar.xz -C /usr/src/php --strip-components=1 \ + && rm php.tar.xz* \ + && cd /usr/src/php \ + && ./configure \ + --with-config-file-path="$PHP_INI_DIR" \ + --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \ + $PHP_EXTRA_CONFIGURE_ARGS \ + --disable-cgi \ + --enable-mysqlnd \ + --with-curl \ + --with-openssl \ + --with-pcre \ + --with-readline \ + --with-recode \ + --with-zlib \ + && make -j"$(nproc)" \ + && make install \ + && { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \ + && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps \ + && make clean + +COPY docker-php-ext-* /usr/local/bin/ + +#### +COPY apache2-foreground /usr/local/bin/ +WORKDIR /var/www/html + +EXPOSE 80 +CMD ["apache2-foreground"] +#### diff --git a/7.0/apache/apache2-foreground b/7.0/apache/apache2-foreground new file mode 100755 index 00000000..70def2f2 --- /dev/null +++ b/7.0/apache/apache2-foreground @@ -0,0 +1,7 @@ +#!/bin/bash +set -e + +# Apache gets grumpy about PID files pre-existing +rm -f /var/run/apache2/apache2.pid + +exec apache2 -DFOREGROUND diff --git a/7.0/apache/apache2.conf b/7.0/apache/apache2.conf new file mode 100644 index 00000000..ab5b2648 --- /dev/null +++ b/7.0/apache/apache2.conf @@ -0,0 +1,64 @@ +# see http://sources.debian.net/src/apache2/2.4.10-1/debian/config-dir/apache2.conf + +Mutex file:/var/lock/apache2 default +PidFile /var/run/apache2/apache2.pid +Timeout 300 +KeepAlive On +MaxKeepAliveRequests 100 +KeepAliveTimeout 5 +User www-data +Group www-data +HostnameLookups Off +ErrorLog /proc/self/fd/2 +LogLevel warn + +IncludeOptional mods-enabled/*.load +IncludeOptional mods-enabled/*.conf + +# ports.conf +Listen 80 + + Listen 443 + + + Listen 443 + + + + Options FollowSymLinks + AllowOverride None + Require all denied + + + + AllowOverride All + Require all granted + + +DocumentRoot /var/www/html + +AccessFileName .htaccess + + Require all denied + + +LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined +LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined +LogFormat "%h %l %u %t \"%r\" %>s %O" common +LogFormat "%{Referer}i -> %U" referer +LogFormat "%{User-agent}i" agent + +CustomLog /proc/self/fd/1 combined + + + SetHandler application/x-httpd-php + + +# Multiple DirectoryIndex directives within the same context will add +# to the list of resources to look for rather than replace +# https://httpd.apache.org/docs/current/mod/mod_dir.html#directoryindex +DirectoryIndex disabled +DirectoryIndex index.php index.html + +IncludeOptional conf-enabled/*.conf +IncludeOptional sites-enabled/*.conf diff --git a/7.0/apache/docker-php-ext-configure b/7.0/apache/docker-php-ext-configure new file mode 100755 index 00000000..3d21b5bb --- /dev/null +++ b/7.0/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/7.0/apache/docker-php-ext-install b/7.0/apache/docker-php-ext-install new file mode 100755 index 00000000..d50cd2a2 --- /dev/null +++ b/7.0/apache/docker-php-ext-install @@ -0,0 +1,60 @@ +#!/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 + if grep -q zend_extension_entry "$module"; then + # https://wiki.php.net/internals/extensions#loading_zend_extensions + line="zend_extension=$(basename "$module")" + else + line="extension=$(basename "$module")" + fi + if ! grep -q "$line" "$ini" 2>/dev/null; then + echo "$line" >> "$ini" + fi + fi + done + make clean + ) +done diff --git a/7.0/docker-php-ext-configure b/7.0/docker-php-ext-configure new file mode 100755 index 00000000..3d21b5bb --- /dev/null +++ b/7.0/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/7.0/docker-php-ext-install b/7.0/docker-php-ext-install new file mode 100755 index 00000000..d50cd2a2 --- /dev/null +++ b/7.0/docker-php-ext-install @@ -0,0 +1,60 @@ +#!/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 + if grep -q zend_extension_entry "$module"; then + # https://wiki.php.net/internals/extensions#loading_zend_extensions + line="zend_extension=$(basename "$module")" + else + line="extension=$(basename "$module")" + fi + if ! grep -q "$line" "$ini" 2>/dev/null; then + echo "$line" >> "$ini" + fi + fi + done + make clean + ) +done diff --git a/7.0/fpm/Dockerfile b/7.0/fpm/Dockerfile new file mode 100644 index 00000000..af2ef7c7 --- /dev/null +++ b/7.0/fpm/Dockerfile @@ -0,0 +1,63 @@ +FROM debian:jessie + +# persistent / runtime deps +RUN apt-get update && apt-get install -y ca-certificates curl libpcre3 librecode0 libsqlite3-0 libxml2 --no-install-recommends && rm -r /var/lib/apt/lists/* + +# phpize deps +RUN apt-get update && apt-get install -y autoconf file g++ gcc libc-dev make pkg-config re2c --no-install-recommends && rm -r /var/lib/apt/lists/* + +ENV PHP_INI_DIR /usr/local/etc/php +RUN mkdir -p $PHP_INI_DIR/conf.d + +#### +ENV PHP_EXTRA_CONFIGURE_ARGS --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data +#### + +ENV PHP_VERSION 7.0.0alpha2 + +# --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 \ + libcurl4-openssl-dev \ + libpcre3-dev \ + libreadline6-dev \ + librecode-dev \ + libsqlite3-dev \ + libssl-dev \ + libxml2-dev \ + xz-utils \ + " \ + && set -x \ + && apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \ + && curl -SL "https://downloads.php.net/~ab/php-$PHP_VERSION.tar.xz" -o php.tar.xz \ + && mkdir -p /usr/src/php \ + && tar -xof php.tar.xz -C /usr/src/php --strip-components=1 \ + && rm php.tar.xz* \ + && cd /usr/src/php \ + && ./configure \ + --with-config-file-path="$PHP_INI_DIR" \ + --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \ + $PHP_EXTRA_CONFIGURE_ARGS \ + --disable-cgi \ + --enable-mysqlnd \ + --with-curl \ + --with-openssl \ + --with-pcre \ + --with-readline \ + --with-recode \ + --with-zlib \ + && make -j"$(nproc)" \ + && make install \ + && { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } \ + && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps \ + && make clean + +COPY docker-php-ext-* /usr/local/bin/ + +#### +WORKDIR /var/www/html +COPY php-fpm.conf /usr/local/etc/ + +EXPOSE 9000 +CMD ["php-fpm"] +#### diff --git a/7.0/fpm/docker-php-ext-configure b/7.0/fpm/docker-php-ext-configure new file mode 100755 index 00000000..3d21b5bb --- /dev/null +++ b/7.0/fpm/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/7.0/fpm/docker-php-ext-install b/7.0/fpm/docker-php-ext-install new file mode 100755 index 00000000..d50cd2a2 --- /dev/null +++ b/7.0/fpm/docker-php-ext-install @@ -0,0 +1,60 @@ +#!/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 + if grep -q zend_extension_entry "$module"; then + # https://wiki.php.net/internals/extensions#loading_zend_extensions + line="zend_extension=$(basename "$module")" + else + line="extension=$(basename "$module")" + fi + if ! grep -q "$line" "$ini" 2>/dev/null; then + echo "$line" >> "$ini" + fi + fi + done + make clean + ) +done diff --git a/7.0/fpm/php-fpm.conf b/7.0/fpm/php-fpm.conf new file mode 100644 index 00000000..9f19a933 --- /dev/null +++ b/7.0/fpm/php-fpm.conf @@ -0,0 +1,25 @@ +; This file was initially adapated from the output of: (on PHP 5.6) +; grep -vE '^;|^ *$' /usr/local/etc/php-fpm.conf.default + +[global] + +error_log = /proc/self/fd/2 +daemonize = no + +[www] + +; if we send this to /proc/self/fd/1, it never appears +access.log = /proc/self/fd/2 + +user = www-data +group = www-data + +listen = [::]:9000 + +pm = dynamic +pm.max_children = 5 +pm.start_servers = 2 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 + +clear_env = no diff --git a/update.sh b/update.sh index 418ab4a6..1c24eea5 100755 --- a/update.sh +++ b/update.sh @@ -3,13 +3,15 @@ set -e declare -A gpgKeys gpgKeys=( + [7.0]='1A4E8B7277C42E53DBA9C7B9BCAA30EA9C0D5763' [5.6]='6E4F6AB321FDC07F2C332E3AC2BF0BC433CFC8B3 0BD78B5F97500D450838F95DFE857D9A90D90EC1' [5.5]='0BD78B5F97500D450838F95DFE857D9A90D90EC1 0B96609E270F565C13292B24C13C70B87267B52D' [5.4]='F38252826ACD957EF380D39F2F7956BC5DA04B5D' [5.3]='0B96609E270F565C13292B24C13C70B87267B52D 0A95E9A026542D53835E3F3A7DEC4E69FC9C83D7' ) # see http://php.net/downloads.php - +alphaVersion="7.0" +fullAlphaVersion="7.0.0alpha2" cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" versions=( "$@" ) @@ -32,7 +34,12 @@ for version in "${versions[@]}"; do done if [ -z "$fullVersion" ]; then echo >&2 "ERROR: missing $version in $packagesUrl" - continue + # if version is alpha then we add the missing part + if [ "$alphaVersion" == "$version" ]; then + fullVersion="$fullAlphaVersion" + else + continue + fi fi gpgKey="${gpgKeys[$version]}" @@ -41,7 +48,7 @@ for version in "${versions[@]}"; do echo >&2 " try looking on http://php.net/downloads.php#gpg-$version" exit 1 fi - + ( set -x; cp docker-php-ext-* "$version/" ) for variant in apache fpm; do