diff --git a/Dockerfile b/Dockerfile index 6b8ae91..cf6d4d9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,8 @@ FROM debian:jessie ENV \ NGINX_VERSION=1.11.7 \ - PHP_VERSION=7.1.0 + PHP_VERSION=7.1.0 \ + XDEBUG_VERSION=2.5.0 COPY \ docker-entrypoint \ @@ -16,6 +17,7 @@ RUN \ apt-get update && \ apt-get install -y --no-install-recommends \ # In general... + autoconf \ build-essential \ curl \ @@ -152,6 +154,18 @@ RUN \ make -j$(nproc) build && \ make install && \ + # Compile Xdebug + mkdir -p /tmp/build/xdebug && \ + cd /tmp/build/xdebug && \ + curl -SLO \ + "https://github.com/xdebug/xdebug/archive/XDEBUG_"$(echo ${XDEBUG_VERSION} | sed "s/\./_/g")".tar.gz" && \ + tar -xvzf "XDEBUG_"$(echo ${XDEBUG_VERSION} | sed "s/\./_/g")".tar.gz" && \ + cd "xdebug-XDEBUG_"$(echo ${XDEBUG_VERSION} | sed "s/\./_/g") && \ + phpize && \ + ./configure && \ + make && \ + make install && \ + # Fix permissions chown -R www-data:www-data /usr/local/nginx/html && \ @@ -206,6 +220,7 @@ RUN \ # Final cleanup apt-get remove -y \ + autoconf \ bison \ build-essential \ curl \ diff --git a/README.md b/README.md index e3d5893..bfad4a2 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,9 @@ Nginx and PHP are compiled in a specific version. Consult the [CHANGELOG.md](./C for further version details. [PHP Composer](https://getcomposer.org/) is already installed and ready for use. +Xdebug is installed as shared extension, but not activated. Start the container with env +ENABLE_XDEBUG=1 to enable the extension. + The Nginx and PHP-FPM master processes are controlled by [Honcho](https://github.com/nickstenning/honcho). Honcho was chosen over Supervisor, because honcho will exit and kill the container if either Nginx or PHP's master process dye for any reason. If you want have to have the container restarted @@ -42,6 +45,12 @@ Mount your custom `nginx.conf` file at `/usr/local/nginx/conf/nginx.conf`. * Mount your custom `www.conf` file at `/usr/local/etc/www.conf`. * Mount your custom `php.ini` file at `/usr/local/php/php.ini`. +### Xdebug + +Xdebug was installed mainly with the idea of providing code coverage for PHPUnit. Thus it's not +configured for any specific use case. You can [configure Xdebug](https://xdebug.org/docs/all) via +`php.ini` if desired. + ### Honcho If you want to overwrite the default Honcho configuration - mount your custom `Procfile` file at `/`. diff --git a/docker-entrypoint b/docker-entrypoint index 6345db0..2cf71b9 100644 --- a/docker-entrypoint +++ b/docker-entrypoint @@ -16,6 +16,13 @@ if [[ $SKIP_COMPOSER_UPDATE != "1" ]]; then composer selfupdate -vvvn fi +# Enable Xdebug +# Use Xdebug if ENABLE_XDEBUG env is set to 1. +if [[ $ENABLE_XDEBUG == "1" ]]; then + echo -e "\e[32mXdebug enabled\e[0m" + echo "zend_extension = /usr/local/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so" >> /usr/local/lib/php.ini +fi + if [[ $1 == "server" ]]; then exec honcho -d / start fi