Skip to content

Commit

Permalink
PHP 7.2 support
Browse files Browse the repository at this point in the history
[FEATURE] Initial PHP 7.2 images

    Add `docker/php-official/7.2` directory which is
    mostly a duplicate of `docker/php-official/7.1` and
    generated Dockerfile.

    Symlinked docker/php/7.2 to newly added on (see above).

    Add `docker/php-dev/7.2` directory which is
    mostly a duplicate of `docker/php-dev/7.1` and
    generated Dockerfile.

    Add `docker/php-apache/7.2` directory which is
    mostly a duplicate of `docker/php-apache/7.1` and
    generated Dockerfile.

    Add `docker/php-apache-dev/7.2` directory which is
    mostly a duplicate of `docker/php-apache-dev/7.1` and
    generated Dockerfile.

    Add `docker/php-nginx/7.2` directory which is
    mostly a duplicate of `docker/php-nginx/7.1` and
    generated Dockerfile.

    All „Dockerfile“ files in this commit are auto generated
    by running `./bin/console generate:dockerfile`.

    Related: webdevops#211
  • Loading branch information
mblaschke committed Dec 6, 2017
1 parent d3e141c commit 3f77073
Show file tree
Hide file tree
Showing 181 changed files with 3,845 additions and 0 deletions.
32 changes: 32 additions & 0 deletions docker/php-apache-dev/7.2/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#+++++++++++++++++++++++++++++++++++++++
# Dockerfile for webdevops/php-apache-dev:7.2
# -- automatically generated --
#+++++++++++++++++++++++++++++++++++++++

FROM webdevops/php-apache:7.2

ENV WEB_DOCUMENT_ROOT=/app \
WEB_DOCUMENT_INDEX=index.php \
WEB_ALIAS_DOMAIN=*.vm \
WEB_PHP_TIMEOUT=600 \
WEB_PHP_SOCKET=""
ENV WEB_PHP_SOCKET=127.0.0.1:9000
ENV WEB_NO_CACHE_PATTERN="\.(css|js|gif|png|jpg|svg|json|xml)$"

COPY conf/ /opt/docker/

RUN set -x \
# Install development environment
&& wget -O - https://packagecloud.io/gpg.key | apt-key add - \
&& echo "deb https://packages.blackfire.io/debian any main" | tee /etc/apt/sources.list.d/blackfire.list \
&& apt-install \
blackfire-php \
blackfire-agent \
&& pecl install xdebug \
&& echo "zend_extension=xdebug.so" > /usr/local/etc/php/conf.d/xdebug.ini \
# Enable php development services
&& docker-service enable syslog \
&& docker-service enable postfix \
&& docker-service enable ssh \
&& docker-run-bootstrap \
&& docker-image-cleanup
12 changes: 12 additions & 0 deletions docker/php-apache-dev/7.2/Dockerfile.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{ docker.from("php-apache", "7.2") }}

{{ environment.web() }}
{{ environment.webPhp() }}
{{ environment.webDevelopment() }}

{{ docker.copy('conf/', '/opt/docker/') }}

RUN set -x \
{{ php.officialDevelopment(version="7.1") }} \
{{ provision.runBootstrap() }} \
{{ docker.cleanup() }}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# placeholder
25 changes: 25 additions & 0 deletions docker/php-apache-dev/7.2/conf/bin/service.d/blackfire-agent.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

# Init vars
if [[ -z "$SERVICE_BLACKFIRE_AGENT_OPTS" ]]; then SERVICE_BLACKFIRE_AGENT_OPTS=""; fi

source /opt/docker/bin/config.sh

BLACKFIRE_ARGS=""

includeScriptDir "/opt/docker/bin/service.d/syslog-ng.d/"

# blackfire.server_id
if [[ -n "${BLACKFIRE_SERVER_ID+x}" ]]; then
BLACKFIRE_ARGS="$BLACKFIRE_ARGS --server-id=\"${BLACKFIRE_SERVER_ID}\""
fi

# blackfire.server_token
if [[ -n "${BLACKFIRE_SERVER_TOKEN+x}" ]]; then
BLACKFIRE_ARGS="$BLACKFIRE_ARGS --server-token=\"${BLACKFIRE_SERVER_TOKEN}\""
fi

# create directory for unix socket
mkdir -p /var/run/blackfire

eval exec blackfire-agent $BLACKFIRE_ARGS $SERVICE_BLACKFIRE_AGENT_OPTS
8 changes: 8 additions & 0 deletions docker/php-apache-dev/7.2/conf/etc/httpd/conf.d/02-dev.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# EnableSendfile: Control whether the sendfile kernel support is
# used to deliver files (assuming that the OS supports it).
# The default is on; turn this off if you serve from NFS-mounted
# filesystems. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#enablesendfile
EnableSendfile off

LogLevel info
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<FilesMatch "<WEB_NO_CACHE_PATTERN>">
FileETag None

<ifModule mod_headers.c>
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</ifModule>
</FilesMatch>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[group:blackfire-agent]
programs=blackfire-agentd
priority=25

[program:blackfire-agentd]
command = /opt/docker/bin/service.d/blackfire-agent.sh
process_name=%(program_name)s
startsecs = 0
autostart = false
autorestart = true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
24 changes: 24 additions & 0 deletions docker/php-apache-dev/7.2/conf/provision/bootstrap.d/10-php.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

PHP_VERSION=$(php -r 'echo phpversion();' | cut -d '-' -f 1)

# Configure php-fpm
go-replace --mode=lineinfile --regex \
-s '^[\s;]*access.format[\s]*=' -r 'access.format = "%R - %u %t \"%m %r%Q%q\" %s %f cpu:%C%% mem:%{megabytes}M reqTime:%d"' \
-- /opt/docker/etc/php/fpm/pool.d/application.conf

if [[ "$(version-compare "$PHP_VERSION" "5.5.999")" == "<" ]]; then
# listen on public IPv4 port
# no ipv6 sockets available for old php version
go-replace --mode=line --regex \
-s '^[\s;]*listen[\s]*=' -r 'listen = 0.0.0.0:9000' \
-- /opt/docker/etc/php/fpm/pool.d/application.conf \
/opt/docker/etc/php/fpm/php-fpm.conf
else
# listen on public IPv6 port
go-replace --mode=line --regex \
-s '^[\s;]*listen[\s]*=' -r 'listen = [::]:9000' \
-- /opt/docker/etc/php/fpm/pool.d/application.conf \
/opt/docker/etc/php/fpm/php-fpm.conf

fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

# Disable blackfire by default
rm -f \
/etc/php5/cli/conf.d/zz-blackfire.ini \
/etc/php5/fpm/conf.d/zz-blackfire.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

# Configure opcache for development
go-replace --mode=lineinfile --regex \
-s '^[\s;]*opcache.memory_consumption[\s]*=' -r 'opcache.memory_consumption = 256' \
-s '^[\s;]*opcache.validate_timestamps[\s]*=' -r 'opcache.validate_timestamps = 1' \
-s '^[\s;]*opcache.revalidate_freq[\s]*=' -r 'opcache.revalidate_freq = 0' \
-s '^[\s;]*opcache.interned_strings_buffer[\s]*=' -r 'opcache.interned_strings_buffer = 16' \
-s '^[\s;]*opcache.max_accelerated_files[\s]*=' -r 'opcache.max_accelerated_files = 7963' \
-s '^[\s;]*opcache.fast_shutdown[\s]*=' -r 'opcache.fast_shutdown = 1' \
-- /opt/docker/etc/php/php.webdevops.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

IMAGE_FAMILY=$(docker-image-info family)

case "$IMAGE_FAMILY" in
Alpine)
# Fix php xdebug module [Alpine family]

if [[ -f "/etc/php5/conf.d/xdebug.ini" ]]; then
go-replace --mode=lineinfile \
-s '^extension=xdebug.so' -r 'zend_extension=xdebug.so' \
/etc/php5/conf.d/xdebug.ini
fi

if [[ -f "/etc/php7/conf.d/xdebug.ini" ]]; then
go-replace --mode=lineinfile \
-s '^extension=xdebug.so' -r 'zend_extension=xdebug.so' \
/etc/php7/conf.d/xdebug.ini
fi

;;
esac

