Skip to content

Commit f775576

Browse files
authored
Merge pull request #45 from aakb/feature/xdebug3
SERV-390: Xdebug 3.x in PHP >= 7.3 images
2 parents 371583e + 556c96f commit f775576

File tree

10 files changed

+100
-89
lines changed

10 files changed

+100
-89
lines changed

php7.3-fpm/Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:18.04
1+
FROM ubuntu:20.04
22
LABEL maintainer "ITK Dev <[email protected]>"
33

44
ENV PHP_VERSION 7.3
@@ -10,12 +10,13 @@ RUN DEBIAN_FRONTEND=noninteractive \
1010
apt-get install -y \
1111
apt-utils
1212

13-
RUN apt-get install -y language-pack-en-base \
13+
RUN DEBIAN_FRONTEND=noninteractive \
14+
apt-get install -y language-pack-en-base \
1415
software-properties-common \
1516
&& locale-gen en_US.UTF-8
1617

1718
# Add php repositories
18-
RUN LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php \
19+
RUN DEBIAN_FRONTEND=noninteractive LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php \
1920
&& apt-get update
2021

2122
# Clean up
@@ -59,7 +60,6 @@ RUN DEBIAN_FRONTEND=noninteractive \
5960
imagemagick \
6061
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
6162

62-
RUN mkdir /var/run/php/
6363
COPY etc/ /etc/
6464

6565
# Configure php
Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,14 @@
1-
{{ if getenv "PHP_XDEBUG" }}
1+
{{$mode := getenv "XDEBUG_MODE" }}
2+
{{ if eq $mode "debug"}}
23
zend_extension=xdebug.so
3-
xdebug.max_nesting_level = {{ getenv "PHP_XDEBUG_MAX_NESTING_LEVEL" "256" }}
4-
xdebug.remote_addr_header = "{{ getenv "PHP_XDEBUG_REMOTE_ADDR_HEADER" "" }}"
5-
xdebug.remote_autostart = {{ getenv "PHP_XDEBUG_REMOTE_AUTOSTART" "0" }}
6-
xdebug.remote_connect_back = {{ getenv "PHP_XDEBUG_REMOTE_CONNECT_BACK" "1" }}
7-
xdebug.remote_enable = {{ getenv "PHP_XDEBUG_REMOTE_ENABLE" "1" }}
8-
xdebug.remote_handler = {{ getenv "PHP_XDEBUG_REMOTE_HANDLER" "dbgp" }}
9-
xdebug.remote_host = {{ getenv "PHP_XDEBUG_REMOTE_HOST" "localhost" }}
10-
xdebug.remote_log = "{{ getenv "PHP_XDEBUG_REMOTE_LOG" "" }}"
11-
xdebug.remote_mode = {{ getenv "PHP_XDEBUG_REMOTE_MODE" "req" }}
12-
xdebug.remote_port = {{ getenv "PHP_XDEBUG_REMOTE_PORT" "9000" }}
13-
14-
{{ if getenv "PHP_XDEBUG_PROFILER" }}
15-
xdebug.profiler_aggregate = {{ getenv "PHP_XDEBUG_PROFILER_AGGREGATE" "0" }}
16-
xdebug.profiler_append = {{ getenv "PHP_XDEBUG_PROFILER_APPEND" "0" }}
17-
xdebug.profiler_enable = {{ getenv "PHP_XDEBUG_PROFILER_ENABLE" "0" }}
18-
xdebug.profiler_enable_trigger = {{ getenv "PHP_XDEBUG_PROFILER_ENABLE_TRIGGER" "0" }}
19-
xdebug.profiler_enable_trigger_value = "{{ getenv "PHP_XDEBUG_PROFILER_ENABLE_TRIGGER_VALUE" "" }}"
20-
xdebug.profiler_output_dir = {{ getenv "PHP_XDEBUG_PROFILER_FILES_DIR" }}/xdebug/profiler
21-
xdebug.profiler_output_name = {{ getenv "PHP_XDEBUG_PROFILER_OUTPUT_NAME" "cachegrind.out.%p" }}
4+
xdebug.max_nesting_level = {{ getenv "XDEBUG_MAX_NESTING_LEVEL" "256" }}
225
{{ end }}
6+
{{ if eq $mode "profile"}}
7+
zend_extension=xdebug.so
238

