Last active
April 1, 2019 00:53
-
-
Save gerardo-junior/55721cb1187378b7163b2b269054fc73 to your computer and use it in GitHub Desktop.
example of installing xdebug inside a docker container
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM library/alpine:3.7 | |
ARG DEBUG=false | |
ARG XDEBUG_VERSION=2.6.0 | |
ARG XDEBUG_VERSION_SHA256=b5264cc03bf68fcbb04b97229f96dca505d7b87ec2fb3bd4249896783d29cbdc | |
ARG XDEBUG_SOURCE_URL=https://xdebug.org/files | |
# ( ... ) Install the php | |
# Compile, install and configure XDebug php extension | |
ARG XDEBUG_CONFIG_HOST=host.docker.internal | |
ARG XDEBUG_CONFIG_PORT=9000 | |
ARG XDEBUG_CONFIG_IDEKEY="IDEA_XDEBUG" | |
RUN set -xe && \ | |
if [[ "$DEBUG" = "true" ]] ; then \ | |
curl -L -o xdebug-${XDEBUG_VERSION}.tgz ${XDEBUG_SOURCE_URL}/xdebug-${XDEBUG_VERSION}.tgz && \ | |
if [ -n "XDEBUG_VERSION_SHA256" ]; then \ | |
echo "${XDEBUG_VERSION_SHA256} xdebug-${XDEBUG_VERSION}.tgz" | sha256sum -c - \ | |
; fi && \ | |
tar -xzf xdebug-${XDEBUG_VERSION}.tgz && \ | |
cd ./xdebug-${XDEBUG_VERSION} && \ | |
phpize && \ | |
sh ./configure --enable-xdebug && \ | |
make && \ | |
make install && \ | |
make clean && \ | |
cd ../ && \ | |
echo -e "[XDebug] \n" \ | |
"zend_extension = $(find /usr/local/lib/php/extensions/ -name xdebug.so) \n" \ | |
"xdebug.remote_enable = on \n" \ | |
"xdebug.remote_host = ${XDEBUG_CONFIG_HOST} \n" \ | |
"xdebug.remote_port = ${XDEBUG_CONFIG_PORT} \n" \ | |
"xdebug.remote_handler = \"dbgp\" \n" \ | |
"xdebug.remote_connect_back = off \n" \ | |
"xdebug.cli_color = on \n" \ | |
"xdebug.idekey = \"${XDEBUG_CONFIG_IDEKEY}\"" > /usr/local/etc/php/conf.d/xdebug.ini \ | |
; fi && \ | |
unset XDEBUG_CONFIG_HOST \ | |
XDEBUG_CONFIG_PORT \ | |
XDEBUG_CONFIG_IDEKEY | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment