Skip to content

Add Xdebug #2

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

Merged
merged 3 commits into from
Dec 31, 2016
Merged
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
17 changes: 16 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ FROM debian:jessie

ENV \
NGINX_VERSION=1.11.7 \
PHP_VERSION=7.1.0
PHP_VERSION=7.1.0 \
XDEBUG_VERSION=2.5.0

COPY \
docker-entrypoint \
Expand All @@ -16,6 +17,7 @@ RUN \
apt-get update && \
apt-get install -y --no-install-recommends \
# In general...
autoconf \
build-essential \
curl \

Expand Down Expand Up @@ -152,6 +154,18 @@ RUN \
make -j$(nproc) build && \
make install && \

# Compile Xdebug
mkdir -p /tmp/build/xdebug && \
cd /tmp/build/xdebug && \
curl -SLO \
"https://github.com/xdebug/xdebug/archive/XDEBUG_"$(echo ${XDEBUG_VERSION} | sed "s/\./_/g")".tar.gz" && \
tar -xvzf "XDEBUG_"$(echo ${XDEBUG_VERSION} | sed "s/\./_/g")".tar.gz" && \
cd "xdebug-XDEBUG_"$(echo ${XDEBUG_VERSION} | sed "s/\./_/g") && \
phpize && \
./configure && \
make && \
make install && \

# Fix permissions
chown -R www-data:www-data /usr/local/nginx/html && \

Expand Down Expand Up @@ -206,6 +220,7 @@ RUN \

# Final cleanup
apt-get remove -y \
autoconf \
bison \
build-essential \
curl \
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Nginx and PHP are compiled in a specific version. Consult the [CHANGELOG.md](./C
for further version details. [PHP Composer](https://getcomposer.org/) is already installed and ready
for use.

Xdebug is installed as shared extension, but not activated. Start the container with env
ENABLE_XDEBUG=1 to enable the extension.

The Nginx and PHP-FPM master processes are controlled by [Honcho](https://github.com/nickstenning/honcho).
Honcho was chosen over Supervisor, because honcho will exit and kill the container if either Nginx
or PHP's master process dye for any reason. If you want have to have the container restarted
Expand Down Expand Up @@ -42,6 +45,12 @@ Mount your custom `nginx.conf` file at `/usr/local/nginx/conf/nginx.conf`.
* Mount your custom `www.conf` file at `/usr/local/etc/www.conf`.
* Mount your custom `php.ini` file at `/usr/local/php/php.ini`.

### Xdebug

Xdebug was installed mainly with the idea of providing code coverage for PHPUnit. Thus it's not
configured for any specific use case. You can [configure Xdebug](https://xdebug.org/docs/all) via
`php.ini` if desired.

### Honcho

If you want to overwrite the default Honcho configuration - mount your custom `Procfile` file at `/`.
Expand Down
7 changes: 7 additions & 0 deletions docker-entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ if [[ $SKIP_COMPOSER_UPDATE != "1" ]]; then
composer selfupdate -vvvn
fi

# Enable Xdebug
# Use Xdebug if ENABLE_XDEBUG env is set to 1.
if [[ $ENABLE_XDEBUG == "1" ]]; then
echo -e "\e[32mXdebug enabled\e[0m"
echo "zend_extension = /usr/local/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so" >> /usr/local/lib/php.ini
fi

if [[ $1 == "server" ]]; then
exec honcho -d / start
fi
Expand Down