How do I install XDebug on docker's official php-fpm-alpine image?
The following is sufficient for simply installing xdebug on that image:
FROM wordpress:php7.1-fpm-alpine
RUN apk add --no-cache $PHPIZE_DEPS \
&& pecl install xdebug-2.5.0 \
&& docker-php-ext-enable xdebug
Building that and then running from a shell inside the resulting image produces the following:
$ php -i | grep Xdebug
with Xdebug v2.5.0, Copyright (c) 2002-2016, by Derick Rethans
If you are concerned about image size you can remove the dependencies:
FROM wordpress:php7.1-fpm-alpine
RUN apk --update --no-cache add autoconf g++ make && \
pecl install -f xdebug && \
docker-php-ext-enable xdebug && \
apk del --purge autoconf g++ make
Great answer @msanchez_aplyca. Although more correctly removing the build dependancies via apk
would be:
RUN apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \
&& pecl install xdebug-2.5.0 \
&& docker-php-ext-enable xdebug \
&& apk del -f .build-deps