Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable xdebug in docker #2014

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Enable xdebug in docker #2014

wants to merge 3 commits into from

Conversation

grubolsch
Copy link
Contributor

Added

Another attempt to get Xdebug inside our docker setup, with an optional docker profile, so you can quickly switch between both versions.
All instructions can be found inside the readme file.

This is how it will look inside docker engine.
Screenshot 2025-02-26 at 16 25 09

@@ -1,12 +1,9 @@
services:
php:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe call this php-base and still use php instead of php-cli ?

@@ -32,3 +34,15 @@ RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf

CMD ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisor/conf.d/supervisord.conf"]

# Always copy a file, but choose# Always copy a file, but choose xdebug.ini or an empty one xdebug.ini or an empty one
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a weird comment 😊

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also wonder why we need to copy the empty xdebug.ini file if ENABLE_XDEBUG would be false?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because

  1. COPY cannot be used inside an if, so I have to write always write the config file
  2. But if the config is there when xdebug is not installed, PHP will give an error because it tries to load a module that does not exists

So solutions was to overwrite the config file with an empty one, in case of no xdebug activated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could remove the xdebug config file to solve the PHP error?

docker-compose --profile xdebug up
```

You don't have to rebuild to switch, *you can just switch between versions in your docker engine*.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can you switch? Are both PHP containers running, one on port 8000 and one on port 8001 with xdebug enabled?

@LucWollants
Copy link
Contributor

I wonder how this will behave on Jenkins, because as far as I know Jenkins uses our docker-compose file?

container_name: php.uitdatabank
extends:
service: php
profiles:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct, should this not always run? I think this breaks the existing setup when not using the xdebug profile

@@ -0,0 +1,2 @@
export XDEBUG_MODE=debug XDEBUG_SESSION=1 PHP_IDE_CONFIG="serverName=host.docker.internal"
# https://github.com/cultuurnet/udb3-backend/pull/1425/files
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this doesn't have much added value?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants