Last active
January 25, 2018 01:48
-
-
Save melihovv/140b3b405d55729b9b3b4a436cbb1c63 to your computer and use it in GitHub Desktop.
Xdebug with docker
This file contains hidden or 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
#!/usr/bin/env bash | |
# Set environment variables for dev | |
export XDEBUG_HOST=$(ipconfig getifaddr en1) # Specific to Macintosh | |
export APP_ENV=${APP_ENV:-local} | |
if [ $# -gt 0 ]; then | |
docker-compose "$@" | |
else | |
docker-compose ps | |
fi |
This file contains hidden or 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
version: '2' | |
services: | |
app: | |
build: | |
context: . | |
image: xdebug-example:latest | |
environment: | |
APP_ENV: "${APP_ENV}" | |
XDEBUG_HOST: ${XDEBUG_HOST} | |
volumes: | |
- ./app:/var/www/html | |
ports: | |
- "80:80" |
This file contains hidden or 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 ubuntu:16.04 | |
MAINTAINER Chris Fidao | |
RUN locale-gen en_US.UTF-8 | |
ENV LANG en_US.UTF-8 | |
ENV LANGUAGE en_US:en | |
ENV LC_ALL en_US.UTF-8 | |
RUN apt-get update \ | |
&& apt-get install -y curl zip unzip git software-properties-common sqlite3 \ | |
&& add-apt-repository -y ppa:ondrej/php \ | |
&& apt-get update \ | |
&& apt-get install -y php7.0-fpm php7.0-cli php7.0-mcrypt php7.0-gd php7.0-mysql \ | |
php7.0-pgsql php7.0-imap php-memcached php7.0-mbstring php7.0-xml php7.0-curl \ | |
php7.0-sqlite3 php7.0-xdebug \ | |
&& php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer \ | |
&& mkdir /run/php \ | |
&& apt-get remove -y --purge software-properties-common \ | |
&& apt-get -y autoremove \ | |
&& apt-get clean \ | |
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | |
COPY xdebug.ini /etc/php/7.0/mods-available/xdebug.ini | |
COPY start-container /usr/local/bin/start-container | |
RUN chmod +x usr/local/bin/start-container | |
EXPOSE 80 | |
CMD ["start-container"] |
This file contains hidden or 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
#!/usr/bin/env bash | |
#!/usr/bin/env bash | |
if [ ! "production" == "$APP_ENV" ] && [ ! "prod" == "$APP_ENV" ]; then | |
# Enable xdebug | |
## FPM | |
ln -sf /etc/php/7.0/mods-available/xdebug.ini /etc/php/7.0/fpm/conf.d/20-xdebug.ini | |
## CLI | |
ln -sf /etc/php/7.0/mods-available/xdebug.ini /etc/php/7.0/cli/conf.d/20-xdebug.ini | |
else | |
# Disable xdebug | |
## FPM | |
if [ -e /etc/php/7.0/fpm/conf.d/20-xdebug.ini ]; then | |
rm -f /etc/php/7.0/fpm/conf.d/20-xdebug.ini | |
fi | |
## CLI | |
if [ -e /etc/php/7.0/cli/conf.d/20-xdebug.ini ]; then | |
rm -f /etc/php/7.0/cli/conf.d/20-xdebug.ini | |
fi | |
fi | |
sed -i "s/xdebug\.remote_host\=.*/xdebug\.remote_host\=$XDEBUG_HOST/g" /etc/php/7.0/mods-available/xdebug.ini | |
php -S 0.0.0.0:80 -t /var/www/html |
This file contains hidden or 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
zend_extension=xdebug.so | |
xdebug.remote_enable=1 | |
xdebug.remote_handler=dbgp | |
xdebug.remote_port=9000 | |
xdebug.remote_autostart=1 | |
xdebug.remote_connect_back=0 | |
xdebug.idekey=docker | |
xdebug.remote_host=??? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment