From 48201fe107f02ef7858d728c48ad4d88af062878 Mon Sep 17 00:00:00 2001 From: Michael Aherne Date: Thu, 16 Aug 2018 09:18:27 +0100 Subject: [PATCH] Add xdebug support. --- Dockerfile | 5 +++++ README.md | 7 +++++++ root/tmp/setup/php-extensions.sh | 2 ++ root/usr/bin/moodle-php-entrypoint | 12 ++++++++++++ 4 files changed, 26 insertions(+) create mode 100644 root/usr/bin/moodle-php-entrypoint diff --git a/Dockerfile b/Dockerfile index 5bcacc2..f4e71c7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,12 @@ RUN chmod 777 /tmp && chmod +t /tmp RUN /tmp/setup/php-extensions.sh RUN /tmp/setup/oci8-extension.sh +RUN chmod +x /usr/bin/moodle-php-entrypoint +ENTRYPOINT ["moodle-php-entrypoint"] + RUN mkdir /var/www/moodledata && chown www-data /var/www/moodledata && \ mkdir /var/www/phpunitdata && chown www-data /var/www/phpunitdata && \ mkdir /var/www/behatdata && chown www-data /var/www/behatdata && \ mkdir /var/www/behatfaildumps && chown www-data /var/www/behatfaildumps + +CMD ["apache2-foreground"] \ No newline at end of file diff --git a/README.md b/README.md index 9e5c142..57b9bb6 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,13 @@ To faciliate testing and easy setup the following directories are created and ow * `/var/www/behatdata` * `/var/www/behatfaildumps` +# Xdebug + +For development, the image contains the Xdebug PHP extension. This is disabled by default, for performance reasons, but can be enabled by setting a non-empty XDEBUG_CONFIG environment variable. This environment variable is also used by Xdebug for configuration (see [XDebug documentation](https://xdebug.org/docs) for details and available configuration settings). + +```bash +$ docker run --name web0 -p 8080:80 -v $PWD:/var/www/html -e XDEBUG_CONFIG="remote_enable=1 remote_connect_back=1" moodlehq/moodle-php-apache:7.1 +``` # See also This container is part of a set of containers for Moodle development, see also: diff --git a/root/tmp/setup/php-extensions.sh b/root/tmp/setup/php-extensions.sh index e479f9a..18dbe25 100755 --- a/root/tmp/setup/php-extensions.sh +++ b/root/tmp/setup/php-extensions.sh @@ -48,6 +48,8 @@ ACCEPT_EULA=Y apt-get install -y msodbcsql pecl install sqlsrv-4.3.0 docker-php-ext-enable sqlsrv +pecl install xdebug-2.6.1 + # Keep our image size down.. pecl clear-cache apt-get remove --purge -y $BUILD_PACKAGES diff --git a/root/usr/bin/moodle-php-entrypoint b/root/usr/bin/moodle-php-entrypoint new file mode 100644 index 0000000..c58287c --- /dev/null +++ b/root/usr/bin/moodle-php-entrypoint @@ -0,0 +1,12 @@ +#!/bin/sh + +XDEBUG_INI_FILE=/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +if [ -z "${XDEBUG_CONFIG}" ]; then + rm -f $XDEBUG_INI_FILE +else + if [ ! -e $XDEBUG_INI_FILE ]; then + echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > $XDEBUG_INI_FILE + fi +fi + +/usr/local/bin/docker-php-entrypoint "$@"