diff --git a/dist/bin/tissue-entrypoint.sh b/dist/bin/tissue-entrypoint.sh index 49280f5..5878f2f 100755 --- a/dist/bin/tissue-entrypoint.sh +++ b/dist/bin/tissue-entrypoint.sh @@ -3,6 +3,15 @@ set -e if [[ "$APP_DEBUG" == "true" ]]; then export PHP_INI_SCAN_DIR=":/usr/local/etc/php/php.d" + + php -r "if (gethostbyname('host.docker.internal') === 'host.docker.internal') exit(1);" &> /dev/null && : + if [[ $? -eq 0 ]]; then + # Docker for Windows/Mac + export PHP_XDEBUG_REMOTE_HOST='host.docker.internal' + else + # Docker for Linux + export PHP_XDEBUG_REMOTE_HOST=$(cat /etc/hosts | awk 'END{print $1}' | sed -r -e 's/[0-9]+$/1/g') + fi fi exec docker-php-entrypoint "$@" diff --git a/dist/php.d/99-xdebug.ini b/dist/php.d/99-xdebug.ini index 007daa1..f2a7c9d 100644 --- a/dist/php.d/99-xdebug.ini +++ b/dist/php.d/99-xdebug.ini @@ -1,4 +1,4 @@ ; Dockerでのデバッグ用設定 zend_extension=xdebug.so xdebug.remote_enable=true -xdebug.remote_host=host.docker.internal \ No newline at end of file +xdebug.remote_host=${PHP_XDEBUG_REMOTE_HOST} \ No newline at end of file