Skip to content

Commit

Permalink
Add xdebug support.
Browse files Browse the repository at this point in the history
  • Loading branch information
micaherne committed Aug 17, 2018
1 parent 2ca8467 commit 3fe3715
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions root/tmp/setup/php-extensions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions root/usr/bin/moodle-php-entrypoint
Original file line number Diff line number Diff line change
@@ -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 "$@"

0 comments on commit 3fe3715

Please sign in to comment.