From de70beae47fe18a65827561e424b7538782919a5 Mon Sep 17 00:00:00 2001 From: Daryle Dale De Silva Date: Mon, 18 Jan 2021 12:02:27 +0800 Subject: [PATCH 1/2] support xdebug 3 --- php-fpm/Dockerfile | 31 +++++++++++++++++++++++-------- workspace/Dockerfile | 39 +++++++++++++++++++++++++++------------ 2 files changed, 50 insertions(+), 20 deletions(-) diff --git a/php-fpm/Dockerfile b/php-fpm/Dockerfile index e4db8856..76dfeb80 100644 --- a/php-fpm/Dockerfile +++ b/php-fpm/Dockerfile @@ -187,13 +187,17 @@ ARG INSTALL_XDEBUG=false RUN if [ ${INSTALL_XDEBUG} = true ]; then \ # Install the xdebug extension - if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \ - pecl install xdebug-2.5.5; \ + if [ $(php -r "echo PHP_MAJOR_VERSION;") = "8" ]; then \ + pecl install xdebug-3.0.0; \ else \ - if [ $(php -r "echo PHP_MINOR_VERSION;") = "0" ]; then \ - pecl install xdebug-2.9.0; \ + if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \ + pecl install xdebug-2.5.5; \ else \ - pecl install xdebug-2.9.8; \ + if [ $(php -r "echo PHP_MINOR_VERSION;") = "0" ]; then \ + pecl install xdebug-2.9.0; \ + else \ + pecl install xdebug-2.9.8; \ + fi \ fi \ fi && \ docker-php-ext-enable xdebug \ @@ -202,9 +206,20 @@ RUN if [ ${INSTALL_XDEBUG} = true ]; then \ # Copy xdebug configuration for remote debugging COPY ./xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini -RUN sed -i "s/xdebug.remote_autostart=0/xdebug.remote_autostart=1/" /usr/local/etc/php/conf.d/xdebug.ini && \ - sed -i "s/xdebug.remote_enable=0/xdebug.remote_enable=1/" /usr/local/etc/php/conf.d/xdebug.ini && \ - sed -i "s/xdebug.cli_color=0/xdebug.cli_color=1/" /usr/local/etc/php/conf.d/xdebug.ini +RUN if [ $(php -r "echo PHP_MAJOR_VERSION;") = "8" ]; then \ + sed -i "s/xdebug.remote_host=/xdebug.client_host=/" /usr/local/etc/php/conf.d/xdebug.ini && \ + sed -i "s/xdebug.remote_connect_back=0/xdebug.discover_client_host=false/" /usr/local/etc/php/conf.d/xdebug.ini && \ + sed -i "s/xdebug.remote_port=9000/xdebug.client_port=9003/" /usr/local/etc/php/conf.d/xdebug.ini && \ + sed -i "s/xdebug.profiler_enable=0/; xdebug.profiler_enable=0/" /usr/local/etc/php/conf.d/xdebug.ini && \ + sed -i "s/xdebug.profiler_output_dir=/xdebug.output_dir=/" /usr/local/etc/php/conf.d/xdebug.ini && \ + sed -i "s/xdebug.remote_mode=req/; xdebug.remote_mode=req/" /usr/local/etc/php/conf.d/xdebug.ini && \ + sed -i "s/xdebug.remote_autostart=0/xdebug.start_with_request=yes/" /usr/local/etc/php/conf.d/xdebug.ini && \ + sed -i "s/xdebug.remote_enable=0/xdebug.mode=debug/" /usr/local/etc/php/conf.d/xdebug.ini \ +;else \ + sed -i "s/xdebug.remote_autostart=0/xdebug.remote_autostart=1/" /usr/local/etc/php/conf.d/xdebug.ini && \ + sed -i "s/xdebug.remote_enable=0/xdebug.remote_enable=1/" /usr/local/etc/php/conf.d/xdebug.ini \ +;fi +RUN sed -i "s/xdebug.cli_color=0/xdebug.cli_color=1/" /usr/local/etc/php/conf.d/xdebug.ini ########################################################################### # pcov: diff --git a/workspace/Dockerfile b/workspace/Dockerfile index 43e76871..ced4721b 100644 --- a/workspace/Dockerfile +++ b/workspace/Dockerfile @@ -359,20 +359,24 @@ ARG INSTALL_XDEBUG=false RUN if [ ${INSTALL_XDEBUG} = true ]; then \ # Install the xdebug extension - if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \ - pecl install xdebug-2.5.5; \ + if [ $(php -r "echo PHP_MAJOR_VERSION;") = "8" ]; then \ + pecl install xdebug-3.0.0; \ else \ - if [ $(php -r "echo PHP_MAJOR_VERSION;") = "7" ] && [ $(php -r "echo PHP_MINOR_VERSION;") = "0" ]; then \ - pecl install xdebug-2.9.0; \ + if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \ + pecl install xdebug-2.5.5; \ else \ - if [ $(php -r "echo PHP_MAJOR_VERSION;") = "7" ] && [ $(php -r "echo PHP_MINOR_VERSION;") = "1" ]; then \ - pecl install xdebug-2.9.8; \ + if [ $(php -r "echo PHP_MAJOR_VERSION;") = "7" ] && [ $(php -r "echo PHP_MINOR_VERSION;") = "0" ]; then \ + pecl install xdebug-2.9.0; \ else \ - if [ $(php -r "echo PHP_MAJOR_VERSION;") = "7" ]; then \ + if [ $(php -r "echo PHP_MAJOR_VERSION;") = "7" ] && [ $(php -r "echo PHP_MINOR_VERSION;") = "1" ]; then \ pecl install xdebug-2.9.8; \ else \ - #pecl install xdebug; \ - echo "xDebug 3 required, not supported."; \ + if [ $(php -r "echo PHP_MAJOR_VERSION;") = "7" ]; then \ + pecl install xdebug-2.9.8; \ + else \ + #pecl install xdebug; \ + echo "xDebug 3 required, not supported."; \ + fi \ fi \ fi \ fi \ @@ -383,9 +387,20 @@ RUN if [ ${INSTALL_XDEBUG} = true ]; then \ # ADD for REMOTE debugging COPY ./xdebug.ini /etc/php/${LARADOCK_PHP_VERSION}/cli/conf.d/xdebug.ini -RUN sed -i "s/xdebug.remote_autostart=0/xdebug.remote_autostart=1/" /etc/php/${LARADOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ - sed -i "s/xdebug.remote_enable=0/xdebug.remote_enable=1/" /etc/php/${LARADOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ - sed -i "s/xdebug.cli_color=0/xdebug.cli_color=1/" /etc/php/${LARADOCK_PHP_VERSION}/cli/conf.d/xdebug.ini +RUN if [ $(php -r "echo PHP_MAJOR_VERSION;") = "8" ]; then \ + sed -i "s/xdebug.remote_host=/xdebug.client_host=/" /etc/php/${LARADOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ + sed -i "s/xdebug.remote_connect_back=0/xdebug.discover_client_host=false/" /etc/php/${LARADOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ + sed -i "s/xdebug.remote_port=9000/xdebug.client_port=9003/" /etc/php/${LARADOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ + sed -i "s/xdebug.profiler_enable=0/; xdebug.profiler_enable=0/" /etc/php/${LARADOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ + sed -i "s/xdebug.profiler_output_dir=/xdebug.output_dir=/" /etc/php/${LARADOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ + sed -i "s/xdebug.remote_mode=req/; xdebug.remote_mode=req/" /etc/php/${LARADOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ + sed -i "s/xdebug.remote_autostart=0/xdebug.start_with_request=yes/" /etc/php/${LARADOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ + sed -i "s/xdebug.remote_enable=0/xdebug.mode=debug/" /etc/php/${LARADOCK_PHP_VERSION}/cli/conf.d/xdebug.ini \ +;else \ + sed -i "s/xdebug.remote_autostart=0/xdebug.remote_autostart=1/" /etc/php/${LARADOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ + sed -i "s/xdebug.remote_enable=0/xdebug.remote_enable=1/" /etc/php/${LARADOCK_PHP_VERSION}/cli/conf.d/xdebug.ini \ +;fi +RUN sed -i "s/xdebug.cli_color=0/xdebug.cli_color=1/" /etc/php/${LARADOCK_PHP_VERSION}/cli/conf.d/xdebug.ini ########################################################################### # pcov: From ea9e9f81561e41ab5005afa3b16f40a6bd394bfd Mon Sep 17 00:00:00 2001 From: Daryle Dale De Silva Date: Tue, 19 Jan 2021 12:27:58 +0800 Subject: [PATCH 2/2] fix "Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: host.docker.internal:9003 (through xdebug.client_host/xdebug.client_port) :-(" --- docker-compose.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 45791f82..d19ba6a5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -270,6 +270,8 @@ services: - ./php-fpm/php${PHP_VERSION}.ini:/usr/local/etc/php/php.ini - ${APP_CODE_PATH_HOST}:${APP_CODE_PATH_CONTAINER}${APP_CODE_CONTAINER_FLAG} - docker-in-docker:/certs/client + ports: + - "9003:9003" expose: - "9000" extra_hosts: