Skip to content

Commit

Permalink
build: compile Xdebug 3.2.2 for PHP 8.0, 8.1, 8.2, fixes #6159 (#6181)
Browse files Browse the repository at this point in the history
  • Loading branch information
stasadev committed May 15, 2024
1 parent 78dc228 commit 90d8956
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
32 changes: 31 additions & 1 deletion containers/ddev-php-base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,29 @@ RUN apt-get -qq install --no-install-recommends --no-install-suggests -y \
wget
#END base

### ---------------------------ddev-xdebug-build--------------------------------------
### Xdebug compile specific version because 3.3 is not fully reliable
### See https://github.com/ddev/ddev/issues/6159
### We don't need to recompile every Xdebug library https://xdebug.org/docs/compat (only PHP 8.0, 8.1, 8.2 can have Xdebug 3.2)
### PECL does not allow you to install multiple versions of Xdebug, so there is `rm -f xdebug.reg`
FROM base as ddev-xdebug-build
SHELL ["/bin/bash", "-c"]
RUN curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb && \
dpkg -i /tmp/debsuryorg-archive-keyring.deb && rm -f /tmp/debsuryorg-archive-keyring.deb && \
echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list && apt-get update
ARG XDEBUG_VERSION="3.2.2"
ARG XDEBUG_BUILD_PACKAGES="build-essential php-pear php8.0-dev php8.1-dev php8.2-dev"
RUN set -eu -o pipefail; \
apt-get -qq update && \
apt-get -qq install --no-install-recommends --no-install-suggests -y ${XDEBUG_BUILD_PACKAGES}
RUN pecl channel-update pecl.php.net && \
for version in 8.0 8.1 8.2; do \
(apt-get -qq remove -y php${version}-xdebug || true) && \
pecl -d php_suffix=${version} install -f xdebug-${XDEBUG_VERSION} && \
rm -f /usr/share/php/.registry/.channel.pecl.php.net/xdebug.reg || exit $?; \
done
#END ddev-xdebug-build

