Skip to content

Commit 71f8f70

Browse files
authored
Merge pull request #2 from rtucek/add/xdebug
Add Xdebug
2 parents f9fcc14 + 885bcac commit 71f8f70

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

Dockerfile

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ FROM debian:jessie
22

33
ENV \
44
NGINX_VERSION=1.11.7 \
5-
PHP_VERSION=7.1.0
5+
PHP_VERSION=7.1.0 \
6+
XDEBUG_VERSION=2.5.0
67

78
COPY \
89
docker-entrypoint \
@@ -16,6 +17,7 @@ RUN \
1617
apt-get update && \
1718
apt-get install -y --no-install-recommends \
1819
# In general...
20+
autoconf \
1921
build-essential \
2022
curl \
2123

@@ -152,6 +154,18 @@ RUN \
152154
make -j$(nproc) build && \
153155
make install && \
154156

157+
# Compile Xdebug
158+
mkdir -p /tmp/build/xdebug && \
159+
cd /tmp/build/xdebug && \
160+
curl -SLO \
161+
"https://github.com/xdebug/xdebug/archive/XDEBUG_"$(echo ${XDEBUG_VERSION} | sed "s/\./_/g")".tar.gz" && \
162+
tar -xvzf "XDEBUG_"$(echo ${XDEBUG_VERSION} | sed "s/\./_/g")".tar.gz" && \
163+
cd "xdebug-XDEBUG_"$(echo ${XDEBUG_VERSION} | sed "s/\./_/g") && \
164+
phpize && \
165+
./configure && \
166+
make && \
167+
make install && \
168+
155169
# Fix permissions
156170
chown -R www-data:www-data /usr/local/nginx/html && \
157171

@@ -206,6 +220,7 @@ RUN \
206220

207221
# Final cleanup
208222
apt-get remove -y \
223+
autoconf \
209224
bison \
210225
build-essential \
211226
curl \

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ Nginx and PHP are compiled in a specific version. Consult the [CHANGELOG.md](./C
1010
for further version details. [PHP Composer](https://getcomposer.org/) is already installed and ready
1111
for use.
1212

13+
Xdebug is installed as shared extension, but not activated. Start the container with env
14+
ENABLE_XDEBUG=1 to enable the extension.
15+
1316
The Nginx and PHP-FPM master processes are controlled by [Honcho](https://github.com/nickstenning/honcho).
1417
Honcho was chosen over Supervisor, because honcho will exit and kill the container if either Nginx
1518
or PHP's master process dye for any reason. If you want have to have the container restarted
@@ -42,6 +45,12 @@ Mount your custom `nginx.conf` file at `/usr/local/nginx/conf/nginx.conf`.
4245
* Mount your custom `www.conf` file at `/usr/local/etc/www.conf`.
4346
* Mount your custom `php.ini` file at `/usr/local/php/php.ini`.
4447

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

4756
If you want to overwrite the default Honcho configuration - mount your custom `Procfile` file at `/`.

docker-entrypoint

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ if [[ $SKIP_COMPOSER_UPDATE != "1" ]]; then
1616
composer selfupdate -vvvn
1717
fi
1818

19+
# Enable Xdebug
20+
# Use Xdebug if ENABLE_XDEBUG env is set to 1.
21+
if [[ $ENABLE_XDEBUG == "1" ]]; then
22+
echo -e "\e[32mXdebug enabled\e[0m"
23+
echo "zend_extension = /usr/local/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so" >> /usr/local/lib/php.ini
24+
fi
25+
1926
if [[ $1 == "server" ]]; then
2027
exec honcho -d / start
2128
fi

0 commit comments

Comments
 (0)