-
Notifications
You must be signed in to change notification settings - Fork 141
Open
Labels
enhancement requestedNew feature suggestedNew feature suggested
Description
Previously, we had to manually fetch the host ip from the container. This is rather hacky, and this starts failing for me locally. We should instead default to xdebug://gateway, https://xdebug.org/docs/step_debug#client_host:
xdebug://gatewayUse the system defined network gateway.
Supported on Linux only.
References:
docker-images-php/utils/docker-entrypoint-as-root.sh
Lines 84 to 114 in 355c1ac
| if [ -z "$XDEBUG_CLIENT_HOST" ]; then | |
| export XDEBUG_CLIENT_HOST=`/sbin/ip route|awk '/default/ { print $3 }'` | |
| set +e | |
| # On Windows and MacOS with Docker >= 18.03, check that host.docker.internal exists. it true, use this. | |
| # Linux systems can report the value exists, but it is bound to localhost. In this case, ignore. | |
| host -t A host.docker.internal &> /dev/null | |
| if [[ $? == 0 ]]; then | |
| # The host exists. | |
| DOCKER_HOST_INTERNAL=`host -t A host.docker.internal | awk '/has address/ { print $4 }'` | |
| if [ "$DOCKER_HOST_INTERNAL" != "127.0.0.1" ]; then | |
| export XDEBUG_CLIENT_HOST=$DOCKER_HOST_INTERNAL | |
| export REMOTE_HOST_FOUND=1 | |
| fi | |
| fi | |
| if [[ "$REMOTE_HOST_FOUND" != "1" ]]; then | |
| # On mac with Docker < 18.03, check that docker.for.mac.localhost exists. it true, use this. | |
| # Linux systems can report the value exists, but it is bound to localhost. In this case, ignore. | |
| host -t A docker.for.mac.localhost &> /dev/null | |
| if [[ $? == 0 ]]; then | |
| # The host exists. | |
| DOCKER_FOR_MAC_REMOTE_HOST=`host -t A docker.for.mac.localhost | awk '/has address/ { print $4 }'` | |
| if [ "$DOCKER_FOR_MAC_REMOTE_HOST" != "127.0.0.1" ]; then | |
| export XDEBUG_CLIENT_HOST=$DOCKER_FOR_MAC_REMOTE_HOST | |
| fi | |
| fi | |
| fi | |
| set -e | |
| fi |
Line 330 in 355c1ac
| If you enable XDebug, the image will do its best to configure the `xdebug.client_host` to point back to your Docker host. |
docker-images-php/utils/README.blueprint.md
Line 278 in 355c1ac
| If you enable XDebug, the image will do its best to configure the `xdebug.client_host` to point back to your Docker host. |
Maybe we should adapt the test too
docker-images-php/tests-suite/php-xdebug.sh
Lines 1 to 23 in 355c1ac
| #!/usr/bin/env bash | |
| . ./config | |
| ############################################################ | |
| ## xdebug | |
| ############################################################ | |
| test_config() { | |
| # Let's check that the "xdebug.client_host" contains a value different from "no value" | |
| docker run ${RUN_OPTIONS} --rm -e PHP_EXTENSION_XDEBUG=1 "${REPO}:${TAG_PREFIX}${PHP_VERSION}-${BRANCH}-${BRANCH_VARIANT}" \ | |
| php -i | grep xdebug.client_host | grep -v -q "no value" | |
| assert_equals "0" "$?" '"xdebug.client_host" contains "no value"' | |
| # Let's check that "xdebug.mode" is set to "debug" by default | |
| docker run ${RUN_OPTIONS} --rm -e PHP_EXTENSION_XDEBUG=1 "${REPO}:${TAG_PREFIX}${PHP_VERSION}-${BRANCH}-${BRANCH_VARIANT}" \ | |
| php -i | grep xdebug.mode | grep -q "debug" | |
| assert_equals "0" "$?" '"xdebug.mode" is not set to "debug" by default' | |
| # Let's check that "xdebug.mode" is properly overridden | |
| docker run ${RUN_OPTIONS} --rm -e PHP_EXTENSION_XDEBUG=1 -e PHP_INI_XDEBUG__MODE=debug,coverage \ | |
| "${REPO}:${TAG_PREFIX}${PHP_VERSION}-${BRANCH}-${BRANCH_VARIANT}" \ | |
| php -i | grep xdebug.mode | grep -q "debug,coverage" | |
| assert_equals "0" "$?" '"xdebug.mode" is not properly overridden' | |
| } |
Metadata
Metadata
Assignees
Labels
enhancement requestedNew feature suggestedNew feature suggested