Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add xdebug support. #31

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
30 changes: 30 additions & 0 deletions root/usr/bin/moodle-php-entrypoint
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/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
# Enable the extension.
echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > $XDEBUG_INI_FILE
# Configure the main settings, keeping features disabled.
cat <<EOF >> $XDEBUG_INI_FILE
# Code coverage.
xdebug.coverage_enable = 0
# Stack trace.
xdebug.default_enable = 0
# Remote debug.
xdebug.remote_enable = 0
xdebug.remote_host = localhost
xdebug.remote_port = 9000
xdebug.remote_autostart = 1
# Profiling: https://docs.moodle.org/dev/Profiling_PHP#Quick_summary
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = /tmp
xdebug.profiler_output_name = cachegrind.out.%R.%u
EOF
fi
fi

/usr/local/bin/docker-php-entrypoint "$@"