24-
{{ end }}
9+
xdebug.max_nesting_level = {{ getenv "XDEBUG_MAX_NESTING_LEVEL" "256" }}
10+
xdebug.profiler_append = {{ getenv "XDEBUG_PROFILER_APPEND" "0" }}
11+
xdebug.output_dir = {{ getenv "XDEBUG_PROFILER_FILES_DIR" }}/xdebug/profiler
12+
xdebug.profiler_output_name = {{ getenv "XDEBUG_PROFILER_OUTPUT_NAME" "cachegrind.out.%p" }}
13+
xdebug.trigger_value= "{{ getenv "XDEBUG_PROFILER_ENABLE_TRIGGER_VALUE" "" }}"
14+
{{ end }}

php7.4-fpm/Dockerfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:18.04
1+
FROM ubuntu:20.04
22
LABEL maintainer "ITK Dev <[email protected]>"
33

44
ENV PHP_VERSION 7.4
@@ -10,16 +10,18 @@ RUN DEBIAN_FRONTEND=noninteractive \
1010
apt-get install -y \
1111
apt-utils
1212

13-
RUN apt-get install -y language-pack-en-base \
13+
RUN DEBIAN_FRONTEND=noninteractive \
14+
apt-get install -y language-pack-en-base \
1415
software-properties-common \
1516
&& locale-gen en_US.UTF-8
1617

1718
# Add php repositories
18-
RUN LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php \
19+
RUN DEBIAN_FRONTEND=noninteractive LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php \
1920
&& apt-get update
2021

2122
# Clean up
22-
RUN apt-get remove -y software-properties-common language-pack-en-base \
23+
RUN DEBIAN_FRONTEND=noninteractive \
24+
apt-get remove -y software-properties-common language-pack-en-base \
2325
&& apt-get autoremove -y
2426

2527
RUN DEBIAN_FRONTEND=noninteractive \
@@ -59,7 +61,6 @@ RUN DEBIAN_FRONTEND=noninteractive \
5961
imagemagick \
6062
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
6163

62-
RUN mkdir /var/run/php/
6364
COPY etc/ /etc/
6465

6566
# Configure php
Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,14 @@
1-
{{ if getenv "PHP_XDEBUG" }}
1+
{{$mode := getenv "XDEBUG_MODE" }}
2+
{{ if eq $mode "debug"}}
23
zend_extension=xdebug.so
3-
xdebug.max_nesting_level = {{ getenv "PHP_XDEBUG_MAX_NESTING_LEVEL" "256" }}
4-
xdebug.remote_addr_header = "{{ getenv "PHP_XDEBUG_REMOTE_ADDR_HEADER" "" }}"
5-
xdebug.remote_autostart = {{ getenv "PHP_XDEBUG_REMOTE_AUTOSTART" "0" }}
6-
xdebug.remote_connect_back = {{ getenv "PHP_XDEBUG_REMOTE_CONNECT_BACK" "1" }}
7-
xdebug.remote_enable = {{ getenv "PHP_XDEBUG_REMOTE_ENABLE" "1" }}
8-
xdebug.remote_handler = {{ getenv "PHP_XDEBUG_REMOTE_HANDLER" "dbgp" }}
9-
xdebug.remote_host = {{ getenv "PHP_XDEBUG_REMOTE_HOST" "localhost" }}
10-
xdebug.remote_log = "{{ getenv "PHP_XDEBUG_REMOTE_LOG" "" }}"
11-
xdebug.remote_mode = {{ getenv "PHP_XDEBUG_REMOTE_MODE" "req" }}
12-
xdebug.remote_port = {{ getenv "PHP_XDEBUG_REMOTE_PORT" "9000" }}
13-
14-
{{ if getenv "PHP_XDEBUG_PROFILER" }}
15-
xdebug.profiler_aggregate = {{ getenv "PHP_XDEBUG_PROFILER_AGGREGATE" "0" }}
16-
xdebug.profiler_append = {{ getenv "PHP_XDEBUG_PROFILER_APPEND" "0" }}
17-
xdebug.profiler_enable = {{ getenv "PHP_XDEBUG_PROFILER_ENABLE" "0" }}
18-
xdebug.profiler_enable_trigger = {{ getenv "PHP_XDEBUG_PROFILER_ENABLE_TRIGGER" "0" }}
19-
xdebug.profiler_enable_trigger_value = "{{ getenv "PHP_XDEBUG_PROFILER_ENABLE_TRIGGER_VALUE" "" }}"
20-
xdebug.profiler_output_dir = {{ getenv "PHP_XDEBUG_PROFILER_FILES_DIR" }}/xdebug/profiler
21-
xdebug.profiler_output_name = {{ getenv "PHP_XDEBUG_PROFILER_OUTPUT_NAME" "cachegrind.out.%p" }}
4+
xdebug.max_nesting_level = {{ getenv "XDEBUG_MAX_NESTING_LEVEL" "256" }}
225
{{ end }}
6+
{{ if eq $mode "profile"}}
7+
zend_extension=xdebug.so
238

