Skip to content
This repository was archived by the owner on Dec 7, 2018. It is now read-only.

Commit ef1495f

Browse files
committed
making xdebug easier to configure
1 parent 5dc1172 commit ef1495f

File tree

4 files changed

+55
-6
lines changed

4 files changed

+55
-6
lines changed

.env.example

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
PHP_XDEBUG_DEFAULT_ENABLE=0
2+
PHP_XDEBUG_REMOTE_ENABLE=0
3+
PHP_XDEBUG_REMOTE_HOST=127.0.0.1
4+
PHP_XDEBUG_REMOTE_PORT=9001
5+
PHP_XDEBUG_REMOTE_AUTO_START=0
6+
PHP_XDEBUG_REMOTE_CONNECT_BACK=0
7+
PHP_XDEBUG_IDEKEY=docker
8+
PHP_XDEBUG_PROFILER_ENABLE=0
9+
PHP_XDEBUG_PROFILER_OUTPUT_DIR=/tmp

Dockerfile

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@ FROM php:7.1-fpm-alpine
22

33
ARG BUILD_DATE
44
ARG VCS_REF
5+
56
ENV COMPOSER_ALLOW_SUPERUSER 1
7+
ENV PHP_XDEBUG_DEFAULT_ENABLE ${PHP_XDEBUG_DEFAULT_ENABLE:-1}
8+
ENV PHP_XDEBUG_REMOTE_ENABLE ${PHP_XDEBUG_REMOTE_ENABLE:-1}
9+
ENV PHP_XDEBUG_REMOTE_HOST ${PHP_XDEBUG_REMOTE_HOST:-"127.0.0.1"}
10+
ENV PHP_XDEBUG_REMOTE_PORT ${PHP_XDEBUG_REMOTE_PORT:-9000}
11+
ENV PHP_XDEBUG_REMOTE_AUTO_START ${PHP_XDEBUG_REMOTE_AUTO_START:-1}
12+
ENV PHP_XDEBUG_REMOTE_CONNECT_BACK ${PHP_XDEBUG_REMOTE_CONNECT_BACK:-1}
13+
ENV PHP_XDEBUG_IDEKEY ${PHP_XDEBUG_IDEKEY:-docker}
14+
ENV PHP_XDEBUG_PROFILER_ENABLE ${PHP_XDEBUG_PROFILER_ENABLE:-0}
15+
ENV PHP_XDEBUG_PROFILER_OUTPUT_DIR ${PHP_XDEBUG_PROFILER_OUTPUT_DIR:-"/tmp"}
616

717
LABEL Maintainer="Zaher Ghaibeh <z@zah.me>" \
818
Description="Lightweight php 7.1 container based on alpine with xDebug enabled, SOPAP extensions enabled & composer installed." \
@@ -22,17 +32,12 @@ RUN apk update \
2232
&& docker-php-ext-enable xdebug redis \
2333
&& docker-php-source delete \
2434
&& docker-php-ext-install mcrypt pdo_mysql soap intl zip \
25-
&& echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
26-
&& echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
27-
&& echo "xdebug.remote_port=9000" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
28-
&& echo "xdebug.remote_handler=dbgp" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
29-
&& echo "xdebug.remote_connect_back=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
3035
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
3136
&& apk del build-dependencies \
3237
&& apk del libmcrypt-dev \
3338
&& rm -rf /tmp/*
3439

35-
# COPY php.ini /usr/local/etc/php/
40+
COPY xdebug.ini /usr/local/etc/php/conf.d/xdebug-dev.ini
3641

3742
USER www-data
3843

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,28 @@
44

55
This image contain php-7.1 based on alpine with xDebug enabled and Composer installed
66

7+
## Run the image:
8+
9+
By default xdebug is enabled, to disable it you need to create a `.env` file which should contain the following variables, but remember to change the value based one what you want to achieve:
10+
11+
```
12+
PHP_XDEBUG_DEFAULT_ENABLE=0
13+
PHP_XDEBUG_REMOTE_ENABLE=0
14+
PHP_XDEBUG_REMOTE_HOST=127.0.0.1
15+
PHP_XDEBUG_REMOTE_PORT=9001
16+
PHP_XDEBUG_REMOTE_AUTO_START=0
17+
PHP_XDEBUG_REMOTE_CONNECT_BACK=0
18+
PHP_XDEBUG_IDEKEY=docker
19+
PHP_XDEBUG_PROFILER_ENABLE=0
20+
PHP_XDEBUG_PROFILER_OUTPUT_DIR=/tmp
21+
```
22+
23+
Then run the docker and specify the env file that you have created like this
24+
25+
```
26+
docker run --env-file .env -p 80:80 zaherg/php-7.1-xdebug-alpine
27+
```
28+
729
## Installed modules information
830

931
It has the following modules:

xdebug.ini

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[xdebug]
2+
xdebug.default_enable=${PHP_XDEBUG_DEFAULT_ENABLE}
3+
xdebug.remote_enable=${PHP_XDEBUG_REMOTE_ENABLE}
4+
xdebug.remote_handler=dbgp
5+
xdebug.remote_port=${PHP_XDEBUG_REMOTE_PORT}
6+
xdebug.remote_host=${PHP_XDEBUG_REMOTE_HOST}
7+
xdebug.remote_autostart=${PHP_XDEBUG_REMOTE_AUTO_START}
8+
xdebug.remote_connect_back=${PHP_XDEBUG_REMOTE_CONNECT_BACK}
9+
xdebug.idekey=${PHP_XDEBUG_IDEKEY}
10+
11+
; profiler
12+
xdebug.profiler_enable = ${PHP_XDEBUG_PROFILER_ENABLE}
13+
xdebug.profiler_output_dir = ${PHP_XDEBUG_PROFILER_OUTPUT_DIR}

0 commit comments

Comments
 (0)