mirror of
https://github.com/hoellen/dockerfiles.git
synced 2025-07-01 22:55:39 +00:00
update php to 7.1.5
This commit is contained in:
191
nginx-php/7.1/Dockerfile
Normal file
191
nginx-php/7.1/Dockerfile
Normal file
@ -0,0 +1,191 @@
|
||||
FROM alpine:3.5
|
||||
|
||||
ARG BUILD_CORES
|
||||
|
||||
ARG NGINX_VER=1.13.0
|
||||
ARG PHP_VER=7.1.5
|
||||
ARG LIBICONV_VERSION=1.15
|
||||
|
||||
LABEL description="nginx + php image based on Alpine" \
|
||||
maintainer="Wonderfall <wonderfall@targaryen.house>" \
|
||||
php_version="PHP v$PHP_VER built from source" \
|
||||
nginx_version="nginx v$NGINX_VER built from source"
|
||||
|
||||
ARG PHP_MIRROR=http://ch1.php.net
|
||||
|
||||
ARG NGINX_CONF=" \
|
||||
--prefix=/nginx \
|
||||
--sbin-path=/usr/local/sbin/nginx \
|
||||
--http-log-path=/nginx/logs/access.log \
|
||||
--error-log-path=/nginx/logs/error.log \
|
||||
--pid-path=/nginx/run/nginx.pid \
|
||||
--lock-path=/nginx/run/nginx.lock \
|
||||
--with-threads \
|
||||
--with-file-aio \
|
||||
--without-http_geo_module \
|
||||
--without-http_autoindex_module \
|
||||
--without-http_split_clients_module \
|
||||
--without-http_memcached_module \
|
||||
--without-http_empty_gif_module \
|
||||
--without-http_browser_module"
|
||||
|
||||
ARG PHP_CONF=" \
|
||||
--prefix=/usr \
|
||||
--libdir=/usr/lib/php \
|
||||
--datadir=/usr/share/php \
|
||||
--sysconfdir=/php/etc \
|
||||
--localstatedir=/php/var \
|
||||
--with-pear=/usr/share/php \
|
||||
--with-config-file-scan-dir=/php/conf.d \
|
||||
--with-config-file-path=/php \
|
||||
--with-pic \
|
||||
--disable-short-tags \
|
||||
--without-readline \
|
||||
--enable-bcmath=shared \
|
||||
--enable-fpm \
|
||||
--disable-cgi \
|
||||
--enable-mysqlnd \
|
||||
--enable-mbstring \
|
||||
--with-curl \
|
||||
--with-libedit \
|
||||
--with-openssl \
|
||||
--with-iconv=/usr/local \
|
||||
--with-gd \
|
||||
--with-jpeg-dir \
|
||||
--with-png-dir \
|
||||
--with-webp-dir \
|
||||
--with-xpm-dir=no \
|
||||
--with-freetype-dir \
|
||||
--enable-gd-native-ttf \
|
||||
--disable-gd-jis-conv \
|
||||
--with-zlib"
|
||||
|
||||
ARG PHP_EXT_LIST=" \
|
||||
mysqli \
|
||||
ctype \
|
||||
dom \
|
||||
json \
|
||||
xml \
|
||||
mbstring \
|
||||
posix \
|
||||
xmlwriter \
|
||||
zip \
|
||||
zlib \
|
||||
sqlite3 \
|
||||
pdo_sqlite \
|
||||
pdo_pgsql \
|
||||
pdo_mysql \
|
||||
pcntl \
|
||||
curl \
|
||||
fileinfo \
|
||||
bz2 \
|
||||
intl \
|
||||
mcrypt \
|
||||
openssl \
|
||||
ldap \
|
||||
simplexml \
|
||||
pgsql \
|
||||
ftp \
|
||||
exif \
|
||||
gmp"
|
||||
|
||||
ARG CUSTOM_BUILD_PKGS=" \
|
||||
freetype-dev \
|
||||
openldap-dev \
|
||||
gmp-dev \
|
||||
libmcrypt-dev \
|
||||
icu-dev \
|
||||
postgresql-dev \
|
||||
libpng-dev \
|
||||
libwebp-dev \
|
||||
gd-dev \
|
||||
libjpeg-turbo-dev \
|
||||
libxpm-dev \
|
||||
libedit-dev \
|
||||
libxml2-dev \
|
||||
libressl-dev \
|
||||
sqlite-dev"
|
||||
|
||||
ARG CUSTOM_PKGS=" \
|
||||
freetype \
|
||||
openldap \
|
||||
gmp \
|
||||
libmcrypt \
|
||||
libbz2 \
|
||||
icu \
|
||||
libpq"
|
||||
|
||||
COPY rootfs /
|
||||
|
||||
RUN NB_CORES=${BUILD_CORES-$(getconf _NPROCESSORS_CONF)} \
|
||||
|
||||
### Packages installation
|
||||
&& BUILD_DEPS=" \
|
||||
linux-headers \
|
||||
libtool \
|
||||
build-base \
|
||||
pcre-dev \
|
||||
zlib-dev \
|
||||
wget \
|
||||
gnupg \
|
||||
autoconf \
|
||||
gcc \
|
||||
g++ \
|
||||
libc-dev \
|
||||
make \
|
||||
pkgconf \
|
||||
curl-dev \
|
||||
ca-certificates \
|
||||
${CUSTOM_BUILD_PKGS}" \
|
||||
&& apk -U add \
|
||||
${BUILD_DEPS} \
|
||||
s6 \
|
||||
su-exec \
|
||||
curl \
|
||||
libedit \
|
||||
libxml2 \
|
||||
libressl \
|
||||
libwebp \
|
||||
gd \
|
||||
pcre \
|
||||
zlib \
|
||||
${CUSTOM_PKGS} \
|
||||
|
||||
### Source downloading
|
||||
&& wget http://nginx.org/download/nginx-${NGINX_VER}.tar.gz -O /tmp/nginx-${NGINX_VER}.tar.gz \
|
||||
&& wget http://nginx.org/download/nginx-${NGINX_VER}.tar.gz.asc -O /tmp/nginx-${NGINX_VER}.tar.gz.asc \
|
||||
&& wget ${PHP_MIRROR}/get/php-${PHP_VER}.tar.gz/from/this/mirror -O /tmp/php-${PHP_VER}.tar.gz \
|
||||
&& wget ${PHP_MIRROR}/get/php-${PHP_VER}.tar.gz.asc/from/this/mirror -O /tmp/php-${PHP_VER}.tar.gz.asc \
|
||||
&& wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-${LIBICONV_VERSION}.tar.gz -O /tmp/libiconv-${LIBICONV_VERSION}.tar.gz \
|
||||
&& mkdir -p /php/conf.d \
|
||||
&& mkdir -p /usr/src \
|
||||
&& tar xzf /tmp/nginx-${NGINX_VER}.tar.gz -C /usr/src \
|
||||
&& tar xzvf /tmp/php-${PHP_VER}.tar.gz -C /usr/src \
|
||||
&& tar xzf /tmp/libiconv-${LIBICONV_VERSION}.tar.gz -C /usr/src \
|
||||
|
||||
### nginx installation
|
||||
&& cd /usr/src/nginx-${NGINX_VER} \
|
||||
&& ./configure --with-cc-opt="-O3 -fPIE -fstack-protector-strong" ${NGINX_CONF} \
|
||||
&& make -j ${NB_CORES} \
|
||||
&& make install \
|
||||
|
||||
### GNU Libiconv installation
|
||||
&& cd /usr/src/libiconv-${LIBICONV_VERSION} \
|
||||
&& ./configure --prefix=/usr/local \
|
||||
&& make && make install && libtool --finish /usr/local/lib \
|
||||
|
||||
### PHP installation
|
||||
&& mv /usr/src/php-${PHP_VER} /usr/src/php \
|
||||
&& cd /usr/src/php \
|
||||
&& ./configure CFLAGS="-O3 -fstack-protector-strong" ${PHP_CONF} \
|
||||
&& make -j ${NB_CORES} \
|
||||
&& make install \
|
||||
|
||||
### Strip, clean, install modules
|
||||
&& { find /usr/local/bin /usr/local/sbin -type f -perm +0111 -exec strip --strip-all '{}' + || true; } \
|
||||
&& make clean \
|
||||
&& chmod u+x /usr/local/bin/* /etc/s6.d/*/* \
|
||||
&& docker-php-ext-install ${PHP_EXT_LIST} \
|
||||
&& apk del ${BUILD_DEPS} \
|
||||
&& rm -rf /tmp/* /var/cache/apk/* /usr/src/* \
|
||||
&& mkdir -p /nginx/logs /nginx/run /php/php-fpm.d /php/logs /php/run /php/session
|
2
nginx-php/7.1/rootfs/etc/s6.d/.s6-svscan/finish
Normal file
2
nginx-php/7.1/rootfs/etc/s6.d/.s6-svscan/finish
Normal file
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
exit 0
|
2
nginx-php/7.1/rootfs/etc/s6.d/nginx/run
Normal file
2
nginx-php/7.1/rootfs/etc/s6.d/nginx/run
Normal file
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
exec nginx
|
2
nginx-php/7.1/rootfs/etc/s6.d/php/run
Normal file
2
nginx-php/7.1/rootfs/etc/s6.d/php/run
Normal file
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
exec php-fpm
|
6
nginx-php/7.1/rootfs/nginx/conf.d/php.conf
Normal file
6
nginx-php/7.1/rootfs/nginx/conf.d/php.conf
Normal file
@ -0,0 +1,6 @@
|
||||
location ~ \.php$ {
|
||||
fastcgi_index index.php;
|
||||
fastcgi_pass unix:/php/run/php-fpm.sock;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
include /nginx/conf/fastcgi_params;
|
||||
}
|
31
nginx-php/7.1/rootfs/nginx/conf/nginx.conf
Normal file
31
nginx-php/7.1/rootfs/nginx/conf/nginx.conf
Normal file
@ -0,0 +1,31 @@
|
||||
worker_processes auto;
|
||||
pid /nginx/run/nginx.pid;
|
||||
daemon off;
|
||||
|
||||
events {
|
||||
worker_connections 2048;
|
||||
use epoll;
|
||||
}
|
||||
|
||||
http {
|
||||
include /nginx/conf/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
access_log /nginx/logs/access.log combined;
|
||||
error_log /nginx/logs/error.log error;
|
||||
|
||||
client_max_body_size <UPLOAD_MAX_SIZE>;
|
||||
|
||||
aio threads;
|
||||
sendfile on;
|
||||
keepalive_timeout 15;
|
||||
keepalive_disable msie6;
|
||||
keepalive_requests 100;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
server_tokens off;
|
||||
|
||||
gzip off;
|
||||
|
||||
include /nginx/sites-enabled/*.conf;
|
||||
}
|
21
nginx-php/7.1/rootfs/php/etc/php-fpm.conf
Normal file
21
nginx-php/7.1/rootfs/php/etc/php-fpm.conf
Normal file
@ -0,0 +1,21 @@
|
||||
[global]
|
||||
daemonize = no
|
||||
error_log = /php/logs/error.log
|
||||
|
||||
[www]
|
||||
listen = /php/run/php-fpm.sock
|
||||
pm = dynamic
|
||||
pm.max_children = 15
|
||||
pm.start_servers = 2
|
||||
pm.min_spare_servers = 1
|
||||
pm.max_spare_servers = 6
|
||||
chdir = /
|
||||
request_terminate_timeout = 0
|
||||
env[PATH] = /usr/local/bin:/usr/bin:/bin
|
||||
php_admin_value[post_max_size] = <UPLOAD_MAX_SIZE>
|
||||
php_admin_value[upload_max_filesize] = <UPLOAD_MAX_SIZE>
|
||||
php_admin_value[max_execution_time] = 10800
|
||||
php_admin_value[max_input_time] = 3600
|
||||
php_admin_value[expose_php] = Off
|
||||
php_admin_value[memory_limit] = <MEMORY_LIMIT>
|
||||
php_admin_value[session.save_path] = "/php/session"
|
19
nginx-php/7.1/rootfs/usr/local/bin/docker-php-ext-configure
Normal file
19
nginx-php/7.1/rootfs/usr/local/bin/docker-php-ext-configure
Normal file
@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
ext="$1"
|
||||
extDir="/usr/src/php/ext/$ext"
|
||||
if [ -z "$ext" ] || ! [ -d "$extDir" ]; then
|
||||
echo >&2 "usage: $0 ext-name [configure flags]"
|
||||
echo >&2 " ie: $0 gd --with-jpeg-dir=/usr/local/something"
|
||||
echo >&2
|
||||
echo >&2 'Possible values for ext-name:'
|
||||
echo >&2 $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)
|
||||
exit 1
|
||||
fi
|
||||
shift
|
||||
|
||||
set -x
|
||||
cd "$extDir"
|
||||
phpize
|
||||
./configure "$@"
|
83
nginx-php/7.1/rootfs/usr/local/bin/docker-php-ext-enable
Normal file
83
nginx-php/7.1/rootfs/usr/local/bin/docker-php-ext-enable
Normal file
@ -0,0 +1,83 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
cd "$(php -r 'echo ini_get("extension_dir");')"
|
||||
|
||||
usage() {
|
||||
echo "usage: $0 [options] module-name [module-name ...]"
|
||||
echo " ie: $0 gd mysqli"
|
||||
echo " $0 pdo pdo_mysql"
|
||||
echo " $0 --ini-name 0-apc.ini apcu apc"
|
||||
echo
|
||||
echo 'Possible values for module-name:'
|
||||
echo $(find -maxdepth 1 -type f -name '*.so' -exec basename '{}' ';' | sort)
|
||||
}
|
||||
|
||||
opts="$(getopt -o 'h?' --long 'help,ini-name:' -- "$@" || { usage >&2 && false; })"
|
||||
eval set -- "$opts"
|
||||
|
||||
iniName=
|
||||
while true; do
|
||||
flag="$1"
|
||||
shift
|
||||
case "$flag" in
|
||||
--help|-h|'-?') usage && exit 0 ;;
|
||||
--ini-name) iniName="$1" && shift ;;
|
||||
--) break ;;
|
||||
*)
|
||||
{
|
||||
echo "error: unknown flag: $flag"
|
||||
usage
|
||||
} >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
modules=
|
||||
for module; do
|
||||
if [ -z "$module" ]; then
|
||||
continue
|
||||
fi
|
||||
if [ -f "$module.so" ] && ! [ -f "$module" ]; then
|
||||
# allow ".so" to be optional
|
||||
module="$module.so"
|
||||
fi
|
||||
if ! [ -f "$module" ]; then
|
||||
echo >&2 "error: $(readlink -f "$module") does not exist"
|
||||
echo >&2
|
||||
usage >&2
|
||||
exit 1
|
||||
fi
|
||||
modules="$modules $module"
|
||||
done
|
||||
|
||||
if [ -z "$modules" ]; then
|
||||
usage >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for module in $modules; do
|
||||
if nm -g "$module" | grep -q ' zend_extension_entry$'; then
|
||||
# https://wiki.php.net/internals/extensions#loading_zend_extensions
|
||||
line="zend_extension=$(readlink -f "$module")"
|
||||
else
|
||||
line="extension=$module"
|
||||
fi
|
||||
|
||||
ext="$(basename "$module")"
|
||||
ext="${ext%.*}"
|
||||
if php -r 'exit(extension_loaded("'"$ext"'") ? 0 : 1);'; then
|
||||
# this isn't perfect, but it's better than nothing
|
||||
# (for example, 'opcache.so' presents inside PHP as 'Zend OPcache', not 'opcache')
|
||||
echo >&2
|
||||
echo >&2 "warning: $ext ($module) is already loaded!"
|
||||
echo >&2
|
||||
continue
|
||||
fi
|
||||
|
||||
ini="/php/conf.d/${iniName:-"docker-php-ext-$ext.ini"}"
|
||||
if ! grep -q "$line" "$ini" 2>/dev/null; then
|
||||
echo "$line" >> "$ini"
|
||||
fi
|
||||
done
|
71
nginx-php/7.1/rootfs/usr/local/bin/docker-php-ext-install
Normal file
71
nginx-php/7.1/rootfs/usr/local/bin/docker-php-ext-install
Normal file
@ -0,0 +1,71 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
cd /usr/src/php/ext
|
||||
|
||||
usage() {
|
||||
echo "usage: $0 [-jN] ext-name [ext-name ...]"
|
||||
echo " ie: $0 gd mysqli"
|
||||
echo " $0 pdo pdo_mysql"
|
||||
echo " $0 -j5 gd mbstring mysqli pdo pdo_mysql shmop"
|
||||
echo
|
||||
echo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'
|
||||
echo
|
||||
echo 'Possible values for ext-name:'
|
||||
echo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)
|
||||
}
|
||||
|
||||
opts="$(getopt -o 'h?j:' --long 'help,jobs:' -- "$@" || { usage >&2 && false; })"
|
||||
eval set -- "$opts"
|
||||
|
||||
j=1
|
||||
while true; do
|
||||
flag="$1"
|
||||
shift
|
||||
case "$flag" in
|
||||
--help|-h|'-?') usage && exit 0 ;;
|
||||
--jobs|-j) j="$1" && shift ;;
|
||||
--) break ;;
|
||||
*)
|
||||
{
|
||||
echo "error: unknown flag: $flag"
|
||||
usage
|
||||
} >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
exts=
|
||||
for ext; do
|
||||
if [ -z "$ext" ]; then
|
||||
continue
|
||||
fi
|
||||
if [ ! -d "$ext" ]; then
|
||||
echo >&2 "error: $(pwd -P)/$ext does not exist"
|
||||
echo >&2
|
||||
usage >&2
|
||||
exit 1
|
||||
fi
|
||||
exts="$exts $ext"
|
||||
done
|
||||
|
||||
if [ -z "$exts" ]; then
|
||||
usage >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for ext in $exts; do
|
||||
(
|
||||
cd "$ext"
|
||||
[ -e Makefile ] || docker-php-ext-configure "$ext"
|
||||
make -j"$j"
|
||||
make -j"$j" install
|
||||
find modules \
|
||||
-maxdepth 1 \
|
||||
-name '*.so' \
|
||||
-exec basename '{}' ';' \
|
||||
| xargs -r docker-php-ext-enable
|
||||
make -j"$j" clean
|
||||
)
|
||||
done
|
Reference in New Issue
Block a user