From 716e682dfa07b09a59963ed1dccb7f983e52a439 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Tue, 29 Dec 2015 19:53:06 +0100 Subject: [PATCH 01/32] 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/32] 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/32] 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 44476f2542c521055846484acd1ad4e1942c0ea6 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Fri, 1 Jan 2016 18:27:07 +0100 Subject: [PATCH 04/32] Fix entrypoint / cmd issue --- Dockerfile | 1 + docker-entrypoint | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c4d2838..d860018 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 0568699f6e36747d284d78429e3e180d4aa3bcfa Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Fri, 1 Jan 2016 18:28:59 +0100 Subject: [PATCH 05/32] Improves xdebug activation --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index d860018..b2a0798 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 4189e7ee88ed85a808b6946cee8312cafc723820 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Fri, 1 Jan 2016 18:35:47 +0100 Subject: [PATCH 06/32] Adds mbstring install --- Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile b/Dockerfile index b2a0798..2645104 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 95c57ee1a417942fb39361ca979e4726e9bda35a Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Fri, 1 Jan 2016 18:37:43 +0100 Subject: [PATCH 07/32] Adds soap install --- Dockerfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Dockerfile b/Dockerfile index 2645104..8ca13cf 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 23df0e9df7e338f2e149fb5074e4a04f7e0de165 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Fri, 1 Jan 2016 18:39:54 +0100 Subject: [PATCH 08/32] Adds opcache install --- Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile b/Dockerfile index 8ca13cf..e7bc89e 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 3ca62330b441963a7a03714199cc91ce02c42604 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Fri, 1 Jan 2016 18:57:58 +0100 Subject: [PATCH 09/32] 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 e7bc89e..c714c22 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 275e80fc815e079ad23dddf96aefa8f89b0942de Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Fri, 1 Jan 2016 19:29:32 +0100 Subject: [PATCH 10/32] Enables apache mod rewrite --- Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile b/Dockerfile index c714c22..1b7690e 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 8b8247679759e0aaaa4f7d2b778cbe785d489347 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Sat, 2 Jan 2016 17:49:31 +0100 Subject: [PATCH 11/32] 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 1b7690e..08e3e95 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 243ad5d7f65beee01784c4f7bd0d2c7d5d3d0543 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Fri, 1 Jan 2016 19:54:10 +0100 Subject: [PATCH 12/32] 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 b0bb0883528954bcee3fb1ede77addcbb9fa5641 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Sat, 2 Jan 2016 18:26:42 +0100 Subject: [PATCH 13/32] 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 c74599d25a32d36fe57e14ea275ce01e83c4ecc3 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Sun, 3 Jan 2016 19:25:42 +0100 Subject: [PATCH 14/32] 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 08e3e95..d6aecca 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 7a185d7e3deac76b847b4e6786fdbe8c7784a9ff Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Fri, 8 Jan 2016 11:54:18 +0100 Subject: [PATCH 15/32] 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 e73b3af6edfea4a8b990a06ddace0e2e695afc56 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Sun, 10 Jan 2016 11:42:56 +0100 Subject: [PATCH 16/32] Install blackfire.io probe --- Dockerfile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Dockerfile b/Dockerfile index d6aecca..117dc9d 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 4cba0aa0f60117210cfd5025de9a1943c084a631 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Wed, 30 Dec 2015 12:24:09 +0100 Subject: [PATCH 17/32] Adds composer --- Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Dockerfile b/Dockerfile index 117dc9d..ed70025 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 e9a7c9f8e09082d0f09fbd74d0eb6e9056e82288 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Thu, 21 Jan 2016 16:04:30 +0100 Subject: [PATCH 18/32] 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 89a41b63518be1e5d55268d6a9740035ac849bba Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Thu, 21 Jan 2016 16:27:14 +0100 Subject: [PATCH 19/32] Adds zip PHP extension --- Dockerfile | 3 +++ README.md | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ed70025..a45c2b2 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 c49bcc9266529e9b25ee3e1f200c56a23b7e84be Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Thu, 21 Jan 2016 16:28:23 +0100 Subject: [PATCH 20/32] Installs GIT --- Dockerfile | 4 ++++ README.md | 1 + 2 files changed, 5 insertions(+) diff --git a/Dockerfile b/Dockerfile index a45c2b2..657a75b 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 0621aa7f62d079b69b301d03e3719651f8696020 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Fri, 29 Jan 2016 12:14:03 +0100 Subject: [PATCH 21/32] 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 657a75b..eb9fd0d 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 85abce6de3e35c8e0aaa366e9b3a1a85dfed69b3 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Fri, 29 Jan 2016 12:27:38 +0100 Subject: [PATCH 22/32] 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 03149af840d13907b6015c90611d4a817498dfc5 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Sat, 30 Jan 2016 15:57:10 +0100 Subject: [PATCH 23/32] Adds group write permissions to document root --- Dockerfile | 7 +++++++ set_docroot_group_perms | 5 +++++ start | 5 +++++ 3 files changed, 17 insertions(+) create mode 100755 set_docroot_group_perms diff --git a/Dockerfile b/Dockerfile index eb9fd0d..c92ebb3 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..73354bc 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,7 @@ 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 5c5d419c9f1f2dbe1738a6f104b39a451d7af80f Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Sat, 30 Jan 2016 19:36:01 +0100 Subject: [PATCH 24/32] Removes set group perms from start script --- start | 3 --- 1 file changed, 3 deletions(-) diff --git a/start b/start index 73354bc..1d8159d 100755 --- a/start +++ b/start @@ -27,7 +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 e45edda2e8ebee0284a548b31a9188b7b252f865 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Tue, 9 Feb 2016 08:15:10 +0100 Subject: [PATCH 25/32] Adds xls PHP extension --- Dockerfile | 5 +++++ README.md | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c92ebb3..879b5b2 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 9b1a666ad15ff2b4b9c66b6cd71c7ea54d145a0a Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Wed, 17 Feb 2016 19:37:38 +0100 Subject: [PATCH 26/32] Adds sSMTP support --- Dockerfile | 9 +++++++++ README.md | 2 ++ start | 11 +++++++++++ 3 files changed, 22 insertions(+) diff --git a/Dockerfile b/Dockerfile index 879b5b2..86e18b8 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 3d54220c6db50aa669ffc7e71a5dc12349de1170 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Wed, 2 Mar 2016 12:20:53 +0100 Subject: [PATCH 27/32] Adds MySQL CLI Client --- Dockerfile | 4 ++++ README.md | 1 + 2 files changed, 5 insertions(+) diff --git a/Dockerfile b/Dockerfile index 86e18b8..13dd122 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 28dc839d4afc83b00dbcadcd86ebc33982f76c2b Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Sat, 3 Sep 2016 14:12:59 +0200 Subject: [PATCH 28/32] 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 13dd122..863f6e0 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 b1da0711d710772acd958598d7fa4f1ce6e0b9c7 Mon Sep 17 00:00:00 2001 From: Benjamin Pick Date: Thu, 8 Sep 2016 14:30:21 +0200 Subject: [PATCH 29/32] 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 aa2b29cc5129b14b088a415c76d6a4299a092400 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Thu, 8 Sep 2016 19:20:03 +0200 Subject: [PATCH 30/32] 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 2467fecf391db9cc7353cf803f8a422159563154 Mon Sep 17 00:00:00 2001 From: Emanuel Aguirre Date: Tue, 30 May 2017 17:56:09 -0300 Subject: [PATCH 31/32] Standalone usage code example with version and dot --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 316f668..0300db4 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ 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 + $ docker run -p 80:80 -v .:/var/www/html webgriffe/php-apache-base:5.6 Credits ------- From 57ce064e20e1262564f4127d4706558321df9492 Mon Sep 17 00:00:00 2001 From: Manuele Menozzi Date: Sun, 25 Mar 2018 16:15:12 +0200 Subject: [PATCH 32/32] 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 863f6e0..5affc66 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/