24-
{{ end }}
9+
xdebug.max_nesting_level = {{ getenv "XDEBUG_MAX_NESTING_LEVEL" "256" }}
10+
xdebug.profiler_append = {{ getenv "XDEBUG_PROFILER_APPEND" "0" }}
11+
xdebug.output_dir = {{ getenv "XDEBUG_PROFILER_FILES_DIR" }}/xdebug/profiler
12+
xdebug.profiler_output_name = {{ getenv "XDEBUG_PROFILER_OUTPUT_NAME" "cachegrind.out.%p" }}
13+
xdebug.trigger_value= "{{ getenv "XDEBUG_PROFILER_ENABLE_TRIGGER_VALUE" "" }}"
14+
{{ end }}

php8.0-fpm/Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@ RUN DEBIAN_FRONTEND=noninteractive \
1010
apt-get install -y \
1111
apt-utils
1212

13-
RUN apt-get install -y language-pack-en-base \
13+
RUN DEBIAN_FRONTEND=noninteractive \
14+
apt-get install -y language-pack-en-base \
1415
software-properties-common \
1516
&& locale-gen en_US.UTF-8
1617

1718
# Add php repositories
18-
RUN LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php \
19+
RUN DEBIAN_FRONTEND=noninteractive LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php \
1920
&& apt-get update
2021

2122
# Clean up
22-
RUN apt-get remove -y software-properties-common language-pack-en-base \
23+
RUN DEBIAN_FRONTEND=noninteractive \
24+
apt-get remove -y software-properties-common language-pack-en-base \
2325
&& apt-get autoremove -y
2426

