Skip to content

Instantly share code, notes, and snippets.

@gerardo-junior

gerardo-junior/Dockerfile

Last active Apr 1, 2019
Embed
What would you like to do?
example of installing xdebug inside a docker container
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