# Configure xdebug for development
go-replace --mode=lineinfile --regex \
-s '^[\s;]*xdebug.remote_enable[\s]*=' -r 'xdebug.remote_enable = 1' \
-s '^[\s;]*xdebug.remote_connect_back[\s]*=' -r 'xdebug.remote_connect_back = 1' \
-s '^[\s;]*xdebug.idekey[\s]*=' -r 'xdebug.idekey = docker' \
-s '^[\s;]*xdebug.cli_color[\s]*=' -r 'xdebug.cli_color = 1' \
-s '^[\s;]*xdebug.max_nesting_level[\s]*=' -r 'xdebug.max_nesting_level = 1000' \
-s '^[\s;]*xdebug.profiler_enable_trigger[\s]*=' -r 'xdebug.profiler_enable_trigger = 1000' \
-s '^[\s;]*xdebug.profiler_output_dir[\s]*=' -r 'xdebug.profiler_output_dir = /tmp/debug' \
-s '^[\s;]*xdebug.output_dir[\s]*=' -r 'xdebug.output_dir = /tmp/debug' \
-- /opt/docker/etc/php/php.webdevops.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/usr/bin/env bash

#################################################
# Debugger switch
#################################################

PHP_CONF_PATHS="
/etc/php5/conf.d
/etc/php7/conf.d
/etc/php.d
/etc/php5/mods-available
/etc/php5/cli/conf.d
/etc/php5/cli/conf.d
/etc/php5/fpm/conf.d
/etc/php5/fpm/conf.d
/etc/php/7.0/mods-available
/etc/php/7.0/cli/conf.d
/etc/php/7.0/fpm/conf.d
/usr/local/etc/php/conf.d/"