2527
RUN DEBIAN_FRONTEND=noninteractive \
Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,14 @@
1-
{{ if getenv "PHP_XDEBUG" }}
1+
{{$mode := getenv "XDEBUG_MODE" }}
2+
{{ if eq $mode "debug"}}
23
zend_extension=xdebug.so
3-
xdebug.max_nesting_level = {{ getenv "PHP_XDEBUG_MAX_NESTING_LEVEL" "256" }}
4-
xdebug.remote_addr_header = "{{ getenv "PHP_XDEBUG_REMOTE_ADDR_HEADER" "" }}"
5-
xdebug.remote_autostart = {{ getenv "PHP_XDEBUG_REMOTE_AUTOSTART" "0" }}
6-
xdebug.remote_connect_back = {{ getenv "PHP_XDEBUG_REMOTE_CONNECT_BACK" "1" }}
7-
xdebug.remote_enable = {{ getenv "PHP_XDEBUG_REMOTE_ENABLE" "1" }}
8-
xdebug.remote_handler = {{ getenv "PHP_XDEBUG_REMOTE_HANDLER" "dbgp" }}
9-
xdebug.remote_host = {{ getenv "PHP_XDEBUG_REMOTE_HOST" "localhost" }}
10-
xdebug.remote_log = "{{ getenv "PHP_XDEBUG_REMOTE_LOG" "" }}"
11-
xdebug.remote_mode = {{ getenv "PHP_XDEBUG_REMOTE_MODE" "req" }}
12-
xdebug.remote_port = {{ getenv "PHP_XDEBUG_REMOTE_PORT" "9000" }}
13-
14-
{{ if getenv "PHP_XDEBUG_PROFILER" }}
15-
xdebug.profiler_aggregate = {{ getenv "PHP_XDEBUG_PROFILER_AGGREGATE" "0" }}
16-
xdebug.profiler_append = {{ getenv "PHP_XDEBUG_PROFILER_APPEND" "0" }}
17-
xdebug.profiler_enable = {{ getenv "PHP_XDEBUG_PROFILER_ENABLE" "0" }}
18-
xdebug.profiler_enable_trigger = {{ getenv "PHP_XDEBUG_PROFILER_ENABLE_TRIGGER" "0" }}
19-
xdebug.profiler_enable_trigger_value = "{{ getenv "PHP_XDEBUG_PROFILER_ENABLE_TRIGGER_VALUE" "" }}"
20-
xdebug.profiler_output_dir = {{ getenv "PHP_XDEBUG_PROFILER_FILES_DIR" }}/xdebug/profiler
21-
xdebug.profiler_output_name = {{ getenv "PHP_XDEBUG_PROFILER_OUTPUT_NAME" "cachegrind.out.%p" }}
4+
xdebug.max_nesting_level = {{ getenv "XDEBUG_MAX_NESTING_LEVEL" "256" }}
225
{{ end }}
6+
{{ if eq $mode "profile"}}
7+
zend_extension=xdebug.so
238

24-
{{ end }}
9+
xdebug.max_nesting_level = {{ getenv "XDEBUG_MAX_NESTING_LEVEL" "256" }}
10+
xdebug.profiler_append = {{ getenv "XDEBUG_PROFILER_APPEND" "0" }}
11+
xdebug.output_dir = {{ getenv "XDEBUG_PROFILER_FILES_DIR" }}/xdebug/profiler
12+
xdebug.profiler_output_name = {{ getenv "XDEBUG_PROFILER_OUTPUT_NAME" "cachegrind.out.%p" }}
13+
xdebug.trigger_value= "{{ getenv "XDEBUG_PROFILER_ENABLE_TRIGGER_VALUE" "" }}"
14+
{{ end }}

scripts/itkdev-docker-compose

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,48 @@ EOF
426426
;;
427427

428428
xdebug)
429+
echo "Deprecated command use xdebug2 (PHP =< 7.2) or xdebug3 (PHP >= 7.3)"
430+
;;
431+
432+
xdebug2)
429433
PHP_XDEBUG=1 \
430434
PHP_XDEBUG_REMOTE_AUTOSTART=1 \
431-
PHP_XDEBUG_REMOTE_PORT=9000 \
432-
PHP_XDEBUG_REMOTE_CONNECT_BACK=0 \
435+
docker_compose up -d
436+
437+
cat <<'EOF' | sed "s|«project directory»|$PWD|"
438+
439+
================================================================================
440+
441+
To debug from the command line, add `PHP_IDE_CONFIG=serverName=localhost` to the
442+
`phpfpm` environment:
443+
444+
# docker-compose.yml
445+
phpfpm:
446+
image: itkdev/php7.2-fpm:latest
447+
environment:
448+
449+
- PHP_IDE_CONFIG=serverName=localhost
450+
451+
and define "localhost" as a server in PhpStorm (Preferences > Languages &
452+
Frameworks > PHP > Servers):
453+
454+
Name: localhost
455+
Host: localhost
456+
Path mapping: «project directory» → /app
457+
458+
You may also want to uncheck "Force break at first line when no path mapping
459+
specified" and/or "Force break at first line when a script is outside the
460+
project" in PhpStorm (Preferences > Languages & Frameworks > PHP > Debug).
461+
462+
================================================================================
463+
464+
EOF
465+
;;
466+
467+
xdebug3)
468+
XDEBUG_MODE=debug \
469+
XDEBUG_SESSION=1 \
470+
XDEBUG_CONFIG="client_host=host.docker.internal start_with_request=yes" \
433471
docker_compose up -d
434472

435473
cat <<'EOF' | sed "s|«project directory»|$PWD|"

templates/drupal-7/docker-compose.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ services:
2323
#- ENCRYPT=1 # Uncomment to enable database encryption.
2424

2525
phpfpm:
26-
image: itkdev/php7.2-fpm:latest
26+
image: itkdev/php7.4-fpm:latest
2727
networks:
2828
- app
2929
environment:
30-
- PHP_XDEBUG=${PHP_XDEBUG:-0}
31-
- PHP_XDEBUG_REMOTE_AUTOSTART=${PHP_XDEBUG_REMOTE_AUTOSTART:-0}
32-
- PHP_XDEBUG_REMOTE_CONNECT_BACK=${PHP_XDEBUG_REMOTE_CONNECT_BACK:-0}
30+
- XDEBUG_MODE=${XDEBUG_MODE:-no}
31+
- XDEBUG_CONFIG=${XDEBUG_CONFIG}
32+
- XDEBUG_SESSION=${XDEBUG_SESSION:-0}
3333
- PHP_MAX_EXECUTION_TIME=30
3434
- PHP_MEMORY_LIMIT=256M
3535
# - PHP_MAIL=1 # Uncomment to enable mailhog.

templates/drupal-8/docker-compose.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ services:
2323
#- ENCRYPT=1 # Uncomment to enable database encryption.
2424

2525
phpfpm:
26-
image: itkdev/php7.2-fpm:latest
26+
image: itkdev/php7.4-fpm:latest
2727
networks:
2828
- app
2929
environment:
30-
- PHP_XDEBUG=${PHP_XDEBUG:-0}
31-
- PHP_XDEBUG_REMOTE_AUTOSTART=${PHP_XDEBUG_REMOTE_AUTOSTART:-0}
32-
- PHP_XDEBUG_REMOTE_CONNECT_BACK=${PHP_XDEBUG_REMOTE_CONNECT_BACK:-0}
30+
- XDEBUG_MODE=${XDEBUG_MODE:-no}
31+
- XDEBUG_CONFIG=${XDEBUG_CONFIG}
32+
- XDEBUG_SESSION=${XDEBUG_SESSION:-0}
3333
- PHP_MAX_EXECUTION_TIME=30
3434
- PHP_MEMORY_LIMIT=256M
3535
# - PHP_MAIL=1 # Uncomment to enable mailhog.

templates/symfony-4/docker-compose.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ services:
2323
#- ENCRYPT=1 # Uncomment to enable database encryption.
2424

2525
phpfpm:
26-
image: itkdev/php7.2-fpm:latest
26+
image: itkdev/php7.4-fpm:latest
2727
networks:
2828
- app
2929
environment:
30-
- PHP_XDEBUG=${PHP_XDEBUG:-0}
31-
- PHP_XDEBUG_REMOTE_AUTOSTART=${PHP_XDEBUG_REMOTE_AUTOSTART:-0}
32-
- PHP_XDEBUG_REMOTE_CONNECT_BACK=${PHP_XDEBUG_REMOTE_CONNECT_BACK:-0}
30+
- XDEBUG_MODE=${XDEBUG_MODE:-no}
31+
- XDEBUG_CONFIG=${XDEBUG_CONFIG}
32+
- XDEBUG_SESSION=${XDEBUG_SESSION:-0}
3333
- PHP_MAX_EXECUTION_TIME=30
3434
- PHP_MEMORY_LIMIT=256M
3535
# - PHP_MAIL=1 # Uncomment to enable mailhog.

0 commit comments

Comments
 (0)