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

issue #6 add xdebug host address and dns for host trhought internal n… #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .docker/php-fpm/7.1/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ RUN apt-get update -qq \
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_host=XDEBUG_REMOTE_HOST" >> /usr/local/etc/php/conf.d/xdebug.ini \
Copy link
Contributor

Choose a reason for hiding this comment

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

As it's a specific configuration it's better to add a specific file like

ADD config/custom-php.ini /usr/local/etc/php/conf.d/custom-php.ini

&& docker-php-ext-install -j$(nproc) pdo pdo_pgsql zip bcmath mbstring xml curl \
&& curl -sS http://getcomposer.org/installer | php -- --filename=composer \
&& chmod a+x composer \
Expand Down
21 changes: 14 additions & 7 deletions .docker/php-fpm/7.1/config/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,25 @@ shopt -s nocasematch
if [ -z ${TZ+x} ]; then
echo "Warning : TimeZone is unset !";
else
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone ;
sudo ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ | sudo tee /etc/timezone ;
fi

if [ $XDEBUG_ENABLE == "true" ]; then
sudo sed -i "s#XDEBUG_REMOTE_HOST#$(ip r | awk '/default/{print $3}')#" /usr/local/etc/php/conf.d/xdebug.ini
else
echo "XDebug disabled";
fi

if [ $REMOTE_HOST_ENABLE == "true" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

Why configuring this variable if xdebug is disabled ?

Copy link
Author

Choose a reason for hiding this comment

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

It's in case you need the DNS for the host for something else (no more need for the external_host with the ip of the host, you can use the docker internal network)

if ! grep -Fxq "remote_host" /etc/hosts; then
echo "$(ip r | awk '/default/{print $3}') remote_host" | sudo tee --append /etc/hosts
fi;
else
echo "remote host disabled";
fi
# Starting the custom entrypointf it exists
if [ -f /docker/custom-entrypoint.sh ]; then
source /config/custom-entrypoint.sh
fi

# Moving static files to a sharedVolume with the nginx
rm -rf /nginx/*
if [ -d "/var/www/html/public" ]; then
cp -rf /var/www/html/public /nginx
fi

exec "$@"
5 changes: 2 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ services:
restart: "${RESTART_POLICIES}"
environment:
TZ: ${TIMEZONE}
XDEBUG_CONFIG: remote_host=${REMOTE_HOST}
XDEBUG_ENABLE: "true"
REMOTE_HOST_ENABLE: "true"
SSH_AUTH_SOCK: /ssh-agent
DB_USER: ${DB_USER}
DB_PASSWORD: ${DB_PASSWORD}
Expand All @@ -44,8 +45,6 @@ services:
- $SSH_AUTH_SOCK:/ssh-agent
working_dir: /var/www/html
user: "${DOCKER_USER}"
entrypoint:
- ""
command:
- "php-fpm"
networks:
Expand Down