### ---------------------------ddev-php-base--------------------------------------
### Build ddev-php-base, which is the base for ddev-php-prod and ddev-webserver-*
### This combines the packages and features of DDEV’s ddev-webserver and PHP image
Expand Down Expand Up @@ -117,14 +140,21 @@ RUN for v in $PHP_VERSIONS; do \
pkgs=$(echo ${!pkgvar} | awk -v v="$v" ' BEGIN {RS=" "; } { printf "%s-%s ",v,$0 ; }' ); \
[[ ${pkgs// } != "" ]] && (apt-get -qq install --no-install-recommends --no-install-suggests -y $pkgs || exit $?) \
done
### ---------------------------ddev-xdebug-build--------------------------------------
### The dates from /usr/lib/php/YYYYMMDD/ represent PHP API versions https://unix.stackexchange.com/a/591771
RUN apt-get -qq remove -y php8.0-xdebug php8.1-xdebug php8.2-xdebug
COPY --from=ddev-xdebug-build /usr/lib/php/20200930/xdebug.so /usr/lib/php/20200930/xdebug.so
COPY --from=ddev-xdebug-build /usr/lib/php/20210902/xdebug.so /usr/lib/php/20210902/xdebug.so
COPY --from=ddev-xdebug-build /usr/lib/php/20220829/xdebug.so /usr/lib/php/20220829/xdebug.so
#END ddev-xdebug-build
RUN phpdismod xhprof
RUN apt-get -qq autoremove -y
RUN curl -L --fail -o /usr/local/bin/composer -sSL https://getcomposer.org/composer-stable.phar && chmod ugo+wx /usr/local/bin/composer
RUN curl -L --fail -sSL "https://github.com/drush-ops/drush/releases/download/${DRUSH_VERSION}/drush.phar" -o /usr/local/bin/drush8 && chmod +x /usr/local/bin/drush8
RUN curl --fail -sSL -o /usr/local/bin/wp-cli -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && chmod +x /usr/local/bin/wp-cli && ln -sf /usr/local/bin/wp-cli /usr/local/bin/wp
RUN url="https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_${TARGETPLATFORM#linux/}"; wget ${url} -O /usr/bin/yq && chmod +x /usr/bin/yq
ADD ddev-php-files /
RUN apt-get -qq autoremove && apt-get -qq clean -y && rm -rf /var/lib/apt/lists/*
RUN apt-get -qq autoremove && apt-get -qq clean -y && rm -rf /var/lib/apt/lists/* /tmp/*
RUN ln -sf /usr/sbin/php-fpm${DDEV_PHP_VERSION} /usr/sbin/php-fpm
RUN mkdir -p /run/php && chown -R www-data:www-data /run
RUN chmod 777 /var/lib/php/sessions
Expand Down
8 changes: 4 additions & 4 deletions containers/ddev-webserver/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
### Build ddev-php-base from ddev-webserver-base
### ddev-php-base is the basic of ddev-php-prod
### and ddev-webserver-* (For DDEV local Usage)
FROM ddev/ddev-php-base:20240513_stasadev_debsuryorg as ddev-webserver-base
FROM ddev/ddev-php-base:v1.23.1 as ddev-webserver-base

ENV BACKDROP_DRUSH_VERSION=1.4.0
ENV DEBIAN_FRONTEND=noninteractive
Expand Down Expand Up @@ -37,7 +37,7 @@ RUN curl --fail -sSL https://raw.githubusercontent.com/netz98/n98-magerun/develo
RUN curl --fail -sSL https://files.magerun.net/n98-magerun2-latest.phar -o /usr/local/bin/magerun2 && chmod 777 /usr/local/bin/magerun2
RUN curl --fail -sSL https://raw.githubusercontent.com/netz98/n98-magerun2/develop/res/autocompletion/bash/n98-magerun2.phar.bash -o /etc/bash_completion.d/n98-magerun2.phar && chmod +x /usr/local/bin/magerun

RUN apt-get -qq autoremove && apt-get -qq clean -y && rm -rf /var/lib/apt/lists/*
RUN apt-get -qq autoremove && apt-get -qq clean -y && rm -rf /var/lib/apt/lists/* /tmp/*

ADD ddev-webserver-base-files /
ADD ddev-webserver-base-scripts /
Expand Down Expand Up @@ -157,7 +157,7 @@ RUN chmod ugo+w /etc/ssl/certs /usr/local/share/ca-certificates

HEALTHCHECK --interval=1s --retries=120 --timeout=120s --start-period=120s CMD ["/healthcheck.sh"]
CMD ["/start.sh"]
RUN apt-get -qq clean -y && rm -rf /var/lib/apt/lists/*
RUN apt-get -qq clean -y && rm -rf /var/lib/apt/lists/* /tmp/*
RUN update-alternatives --set php /usr/bin/php${PHP_DEFAULT_VERSION}

#END ddev-webserver-dev-base
Expand Down Expand Up @@ -265,7 +265,7 @@ RUN chmod ugo+w /etc/ssl/certs /usr/local/share/ca-certificates

HEALTHCHECK --interval=1s --retries=120 --timeout=120s --start-period=120s CMD ["/healthcheck.sh"]
CMD ["/start.sh"]
RUN apt-get -qq clean -y && rm -rf /var/lib/apt/lists/*
RUN apt-get -qq clean -y && rm -rf /var/lib/apt/lists/* /tmp/*
RUN update-alternatives --set php /usr/bin/php${PHP_DEFAULT_VERSION}

#END ddev-webserver-prod-base
Expand Down
2 changes: 1 addition & 1 deletion pkg/versionconstants/versionconstants.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var AmplitudeAPIKey = ""
var WebImg = "ddev/ddev-webserver"

// WebTag defines the default web image tag
var WebTag = "20240513_stasadev_debsuryorg" // Note that this can be overridden by make
var WebTag = "v1.23.1" // Note that this can be overridden by make

// DBImg defines the default db image used for applications.
var DBImg = "ddev/ddev-dbserver"
Expand Down

0 comments on commit 90d8956

Please sign in to comment.