Skip to content

Commit 5c1f21c

Browse files
committed
fixes for xdebug in cli container
1 parent b3dd42a commit 5c1f21c

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

development/nginx-fpm/compose.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ services:
5252
args:
5353
UID: ${UID}
5454
GID: ${GID}
55+
XDEBUG_ENABLED: ${XDEBUG_ENABLED}
56+
XDEBUG_MODE: ${XDEBUG_MODE}
57+
XDEBUG_HOST: ${XDEBUG_HOST}
58+
XDEBUG_IDE_KEY: ${XDEBUG_IDE_KEY}
59+
XDEBUG_LOG: ${XDEBUG_LOG}
60+
XDEBUG_LOG_LEVEL: ${XDEBUG_LOG_LEVEL}
5561
tty: true # Enables an interactive terminal
5662
stdin_open: true # Keeps standard input open for 'docker exec'
5763
env_file:

development/nginx-fpm/workspace/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,25 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
3131
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
3232
&& apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
3333

34+
# Use ARG to define environment variables passed from the Docker build command or Docker Compose.
35+
ARG XDEBUG_ENABLED
36+
ARG XDEBUG_MODE
37+
ARG XDEBUG_HOST
38+
ARG XDEBUG_IDE_KEY
39+
ARG XDEBUG_LOG
40+
ARG XDEBUG_LOG_LEVEL
41+
42+
# Configure Xdebug if enabled
43+
RUN if [ "${XDEBUG_ENABLED}" = "true" ]; then \
44+
docker-php-ext-enable xdebug && \
45+
echo "xdebug.mode=${XDEBUG_MODE}" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \
46+
echo "xdebug.idekey=${XDEBUG_IDE_KEY}" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \
47+
echo "xdebug.log=${XDEBUG_LOG}" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \
48+
echo "xdebug.log_level=${XDEBUG_LOG_LEVEL}" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \
49+
echo "xdebug.client_host=${XDEBUG_HOST}" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini ; \
50+
echo "xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini ; \
51+
fi
52+
3453
# If the group already exists, use it; otherwise, create the 'www' group
3554
RUN if getent group ${GID}; then \
3655
useradd -m -u ${UID} -g ${GID} -s /bin/bash www; \

0 commit comments

Comments
 (0)