ByteInternet / hypernode-docker

Fast and easy Docker for Magento development
https://community.hypernode.io/hypernode-docker
35 stars 8 forks source link

Install Xdebug on Hypernode Docker #8

Open Bonno opened 6 years ago

Bonno commented 6 years ago

Is it possible to have xdebug preinstalled in the docker image? Possible in the same manner as for the vagrant image? https://support.hypernode.com/knowledgebase/configure-xdebug-hypernode-vagrant/

vdloo commented 6 years ago

Have you tried apt-get install php-xdebug? I don't know if there's anything different about the vagrant that might cause it to have problems, but installing that package should place the .ini files so perhaps that will just work:

root@837c5e816b80 ~ # dpkg -L php-xdebug
/.
/etc
/etc/php
/etc/php/5.5
/etc/php/5.5/mods-available
/etc/php/5.5/mods-available/xdebug.ini
/etc/php/5.6
/etc/php/5.6/mods-available
/etc/php/5.6/mods-available/xdebug.ini
/etc/php/7.0
/etc/php/7.0/mods-available
/etc/php/7.0/mods-available/xdebug.ini
/etc/php/7.1
/etc/php/7.1/mods-available
/etc/php/7.1/mods-available/xdebug.ini
/usr
/usr/lib
/usr/lib/php
/usr/lib/php/20131226
/usr/lib/php/20131226/xdebug.so
/usr/lib/php/20160303
/usr/lib/php/20160303/xdebug.so
/usr/lib/php/20121212
/usr/lib/php/20121212/xdebug.so
/usr/lib/php/20151012
/usr/lib/php/20151012/xdebug.so
/usr/share
/usr/share/doc
/usr/share/doc/php-xdebug
/usr/share/doc/php-xdebug/changelog.Debian.gz
/usr/share/doc/php-xdebug/copyright
root@837c5e816b80 ~ # php -m | grep xdebug -i
xdebug
Xdebug
Bonno commented 6 years ago

I was hoping it can be installed by default in the image. So we can use the config settings in /data/web/public/.user.ini as described in the hypernode-vagrant documentation. I'll probably can get it to work with a manual installation and configuration, but it would be cool to have this feature out-of-the-box. Not a huge issue, but since it seems to be supported on the vagrant image I was hoping it could be integrated in the docker image.

vdloo commented 6 years ago

Hi Bonno, I purposely did not put this in the default image because I think for most use-cases this would not be needed and creating a Dockerfile that adds this if you need it would be trivial. But I am a proponent of good defaults, so perhaps this is something we might consider in the future. But for now I suggest if you want to use xdebug with this Docker to create a Dockerfile that installs the package. Perhaps that would be something that you could document in this repo for other users?

Bonno commented 6 years ago

Thanks for your answers. The Dockerfile needed to make this work only needs to contain the following RUN command.

RUN apt-get update && apt-get install -y php-xdebug

Then you can set the xdebug configuration in /data/web/public/.user.ini

xdebug.show_error_trace = 1
xdebug.remote_enable = 1

; Debug from 1 specific machine (Disable xdebug.remote_connect_back for this to work.)
xdebug.remote_connect_back = 0
xdebug.remote_host = IP.address.from.host
xdebug.remote_port = 9000
xdebug.scream = 0
xdebug.show_local_vars = 1
xdebug.idekey = PHPSTORM