function phpModuleRemove() {
if [ "$#" -ne 1 ]; then
echo "You must specify the name of the PHP module which you want to disable"
exit 1
fi

echo " - Removing PHP module ${1}"
for CONF_PATH in $PHP_CONF_PATHS; do
rm -f "${CONF_PATH}"/*"${1}".ini
done
}


if [[ -n "${PHP_DEBUGGER+x}" ]]; then
case "$PHP_DEBUGGER" in
xdebug)
echo "PHP-Debugger: Xdebug enabled"
phpModuleRemove "blackfire"
;;

blackfire)
echo "PHP-Debugger: Blackfire enabled"
phpModuleRemove "xdebug"
docker-service-enable blackfire-agent
;;

none)
echo "PHP-Debugger: none"
phpModuleRemove "blackfire"
phpModuleRemove "xdebug"
;;
esac

else

echo "PHP-Debugger: not specified - default is xdebug"
phpModuleRemove "blackfire"

fi

#################################################
# PHP debugger environment variables
#################################################

function phpEnvironmentVariable() {
PHP_INI_KEY="$1"
PHP_ENV_NAME="$2"

if [[ -n "${!PHP_ENV_NAME+x}" ]]; then
PHP_ENV_VALUE="${!PHP_ENV_NAME}"
echo "${PHP_INI_KEY}=\"${PHP_ENV_VALUE}\"" >> /opt/docker/etc/php/php.ini
fi
}

###################
# XDEBUG
###################

# remote debugger
phpEnvironmentVariable "xdebug.remote_connect_back" "XDEBUG_REMOTE_CONNECT_BACK"
phpEnvironmentVariable "xdebug.remote_autostart" "XDEBUG_REMOTE_AUTOSTART"
phpEnvironmentVariable "xdebug.remote_host" "XDEBUG_REMOTE_HOST"
phpEnvironmentVariable "xdebug.remote_port" "XDEBUG_REMOTE_PORT"

# profiler
phpEnvironmentVariable "xdebug.profiler_enable" "XDEBUG_PROFILER_ENABLE"
phpEnvironmentVariable "xdebug.profiler_enable_trigger" "XDEBUG_PROFILER_ENABLE_TRIGGER"
phpEnvironmentVariable "xdebug.profiler_enable_trigger_value" "XDEBUG_PROFILER_ENABLE_TRIGGER_VALUE"
phpEnvironmentVariable "xdebug.profiler_output_dir" "XDEBUG_PROFILER_OUTPUT_DIR"
phpEnvironmentVariable "xdebug.profiler_output_name" "XDEBUG_PROFILER_OUTPUT_NAME"

###################
# BLACKFIRE
###################
phpEnvironmentVariable "blackfire.server_id" "BLACKFIRE_SERVER_ID"
phpEnvironmentVariable "blackfire.server_token" "BLACKFIRE_SERVER_TOKEN"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
go-replace \
-s "<WEB_NO_CACHE_PATTERN>" -r "$WEB_NO_CACHE_PATTERN" \
--path=/opt/docker/etc/httpd/ \
--path-pattern='*.conf' \
--ignore-empty
33 changes: 33 additions & 0 deletions docker/php-apache/7.2/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#+++++++++++++++++++++++++++++++++++++++
# Dockerfile for webdevops/php-apache:7.2
# -- automatically generated --
#+++++++++++++++++++++++++++++++++++++++

FROM webdevops/php:7.2

ENV WEB_DOCUMENT_ROOT=/app \
WEB_DOCUMENT_INDEX=index.php \
WEB_ALIAS_DOMAIN=*.vm \
WEB_PHP_TIMEOUT=600 \
WEB_PHP_SOCKET=""
ENV WEB_PHP_SOCKET=127.0.0.1:9000

COPY conf/ /opt/docker/

RUN set -x \
# Install apache
&& apt-install \
apache2 \
apache2-mpm-worker \
&& sed -ri ' \
s!^(\s*CustomLog)\s+\S+!\1 /proc/self/fd/1!g; \
s!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g; \
' /etc/apache2/apache2.conf \
&& rm -f /etc/apache2/sites-enabled/* \
&& a2enmod actions proxy proxy_fcgi ssl rewrite headers expires \
&& docker-run-bootstrap \
&& docker-image-cleanup \
&& docker-run-bootstrap \
&& docker-image-cleanup

EXPOSE 80 443
13 changes: 13 additions & 0 deletions docker/php-apache/7.2/Dockerfile.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{ docker.from("php", "7.2") }}

{{ environment.web() }}
{{ environment.webPhp() }}

{{ docker.copy('conf/', '/opt/docker/') }}

RUN set -x \
{{ apache.debian8() }} \
{{ provision.runBootstrap() }} \
{{ docker.cleanup() }}

{{ docker.expose('80 443') }}
6 changes: 6 additions & 0 deletions docker/php-apache/7.2/conf/bin/service.d/httpd.d/10-init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
if [[ ! -e "$WEB_DOCUMENT_ROOT" ]]; then
echo ""
echo "[WARNING] WEB_DOCUMENT_ROOT does not exists with path \"$WEB_DOCUMENT_ROOT\"!"
echo ""
fi

14 changes: 14 additions & 0 deletions docker/php-apache/7.2/conf/bin/service.d/httpd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

# Init vars
if [[ -z "$SERVICE_APACHE_OPTS" ]]; then SERVICE_APACHE_OPTS=""; fi

source /opt/docker/bin/config.sh

includeScriptDir "/opt/docker/bin/service.d/httpd.d/"

# Apache gets grumpy about PID files pre-existing
rm -f /var/run/apache2/apache2*.pid

source /etc/apache2/envvars
exec apache2 -DFOREGROUND -DAPACHE_LOCK_DIR $SERVICE_APACHE_OPTS
Empty file.
15 changes: 15 additions & 0 deletions docker/php-apache/7.2/conf/etc/httpd/conf.d/10-error-document.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#######################################
# Faster error documents
#######################################
<Location ~ "(\.jpeg|\.jpg|\.gif|\.png|\.ico|\.js|\.css|\.map|\.json|\.xml|robots\.txt)$">
ErrorDocument 400 "400 Bad Request"
ErrorDocument 401 "401 Unauthorized"
ErrorDocument 403 "403 Forbidden"
ErrorDocument 404 "404 Not Found"
ErrorDocument 405 "405 Method Not Allowed"

ErrorDocument 500 "500 Internal Server Error"
ErrorDocument 501 "501 Not Implemented"
ErrorDocument 502 "502 Bad Gateway"
ErrorDocument 503 "503 Service Unavailable"
</Location>
4 changes: 4 additions & 0 deletions docker/php-apache/7.2/conf/etc/httpd/conf.d/10-log.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
LogFormat "[httpd:access] %V:%p %h %l %u %t \"%r\" %>s bytesIn:%I bytesOut:%O reqTime:%T" dockerlog
LogLevel warn
CustomLog /docker.stdout dockerlog
ErrorLog /docker.stderr
Loading

0 comments on commit 3f77073

Please sign in to comment.