From 716e682dfa07b09a59963ed1dccb7f983e52a439 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Tue, 29 Dec 2015 19:53:06 +0100 Subject: [PATCH 01/31] Removes useless iconv install (already enabled by base image) --- Dockerfile | 3 --- 1 file changed, 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index c962853..ef821cc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,9 +7,6 @@ RUN apt-get update \ && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \ && docker-php-ext-install gd -# Install Iconv -RUN docker-php-ext-install iconv - # Install MCrypt RUN apt-get update \ && apt-get install -y libmcrypt-dev \ From 2845ac5d3b500a1a52825bfda3c57fa16c2cb20d Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Tue, 29 Dec 2015 19:53:30 +0100 Subject: [PATCH 02/31] Adds pdo_mysql ext installation --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ef821cc..439c91e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,7 @@ RUN pecl install -o -f xdebug \ && echo "zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so" > /usr/local/etc/php/conf.d/xdebug.ini # Install Mysql -RUN docker-php-ext-install mysql mysqli +RUN docker-php-ext-install mysql mysqli pdo_mysql COPY ./index.php /var/www/html/index.php From 5fd9a3d4d44fd851d89d57e02628289a3cb7e607 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Wed, 30 Dec 2015 19:18:41 +0100 Subject: [PATCH 03/31] Adds the ability to set Apache document root via env variable --- Dockerfile | 6 +++++- docker-entrypoint | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100755 docker-entrypoint diff --git a/Dockerfile b/Dockerfile index 439c91e..c4d2838 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,6 +25,10 @@ RUN pecl install -o -f xdebug \ # Install Mysql RUN docker-php-ext-install mysql mysqli pdo_mysql -COPY ./index.php /var/www/html/index.php +# Configure Apache Document Root +ENV APACHE_DOC_ROOT /var/www/html +COPY ./docker-entrypoint /usr/local/bin/ +COPY ./index.php /var/www/html/index.php +ENTRYPOINT ["docker-entrypoint"] diff --git a/docker-entrypoint b/docker-entrypoint new file mode 100755 index 0000000..d44b82c --- /dev/null +++ b/docker-entrypoint @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -e + +sed -i "s|DocumentRoot /var/www/html|DocumentRoot $APACHE_DOC_ROOT|" /etc/apache2/sites-available/000-default.conf +sed -i "s|DocumentRoot /var/www/html|DocumentRoot $APACHE_DOC_ROOT|" /etc/apache2/apache2.conf + +apache2-foreground From 5fac2d4c9ac6867ecdc3ca65bd362a5c19d12948 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Fri, 1 Jan 2016 18:11:21 +0100 Subject: [PATCH 04/31] Adds php 5.5 tag --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index c4d2838..f6fa61a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM php:5.6-apache +FROM php:5.5-apache MAINTAINER Webgriffe Srl # Install GD @@ -20,7 +20,7 @@ RUN apt-get update \ # Install XDebug RUN pecl install -o -f xdebug \ && rm -rf /tmp/pear \ - && echo "zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so" > /usr/local/etc/php/conf.d/xdebug.ini + && docker-php-ext-enable xdebug # Install Mysql RUN docker-php-ext-install mysql mysqli pdo_mysql From 3620bd8116705ff8ec577362e20b9713f18a06ea Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Fri, 1 Jan 2016 18:27:07 +0100 Subject: [PATCH 05/31] Fix entrypoint / cmd issue --- Dockerfile | 1 + docker-entrypoint | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index f6fa61a..e04428e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,3 +32,4 @@ COPY ./docker-entrypoint /usr/local/bin/ COPY ./index.php /var/www/html/index.php ENTRYPOINT ["docker-entrypoint"] +CMD ["apache2-foreground"] diff --git a/docker-entrypoint b/docker-entrypoint index d44b82c..fe15868 100755 --- a/docker-entrypoint +++ b/docker-entrypoint @@ -5,4 +5,4 @@ set -e sed -i "s|DocumentRoot /var/www/html|DocumentRoot $APACHE_DOC_ROOT|" /etc/apache2/sites-available/000-default.conf sed -i "s|DocumentRoot /var/www/html|DocumentRoot $APACHE_DOC_ROOT|" /etc/apache2/apache2.conf -apache2-foreground +exec "$@" From 9395a6e2b4af3b335573b7a6b44183caf92e6dee Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Fri, 1 Jan 2016 18:35:47 +0100 Subject: [PATCH 06/31] Adds mbstring install --- Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile b/Dockerfile index e04428e..08512d9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,6 +25,9 @@ RUN pecl install -o -f xdebug \ # Install Mysql RUN docker-php-ext-install mysql mysqli pdo_mysql +# Install mbstring +RUN docker-php-ext-install mbstring + # Configure Apache Document Root ENV APACHE_DOC_ROOT /var/www/html COPY ./docker-entrypoint /usr/local/bin/ From 373afaa9d4931adc9090b3791fd4878372f90a15 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Fri, 1 Jan 2016 18:37:43 +0100 Subject: [PATCH 07/31] Adds soap install --- Dockerfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Dockerfile b/Dockerfile index 08512d9..4758244 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,6 +28,11 @@ RUN docker-php-ext-install mysql mysqli pdo_mysql # Install mbstring RUN docker-php-ext-install mbstring +# Install soap +RUN apt-get update \ + && apt-get install -y libxml2-dev \ + && docker-php-ext-install soap + # Configure Apache Document Root ENV APACHE_DOC_ROOT /var/www/html COPY ./docker-entrypoint /usr/local/bin/ From 575905d94e26d0782a66981181910b9907082238 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Fri, 1 Jan 2016 18:39:54 +0100 Subject: [PATCH 08/31] Adds opcache install --- Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile b/Dockerfile index 4758244..3ed4324 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,6 +33,9 @@ RUN apt-get update \ && apt-get install -y libxml2-dev \ && docker-php-ext-install soap +# Install opcache +RUN docker-php-ext-install opcache + # Configure Apache Document Root ENV APACHE_DOC_ROOT /var/www/html COPY ./docker-entrypoint /usr/local/bin/ From 8c2d1799a5cfd792a66046f17a80cdbb0a9b41e0 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Fri, 1 Jan 2016 18:57:58 +0100 Subject: [PATCH 09/31] Allows to set php timezone via env var (default is Rome) --- Dockerfile | 3 +++ docker-entrypoint | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/Dockerfile b/Dockerfile index 3ed4324..e8268c1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,6 +36,9 @@ RUN apt-get update \ # Install opcache RUN docker-php-ext-install opcache +# Define PHP_TIMEZONE env variable +ENV PHP_TIMEZONE Europe/Rome + # Configure Apache Document Root ENV APACHE_DOC_ROOT /var/www/html COPY ./docker-entrypoint /usr/local/bin/ diff --git a/docker-entrypoint b/docker-entrypoint index fe15868..3bb47c1 100755 --- a/docker-entrypoint +++ b/docker-entrypoint @@ -2,6 +2,10 @@ set -e +# Configure PHP date.timezone +echo "date.timezone = $PHP_TIMEZONE" > /usr/local/etc/php/conf.d/timezone.ini + +# Configure Apache Document Root sed -i "s|DocumentRoot /var/www/html|DocumentRoot $APACHE_DOC_ROOT|" /etc/apache2/sites-available/000-default.conf sed -i "s|DocumentRoot /var/www/html|DocumentRoot $APACHE_DOC_ROOT|" /etc/apache2/apache2.conf From b453c5bb6c51c54683219ea48f316c5ebcb2d66d Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Fri, 1 Jan 2016 19:29:32 +0100 Subject: [PATCH 10/31] Enables apache mod rewrite --- Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile b/Dockerfile index e8268c1..cdb15df 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,6 +43,9 @@ ENV PHP_TIMEZONE Europe/Rome ENV APACHE_DOC_ROOT /var/www/html COPY ./docker-entrypoint /usr/local/bin/ +# Enable Apache mod_rewrite +RUN a2enmod rewrite + COPY ./index.php /var/www/html/index.php ENTRYPOINT ["docker-entrypoint"] From 3599802ad5fda4d23b397f3aab67260c3397aee8 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Sat, 2 Jan 2016 17:49:31 +0100 Subject: [PATCH 11/31] Adds additional php ini configuration --- 999-php.ini | 2 ++ Dockerfile | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 999-php.ini diff --git a/999-php.ini b/999-php.ini new file mode 100644 index 0000000..7b69ed7 --- /dev/null +++ b/999-php.ini @@ -0,0 +1,2 @@ +memory_limit = -1 +error_reporting = E_ALL | E_STRICT diff --git a/Dockerfile b/Dockerfile index cdb15df..3c42c98 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,6 +46,9 @@ COPY ./docker-entrypoint /usr/local/bin/ # Enable Apache mod_rewrite RUN a2enmod rewrite +# Additional PHP ini configuration +COPY ./999-php.ini /usr/local/etc/php/conf.d/ + COPY ./index.php /var/www/html/index.php ENTRYPOINT ["docker-entrypoint"] From 0c4b25dc80e939f70fed7365fc97db6698953d25 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Fri, 1 Jan 2016 19:54:10 +0100 Subject: [PATCH 12/31] Improves README.md --- README.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1c87070..171aadf 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,29 @@ Base PHP with Apache Docker Container ===================================== -Base Docker Container for PHP web development. Apache webserver integrated. +Dockerized environment for PHP web development and Apache web server. + +Features +-------- + +* Ability to set Apache document root through `APACHE_DOC_ROOT` environment variable. Default document root is `/var/www/html` +* Enabled Apache modules: rewrite +* Ability to set PHP `date.timezone` through `PHP_TIMEZONE` environment variable. Default timezone is `Europe/Rome` +* Enabled PHP extensions: gd, mcrypt, intl, xdebug, mysql, mysqli, pdo_mysql, mbstring, soap, opcache +* Composer installed globally at `/usr/local/bin/composer` + +Usage +----- + +Standalone usage example with host's current working directory as document root: + + $ docker run -p 80:80 -v $(pwd):/var/www/html webgriffe/php-apache-base + +Credits +------- + +[Webgriffe®](http://www.webgriffe.com/) + + + From 1ebb391e34adf032e3762c68048493325c3f1aed Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Sat, 2 Jan 2016 18:26:42 +0100 Subject: [PATCH 13/31] Sets xdebug for remote debugging --- 999-php.ini | 13 +++++++++++++ README.md | 1 + docker-entrypoint | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/999-php.ini b/999-php.ini index 7b69ed7..6aa060e 100644 --- a/999-php.ini +++ b/999-php.ini @@ -1,2 +1,15 @@ memory_limit = -1 error_reporting = E_ALL | E_STRICT + +[xdebug] +xdebug.remote_enable=on +xdebug.default_enable=on +xdebug.remote_autostart=off +xdebug.remote_port=9000 +xdebug.profiler_enable_trigger=1 +xdebug.profiler_output_name=xdebug-profile-cachegrind.out-%H-%R +xdebug.var_display_max_children = 128 +xdebug.var_display_max_data = 2048 +xdebug.var_display_max_depth = 128 +xdebug.max_nesting_level = 200 +xdebug.coverage_enable = 1 diff --git a/README.md b/README.md index 171aadf..8d9d7d3 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ Features * Ability to set PHP `date.timezone` through `PHP_TIMEZONE` environment variable. Default timezone is `Europe/Rome` * Enabled PHP extensions: gd, mcrypt, intl, xdebug, mysql, mysqli, pdo_mysql, mbstring, soap, opcache * Composer installed globally at `/usr/local/bin/composer` +* Ability to set xdebug.remote_enable setting through `HOST_IP` environment variable. Usage ----- diff --git a/docker-entrypoint b/docker-entrypoint index 3bb47c1..2ca6967 100755 --- a/docker-entrypoint +++ b/docker-entrypoint @@ -9,4 +9,11 @@ echo "date.timezone = $PHP_TIMEZONE" > /usr/local/etc/php/conf.d/timezone.ini sed -i "s|DocumentRoot /var/www/html|DocumentRoot $APACHE_DOC_ROOT|" /etc/apache2/sites-available/000-default.conf sed -i "s|DocumentRoot /var/www/html|DocumentRoot $APACHE_DOC_ROOT|" /etc/apache2/apache2.conf +# Configure XDebug remote host +if [ -z "$HOST_IP" ]; then + # Allows to set HOST_IP by env variable because could be different from the one which come from ip route command + HOST_IP=$(/sbin/ip route|awk '/default/ { print $3 }') +fi; +echo "xdebug.remote_host=$HOST_IP" > /usr/local/etc/php/conf.d/xdebug_remote_host.ini + exec "$@" From 60e32d89982c601a8c8b862f7c12a21f32db93cc Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Sun, 3 Jan 2016 19:25:42 +0100 Subject: [PATCH 14/31] Sets xdebug disabled by default. Enabled with XDEBUG_ENABLE env var. --- 99-xdebug.ini.disabled | 12 ++++++++++++ 999-php.ini | 13 ------------- Dockerfile | 5 +++-- README.md | 4 +++- docker-entrypoint | 15 ++++++++++----- 5 files changed, 28 insertions(+), 21 deletions(-) create mode 100644 99-xdebug.ini.disabled diff --git a/99-xdebug.ini.disabled b/99-xdebug.ini.disabled new file mode 100644 index 0000000..e1a5731 --- /dev/null +++ b/99-xdebug.ini.disabled @@ -0,0 +1,12 @@ +[xdebug] +xdebug.remote_enable=on +xdebug.default_enable=on +xdebug.remote_autostart=off +xdebug.remote_port=9000 +xdebug.profiler_enable_trigger=1 +xdebug.profiler_output_name=xdebug-profile-cachegrind.out-%H-%R +xdebug.var_display_max_children = 128 +xdebug.var_display_max_data = 2048 +xdebug.var_display_max_depth = 128 +xdebug.max_nesting_level = 200 +xdebug.coverage_enable = 1 diff --git a/999-php.ini b/999-php.ini index 6aa060e..7b69ed7 100644 --- a/999-php.ini +++ b/999-php.ini @@ -1,15 +1,2 @@ memory_limit = -1 error_reporting = E_ALL | E_STRICT - -[xdebug] -xdebug.remote_enable=on -xdebug.default_enable=on -xdebug.remote_autostart=off -xdebug.remote_port=9000 -xdebug.profiler_enable_trigger=1 -xdebug.profiler_output_name=xdebug-profile-cachegrind.out-%H-%R -xdebug.var_display_max_children = 128 -xdebug.var_display_max_data = 2048 -xdebug.var_display_max_depth = 128 -xdebug.max_nesting_level = 200 -xdebug.coverage_enable = 1 diff --git a/Dockerfile b/Dockerfile index 3c42c98..722af7d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,9 +18,10 @@ RUN apt-get update \ && docker-php-ext-install intl # Install XDebug +ENV XDEBUG_ENABLE 0 RUN pecl install -o -f xdebug \ - && rm -rf /tmp/pear \ - && docker-php-ext-enable xdebug + && rm -rf /tmp/pear +COPY ./99-xdebug.ini.disabled /usr/local/etc/php/conf.d/ # Install Mysql RUN docker-php-ext-install mysql mysqli pdo_mysql diff --git a/README.md b/README.md index 8d9d7d3..bc232a9 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,10 @@ Features * Ability to set Apache document root through `APACHE_DOC_ROOT` environment variable. Default document root is `/var/www/html` * Enabled Apache modules: rewrite * Ability to set PHP `date.timezone` through `PHP_TIMEZONE` environment variable. Default timezone is `Europe/Rome` -* Enabled PHP extensions: gd, mcrypt, intl, xdebug, mysql, mysqli, pdo_mysql, mbstring, soap, opcache +* Enabled PHP extensions: gd, mcrypt, intl, mysql, mysqli, pdo_mysql, mbstring, soap, opcache * Composer installed globally at `/usr/local/bin/composer` +* Xdebug PHP extension installed but not enabled +* Ability to enable xdebug PHP extension through `XDEBUG_ENABLE` environment variable which has to be set to `1` * Ability to set xdebug.remote_enable setting through `HOST_IP` environment variable. Usage diff --git a/docker-entrypoint b/docker-entrypoint index 2ca6967..b12e067 100755 --- a/docker-entrypoint +++ b/docker-entrypoint @@ -9,11 +9,16 @@ echo "date.timezone = $PHP_TIMEZONE" > /usr/local/etc/php/conf.d/timezone.ini sed -i "s|DocumentRoot /var/www/html|DocumentRoot $APACHE_DOC_ROOT|" /etc/apache2/sites-available/000-default.conf sed -i "s|DocumentRoot /var/www/html|DocumentRoot $APACHE_DOC_ROOT|" /etc/apache2/apache2.conf -# Configure XDebug remote host -if [ -z "$HOST_IP" ]; then - # Allows to set HOST_IP by env variable because could be different from the one which come from ip route command - HOST_IP=$(/sbin/ip route|awk '/default/ { print $3 }') +# Enable XDebug if needed +if [ "$XDEBUG_ENABLE" = "1" ]; then + docker-php-ext-enable xdebug + mv /usr/local/etc/php/conf.d/99-xdebug.ini.disabled /usr/local/etc/php/conf.d/99-xdebug.ini + # Configure XDebug remote host + if [ -z "$HOST_IP" ]; then + # Allows to set HOST_IP by env variable because could be different from the one which come from ip route command + HOST_IP=$(/sbin/ip route|awk '/default/ { print $3 }') + fi; + echo "xdebug.remote_host=$HOST_IP" > /usr/local/etc/php/conf.d/xdebug_remote_host.ini fi; -echo "xdebug.remote_host=$HOST_IP" > /usr/local/etc/php/conf.d/xdebug_remote_host.ini exec "$@" From 45fd11c586c1bc10be708d288b4d09934905f243 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Fri, 8 Jan 2016 11:54:18 +0100 Subject: [PATCH 15/31] Allow /unison to be Apache document root --- docker-entrypoint | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docker-entrypoint b/docker-entrypoint index b12e067..1155067 100755 --- a/docker-entrypoint +++ b/docker-entrypoint @@ -9,6 +9,12 @@ echo "date.timezone = $PHP_TIMEZONE" > /usr/local/etc/php/conf.d/timezone.ini sed -i "s|DocumentRoot /var/www/html|DocumentRoot $APACHE_DOC_ROOT|" /etc/apache2/sites-available/000-default.conf sed -i "s|DocumentRoot /var/www/html|DocumentRoot $APACHE_DOC_ROOT|" /etc/apache2/apache2.conf +# Allow /unison to be Apache Document Root +echo "" >> /etc/apache2/apache2.conf +echo " AllowOverride All" >> /etc/apache2/apache2.conf +echo " Require all granted" >> /etc/apache2/apache2.conf +echo "" >> /etc/apache2/apache2.conf + # Enable XDebug if needed if [ "$XDEBUG_ENABLE" = "1" ]; then docker-php-ext-enable xdebug From 9131e820bac181edebdfc2fd288e2934d5e97c40 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Sun, 10 Jan 2016 11:42:56 +0100 Subject: [PATCH 16/31] Install blackfire.io probe --- Dockerfile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Dockerfile b/Dockerfile index 722af7d..4118066 100644 --- a/Dockerfile +++ b/Dockerfile @@ -50,6 +50,14 @@ RUN a2enmod rewrite # Additional PHP ini configuration COPY ./999-php.ini /usr/local/etc/php/conf.d/ +# Install Blackfire.io Probe +RUN export VERSION=`php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;"` \ + && curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/${VERSION} \ + && tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp \ + && mv /tmp/blackfire-*.so `php -r "echo ini_get('extension_dir');"`/blackfire.so \ + && echo "extension=blackfire.so\nblackfire.agent_socket=\${BLACKFIRE_PORT}" > $PHP_INI_DIR/conf.d/blackfire.ini + +# Sample index.php with phpinfo() and entrypoint COPY ./index.php /var/www/html/index.php ENTRYPOINT ["docker-entrypoint"] From 1490d935978de0674b180fad91a4a7ebbc998f53 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Wed, 30 Dec 2015 12:24:09 +0100 Subject: [PATCH 17/31] Adds composer --- Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Dockerfile b/Dockerfile index 4118066..2a35a4b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,6 +26,10 @@ COPY ./99-xdebug.ini.disabled /usr/local/etc/php/conf.d/ # Install Mysql RUN docker-php-ext-install mysql mysqli pdo_mysql +# Install Composer +RUN curl -sS https://getcomposer.org/installer | php \ + && mv composer.phar /usr/local/bin/composer + # Install mbstring RUN docker-php-ext-install mbstring From fbf41a2ddda195a201ce3eba16fcd588bc84bdf5 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Thu, 21 Jan 2016 16:04:30 +0100 Subject: [PATCH 18/31] Adds Blackfire.ip to README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index bc232a9..9d4a2ea 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ Features * Xdebug PHP extension installed but not enabled * Ability to enable xdebug PHP extension through `XDEBUG_ENABLE` environment variable which has to be set to `1` * Ability to set xdebug.remote_enable setting through `HOST_IP` environment variable. +* Blackfire.io Probe installed Usage ----- From 8aa5ca87665507cd161aa6012dffade08e1b4283 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Thu, 21 Jan 2016 16:27:14 +0100 Subject: [PATCH 19/31] Adds zip PHP extension --- Dockerfile | 3 +++ README.md | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 2a35a4b..7778075 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,6 +41,9 @@ RUN apt-get update \ # Install opcache RUN docker-php-ext-install opcache +# Install PHP zip extension +RUN docker-php-ext-install zip + # Define PHP_TIMEZONE env variable ENV PHP_TIMEZONE Europe/Rome diff --git a/README.md b/README.md index 9d4a2ea..922da13 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Features * Ability to set Apache document root through `APACHE_DOC_ROOT` environment variable. Default document root is `/var/www/html` * Enabled Apache modules: rewrite * Ability to set PHP `date.timezone` through `PHP_TIMEZONE` environment variable. Default timezone is `Europe/Rome` -* Enabled PHP extensions: gd, mcrypt, intl, mysql, mysqli, pdo_mysql, mbstring, soap, opcache +* Enabled PHP extensions: gd, mcrypt, intl, mysql, mysqli, pdo_mysql, mbstring, soap, opcache, zip * Composer installed globally at `/usr/local/bin/composer` * Xdebug PHP extension installed but not enabled * Ability to enable xdebug PHP extension through `XDEBUG_ENABLE` environment variable which has to be set to `1` From 461cc3c2ace846f50afa51e35c652c5435fbad2b Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Thu, 21 Jan 2016 16:28:23 +0100 Subject: [PATCH 20/31] Installs GIT --- Dockerfile | 4 ++++ README.md | 1 + 2 files changed, 5 insertions(+) diff --git a/Dockerfile b/Dockerfile index 7778075..64fcc77 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,6 +44,10 @@ RUN docker-php-ext-install opcache # Install PHP zip extension RUN docker-php-ext-install zip +# Install Git +RUN apt-get update \ + && apt-get install -y git + # Define PHP_TIMEZONE env variable ENV PHP_TIMEZONE Europe/Rome diff --git a/README.md b/README.md index 922da13..d7f52e4 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ Features * Ability to enable xdebug PHP extension through `XDEBUG_ENABLE` environment variable which has to be set to `1` * Ability to set xdebug.remote_enable setting through `HOST_IP` environment variable. * Blackfire.io Probe installed +* GIT installed (required by Composer) Usage ----- From adeb68e36fc39a3ada0f80b72b2b1c8f448e766a Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Fri, 29 Jan 2016 12:14:03 +0100 Subject: [PATCH 21/31] No more entrypoint (only start script) --- Dockerfile | 6 +++--- docker-entrypoint => start | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) rename docker-entrypoint => start (97%) diff --git a/Dockerfile b/Dockerfile index 64fcc77..9764c9c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -53,7 +53,6 @@ ENV PHP_TIMEZONE Europe/Rome # Configure Apache Document Root ENV APACHE_DOC_ROOT /var/www/html -COPY ./docker-entrypoint /usr/local/bin/ # Enable Apache mod_rewrite RUN a2enmod rewrite @@ -71,5 +70,6 @@ RUN export VERSION=`php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;"` \ # Sample index.php with phpinfo() and entrypoint COPY ./index.php /var/www/html/index.php -ENTRYPOINT ["docker-entrypoint"] -CMD ["apache2-foreground"] +# Start! +COPY ./start /usr/local/bin/ +CMD ["start"] diff --git a/docker-entrypoint b/start similarity index 97% rename from docker-entrypoint rename to start index 1155067..da7fb6e 100755 --- a/docker-entrypoint +++ b/start @@ -27,4 +27,4 @@ if [ "$XDEBUG_ENABLE" = "1" ]; then echo "xdebug.remote_host=$HOST_IP" > /usr/local/etc/php/conf.d/xdebug_remote_host.ini fi; -exec "$@" +exec "apache2-foreground" From d1442e2582042dd95fe99c643ed00cd8665b2864 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Fri, 29 Jan 2016 12:27:38 +0100 Subject: [PATCH 22/31] Provides more generic document root apache config --- start | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/start b/start index da7fb6e..97132a3 100755 --- a/start +++ b/start @@ -6,14 +6,12 @@ set -e echo "date.timezone = $PHP_TIMEZONE" > /usr/local/etc/php/conf.d/timezone.ini # Configure Apache Document Root -sed -i "s|DocumentRoot /var/www/html|DocumentRoot $APACHE_DOC_ROOT|" /etc/apache2/sites-available/000-default.conf sed -i "s|DocumentRoot /var/www/html|DocumentRoot $APACHE_DOC_ROOT|" /etc/apache2/apache2.conf - -# Allow /unison to be Apache Document Root -echo "" >> /etc/apache2/apache2.conf -echo " AllowOverride All" >> /etc/apache2/apache2.conf -echo " Require all granted" >> /etc/apache2/apache2.conf -echo "" >> /etc/apache2/apache2.conf +echo "" > /etc/apache2/conf-available/document-root-directory.conf +echo " AllowOverride All" >> /etc/apache2/conf-available/document-root-directory.conf +echo " Require all granted" >> /etc/apache2/conf-available/document-root-directory.conf +echo "" >> /etc/apache2/conf-available/document-root-directory.conf +a2enconf "document-root-directory.conf" # Enable XDebug if needed if [ "$XDEBUG_ENABLE" = "1" ]; then From c4a7149283178b161732ed86b07aa6a7c9d5249f Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Sat, 30 Jan 2016 15:57:10 +0100 Subject: [PATCH 23/31] Adds group write permissions to document root --- Dockerfile | 7 +++++++ set_docroot_group_perms | 5 +++++ start | 6 ++++++ 3 files changed, 18 insertions(+) create mode 100755 set_docroot_group_perms diff --git a/Dockerfile b/Dockerfile index 9764c9c..0c96bb8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -70,6 +70,13 @@ RUN export VERSION=`php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;"` \ # Sample index.php with phpinfo() and entrypoint COPY ./index.php /var/www/html/index.php +# Add www-data to root group and viceversa +RUN usermod -a -G www-data root +RUN usermod -a -G root www-data + +# Add Document Root group permissions set script +COPY ./set_docroot_group_perms /usr/local/bin/ + # Start! COPY ./start /usr/local/bin/ CMD ["start"] diff --git a/set_docroot_group_perms b/set_docroot_group_perms new file mode 100755 index 0000000..e29abf4 --- /dev/null +++ b/set_docroot_group_perms @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +chmod g+rwx $APACHE_DOC_ROOT +find $APACHE_DOC_ROOT -type d -exec chmod g+rwx {} \; +find $APACHE_DOC_ROOT -type f -exec chmod g+rw {} \; diff --git a/start b/start index 97132a3..ba9368e 100755 --- a/start +++ b/start @@ -6,6 +6,8 @@ set -e echo "date.timezone = $PHP_TIMEZONE" > /usr/local/etc/php/conf.d/timezone.ini # Configure Apache Document Root +mkdir -p $APACHE_DOC_ROOT +chown www-data:www-data $APACHE_DOC_ROOT sed -i "s|DocumentRoot /var/www/html|DocumentRoot $APACHE_DOC_ROOT|" /etc/apache2/apache2.conf echo "" > /etc/apache2/conf-available/document-root-directory.conf echo " AllowOverride All" >> /etc/apache2/conf-available/document-root-directory.conf @@ -25,4 +27,8 @@ if [ "$XDEBUG_ENABLE" = "1" ]; then echo "xdebug.remote_host=$HOST_IP" > /usr/local/etc/php/conf.d/xdebug_remote_host.ini fi; + +# Set group permissions for path $APACHE_DOC_ROOT +set_docroot_group_perms + exec "apache2-foreground" From 3312c984282ea68bbe84d4c10361b74c332fde91 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Sat, 30 Jan 2016 19:36:01 +0100 Subject: [PATCH 24/31] Removes set group perms from start script --- start | 4 ---- 1 file changed, 4 deletions(-) diff --git a/start b/start index ba9368e..1d8159d 100755 --- a/start +++ b/start @@ -27,8 +27,4 @@ if [ "$XDEBUG_ENABLE" = "1" ]; then echo "xdebug.remote_host=$HOST_IP" > /usr/local/etc/php/conf.d/xdebug_remote_host.ini fi; - -# Set group permissions for path $APACHE_DOC_ROOT -set_docroot_group_perms - exec "apache2-foreground" From a8520b6775e054c685fa0e3aac68028628afed2a Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Tue, 9 Feb 2016 08:15:10 +0100 Subject: [PATCH 25/31] Adds xls PHP extension --- Dockerfile | 5 +++++ README.md | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 0c96bb8..8074a84 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,6 +48,11 @@ RUN docker-php-ext-install zip RUN apt-get update \ && apt-get install -y git +# Install xsl +RUN apt-get update \ + && apt-get install -y libxslt-dev \ + && docker-php-ext-install xsl + # Define PHP_TIMEZONE env variable ENV PHP_TIMEZONE Europe/Rome diff --git a/README.md b/README.md index d7f52e4..9e3df36 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Features * Ability to set Apache document root through `APACHE_DOC_ROOT` environment variable. Default document root is `/var/www/html` * Enabled Apache modules: rewrite * Ability to set PHP `date.timezone` through `PHP_TIMEZONE` environment variable. Default timezone is `Europe/Rome` -* Enabled PHP extensions: gd, mcrypt, intl, mysql, mysqli, pdo_mysql, mbstring, soap, opcache, zip +* Enabled PHP extensions: gd, mcrypt, intl, mysql, mysqli, pdo_mysql, mbstring, soap, opcache, zip, xls * Composer installed globally at `/usr/local/bin/composer` * Xdebug PHP extension installed but not enabled * Ability to enable xdebug PHP extension through `XDEBUG_ENABLE` environment variable which has to be set to `1` From ddaa31dfa28b1bc8d6e93da28aab3d7f1e3eba33 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Wed, 17 Feb 2016 19:37:38 +0100 Subject: [PATCH 26/31] Adds sSMTP support --- Dockerfile | 9 +++++++++ README.md | 2 ++ start | 11 +++++++++++ 3 files changed, 22 insertions(+) diff --git a/Dockerfile b/Dockerfile index 8074a84..e4ae4a4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -82,6 +82,15 @@ RUN usermod -a -G root www-data # Add Document Root group permissions set script COPY ./set_docroot_group_perms /usr/local/bin/ +# Install ssmtp Mail Transfer Agent +RUN apt-get update \ + && apt-get install -y ssmtp \ + && apt-get clean \ + && echo "FromLineOverride=YES" >> /etc/ssmtp/ssmtp.conf \ + && echo 'sendmail_path = "/usr/sbin/ssmtp -t"' > /usr/local/etc/php/conf.d/mail.ini + +######################################################################################################################## + # Start! COPY ./start /usr/local/bin/ CMD ["start"] diff --git a/README.md b/README.md index 9e3df36..5c2480a 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ Features * Ability to set xdebug.remote_enable setting through `HOST_IP` environment variable. * Blackfire.io Probe installed * GIT installed (required by Composer) +* sSMTP installed (as Mail Transfer Agent for PHP mail function) +* Ability to set sSMTP mailhub, AuthUser and AuthPass through `SSMTP_MAILHUB`, `SSMTP_AUTH_USER` and `SSMTP_AUTH_PASS` environment variables Usage ----- diff --git a/start b/start index 1d8159d..a0d2f56 100755 --- a/start +++ b/start @@ -27,4 +27,15 @@ if [ "$XDEBUG_ENABLE" = "1" ]; then echo "xdebug.remote_host=$HOST_IP" > /usr/local/etc/php/conf.d/xdebug_remote_host.ini fi; +# Configure sSMTP +if [ "$SSMTP_MAILHUB" ]; then + echo "mailhub=$SSMTP_MAILHUB" >> /etc/ssmtp/ssmtp.conf +fi; +if [ "$SSMTP_AUTH_USER" ]; then + echo "AuthUser=$SSMTP_AUTH_USER" >> /etc/ssmtp/ssmtp.conf +fi; +if [ "$SSMTP_AUTH_PASS" ]; then + echo "AuthPass=$SSMTP_AUTH_PASS" >> /etc/ssmtp/ssmtp.conf +fi; + exec "apache2-foreground" From 3dc824cb6680152944e3e93bf9ee6102a0063fe0 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Wed, 2 Mar 2016 12:20:53 +0100 Subject: [PATCH 27/31] Adds MySQL CLI Client --- Dockerfile | 4 ++++ README.md | 1 + 2 files changed, 5 insertions(+) diff --git a/Dockerfile b/Dockerfile index e4ae4a4..cc9a044 100644 --- a/Dockerfile +++ b/Dockerfile @@ -89,6 +89,10 @@ RUN apt-get update \ && echo "FromLineOverride=YES" >> /etc/ssmtp/ssmtp.conf \ && echo 'sendmail_path = "/usr/sbin/ssmtp -t"' > /usr/local/etc/php/conf.d/mail.ini +# Install MySQL CLI Client +RUN apt-get update \ + && apt-get install -y mysql-client + ######################################################################################################################## # Start! diff --git a/README.md b/README.md index 5c2480a..316f668 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ Features * GIT installed (required by Composer) * sSMTP installed (as Mail Transfer Agent for PHP mail function) * Ability to set sSMTP mailhub, AuthUser and AuthPass through `SSMTP_MAILHUB`, `SSMTP_AUTH_USER` and `SSMTP_AUTH_PASS` environment variables +* MySQL CLI Client installed Usage ----- From cebc263d1e784d2bd11dcd62f046d597b6a25154 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Sat, 3 Sep 2016 14:12:59 +0200 Subject: [PATCH 28/31] Removes permissions handling, not a container responsibility --- Dockerfile | 7 ------- set_docroot_group_perms | 5 ----- 2 files changed, 12 deletions(-) delete mode 100755 set_docroot_group_perms diff --git a/Dockerfile b/Dockerfile index cc9a044..dac1773 100644 --- a/Dockerfile +++ b/Dockerfile @@ -75,13 +75,6 @@ RUN export VERSION=`php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;"` \ # Sample index.php with phpinfo() and entrypoint COPY ./index.php /var/www/html/index.php -# Add www-data to root group and viceversa -RUN usermod -a -G www-data root -RUN usermod -a -G root www-data - -# Add Document Root group permissions set script -COPY ./set_docroot_group_perms /usr/local/bin/ - # Install ssmtp Mail Transfer Agent RUN apt-get update \ && apt-get install -y ssmtp \ diff --git a/set_docroot_group_perms b/set_docroot_group_perms deleted file mode 100755 index e29abf4..0000000 --- a/set_docroot_group_perms +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -chmod g+rwx $APACHE_DOC_ROOT -find $APACHE_DOC_ROOT -type d -exec chmod g+rwx {} \; -find $APACHE_DOC_ROOT -type f -exec chmod g+rw {} \; From 330dd23da065a0643fa3ae507ca34848e1cef767 Mon Sep 17 00:00:00 2001 From: Benjamin Pick Date: Thu, 8 Sep 2016 14:30:21 +0200 Subject: [PATCH 29/31] Fix $APACHE_DOC_ROOT The debian default config of apache2 doesn't have the DocumentRoot-Directive directly in the apache2.conf ... so changing the APACHE_DOC_ROOT from the default `/var/www/html` didn't work. --- start | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/start b/start index a0d2f56..107f61d 100755 --- a/start +++ b/start @@ -8,7 +8,7 @@ echo "date.timezone = $PHP_TIMEZONE" > /usr/local/etc/php/conf.d/timezone.ini # Configure Apache Document Root mkdir -p $APACHE_DOC_ROOT chown www-data:www-data $APACHE_DOC_ROOT -sed -i "s|DocumentRoot /var/www/html|DocumentRoot $APACHE_DOC_ROOT|" /etc/apache2/apache2.conf +sed -i "s|DocumentRoot /var/www/html|DocumentRoot $APACHE_DOC_ROOT|" /etc/apache2/sites-available/000-default.conf echo "" > /etc/apache2/conf-available/document-root-directory.conf echo " AllowOverride All" >> /etc/apache2/conf-available/document-root-directory.conf echo " Require all granted" >> /etc/apache2/conf-available/document-root-directory.conf From bbd8c34d295745ca4c0f57b9de4a792cee389079 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Thu, 8 Sep 2016 19:20:03 +0200 Subject: [PATCH 30/31] Fixes doc root replacement replacement in apache config --- start | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/start b/start index 107f61d..c4e7a29 100755 --- a/start +++ b/start @@ -8,7 +8,7 @@ echo "date.timezone = $PHP_TIMEZONE" > /usr/local/etc/php/conf.d/timezone.ini # Configure Apache Document Root mkdir -p $APACHE_DOC_ROOT chown www-data:www-data $APACHE_DOC_ROOT -sed -i "s|DocumentRoot /var/www/html|DocumentRoot $APACHE_DOC_ROOT|" /etc/apache2/sites-available/000-default.conf +sed -i "s|DocumentRoot /var/www/html\$|DocumentRoot $APACHE_DOC_ROOT|" /etc/apache2/sites-available/000-default.conf echo "" > /etc/apache2/conf-available/document-root-directory.conf echo " AllowOverride All" >> /etc/apache2/conf-available/document-root-directory.conf echo " Require all granted" >> /etc/apache2/conf-available/document-root-directory.conf From e1942c55eed44bf9ffc126506baef0303b2bc892 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Sun, 25 Mar 2018 16:15:12 +0200 Subject: [PATCH 31/31] Uses xdebug 2.5.5 which is the last compatible with php 5.5 and 5.6 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index dac1773..d292173 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,7 +19,7 @@ RUN apt-get update \ # Install XDebug ENV XDEBUG_ENABLE 0 -RUN pecl install -o -f xdebug \ +RUN pecl install -o -f xdebug-2.5.5 \ && rm -rf /tmp/pear COPY ./99-xdebug.ini.disabled /usr/local/etc/php/conf.d/