From 8f22b552ee00a550bd546b22b9ab326870056c0d Mon Sep 17 00:00:00 2001 From: Leonardo Medici Date: Fri, 29 Apr 2022 16:43:44 +0200 Subject: [PATCH] Fix Xdebug 3 compatibility with PHP 7.3 and 7.4 - Allow to set custom Xdebug port - Update Xdebug to v3.1.4 --- .env.example | 1 + docker-compose.yml | 4 ++-- php-fpm/Dockerfile | 7 ++++--- workspace/Dockerfile | 7 ++++--- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.env.example b/.env.example index fcf07853..63fec840 100644 --- a/.env.example +++ b/.env.example @@ -205,6 +205,7 @@ WORKSPACE_INSTALL_TRADER=false WORKSPACE_PROTOC_VERSION=latest WORKSPACE_INSTALL_MEMCACHED=true WORKSPACE_INSTALL_EVENT=false +WORKSPACE_XDEBUG_PORT=9003 ### PHP_FPM ############################################### diff --git a/docker-compose.yml b/docker-compose.yml index 74fb92c2..01704319 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -74,6 +74,7 @@ services: - INSTALL_GMP=${WORKSPACE_INSTALL_GMP} - INSTALL_GNUPG=${WORKSPACE_INSTALL_GNUPG} - INSTALL_XDEBUG=${WORKSPACE_INSTALL_XDEBUG} + - XDEBUG_PORT=${WORKSPACE_XDEBUG_PORT} - INSTALL_PCOV=${WORKSPACE_INSTALL_PCOV} - INSTALL_PHPDBG=${WORKSPACE_INSTALL_PHPDBG} - INSTALL_BLACKFIRE=${INSTALL_BLACKFIRE} @@ -218,6 +219,7 @@ services: - INSTALL_GMP=${PHP_FPM_INSTALL_GMP} - INSTALL_GNUPG=${PHP_FPM_INSTALL_GNUPG} - INSTALL_XDEBUG=${PHP_FPM_INSTALL_XDEBUG} + - XDEBUG_PORT=${PHP_FPM_XDEBUG_PORT} - INSTALL_PCOV=${PHP_FPM_INSTALL_PCOV} - INSTALL_PHPDBG=${PHP_FPM_INSTALL_PHPDBG} - INSTALL_BLACKFIRE=${INSTALL_BLACKFIRE} @@ -294,8 +296,6 @@ 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: - - "${PHP_FPM_XDEBUG_PORT}:9003" expose: - "9000" extra_hosts: diff --git a/php-fpm/Dockerfile b/php-fpm/Dockerfile index 46ecbaf2..5c4ac823 100644 --- a/php-fpm/Dockerfile +++ b/php-fpm/Dockerfile @@ -212,12 +212,13 @@ RUN if [ ${INSTALL_PG_CLIENT} = true ]; then \ ########################################################################### ARG INSTALL_XDEBUG=false +ARG XDEBUG_PORT=9003 RUN if [ ${INSTALL_XDEBUG} = true ]; then \ # Install the xdebug extension # https://xdebug.org/docs/compat if [ $(php -r "echo PHP_MAJOR_VERSION;") = "8" ] || { [ $(php -r "echo PHP_MAJOR_VERSION;") = "7" ] && { [ $(php -r "echo PHP_MINOR_VERSION;") = "4" ] || [ $(php -r "echo PHP_MINOR_VERSION;") = "3" ] ;} ;}; then \ - pecl install xdebug-3.1.2; \ + pecl install xdebug-3.1.4; \ else \ if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \ pecl install xdebug-2.5.5; \ @@ -235,10 +236,10 @@ RUN if [ ${INSTALL_XDEBUG} = true ]; then \ # Copy xdebug configuration for remote debugging COPY ./xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini -RUN if [ $(php -r "echo PHP_MAJOR_VERSION;") = "8" ]; then \ +RUN if [ $(php -r "echo PHP_MAJOR_VERSION;") = "8" ] || { [ $(php -r "echo PHP_MAJOR_VERSION;") = "7" ] && { [ $(php -r "echo PHP_MINOR_VERSION;") = "4" ] || [ $(php -r "echo PHP_MINOR_VERSION;") = "3" ] ;} ;}; 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.remote_port=9000/xdebug.client_port=${XDEBUG_PORT}/" /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 && \ diff --git a/workspace/Dockerfile b/workspace/Dockerfile index 5eee6679..d5042f66 100644 --- a/workspace/Dockerfile +++ b/workspace/Dockerfile @@ -327,13 +327,14 @@ RUN set -eux; \ USER root ARG INSTALL_XDEBUG=false +ARG XDEBUG_PORT=9003 RUN if [ ${INSTALL_XDEBUG} = true ]; then \ # Install the xdebug extension # https://xdebug.org/docs/compat apt-get install -yqq pkg-config php-xml php${LARADOCK_PHP_VERSION}-xml && \ if [ $(php -r "echo PHP_MAJOR_VERSION;") = "8" ] || { [ $(php -r "echo PHP_MAJOR_VERSION;") = "7" ] && { [ $(php -r "echo PHP_MINOR_VERSION;") = "4" ] || [ $(php -r "echo PHP_MINOR_VERSION;") = "3" ] ;} ;}; then \ - pecl install xdebug-3.1.2; \ + pecl install xdebug-3.1.4; \ else \ if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \ pecl install xdebug-2.5.5; \ @@ -351,10 +352,10 @@ RUN if [ ${INSTALL_XDEBUG} = true ]; then \ # ADD for REMOTE debugging COPY ./xdebug.ini /etc/php/${LARADOCK_PHP_VERSION}/cli/conf.d/xdebug.ini -RUN if [ $(php -r "echo PHP_MAJOR_VERSION;") = "8" ]; then \ +RUN if [ $(php -r "echo PHP_MAJOR_VERSION;") = "8" ] || { [ $(php -r "echo PHP_MAJOR_VERSION;") = "7" ] && { [ $(php -r "echo PHP_MINOR_VERSION;") = "4" ] || [ $(php -r "echo PHP_MINOR_VERSION;") = "3" ] ;} ;}; 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.remote_port=9000/xdebug.client_port=${XDEBUG_PORT}/" /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 && \