Skip to content

Commit a695ef7

Browse files
🐛 Fix XDebug Argument Passage + Make Value Configurable
1 parent b0fb152 commit a695ef7

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

Dockerfile

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ ARG NGINX_VERSION="1.17.4"
44
ARG COMPOSER_VERSION="2.0"
55
ARG XDEBUG_VERSION="3.0.3"
66
ARG COMPOSER_AUTH
7-
ARG IMAGE_DEPS="fcgi tini icu-dev gettext curl"
8-
ARG RUNTIME_DEPS="zip"
9-
107
# -------------------------------------------------- Composer Image ----------------------------------------------------
118

129
FROM composer:${COMPOSER_VERSION} as composer
@@ -19,8 +16,7 @@ FROM composer:${COMPOSER_VERSION} as composer
1916
FROM php:${PHP_VERSION}-fpm-alpine AS base
2017

2118
# Required Args ( inherited from start of file, or passed at build )
22-
ARG IMAGE_DEPS
23-
ARG RUNTIME_DEPS
19+
ARG XDEBUG_VERSION
2420

2521
# Maintainer label
2622
LABEL maintainer="sherifabdlnaby@gmail.com"
@@ -182,17 +178,22 @@ CMD ["php-fpm"]
182178

183179
FROM base as app-dev
184180

185-
ARG XDEBUG_VERSION
181+
186182
ENV APP_ENV dev
187183
ENV APP_DEBUG 1
188184

189185
# Switch root to install stuff
190186
USER root
191187

192188
# For Composer Installs
193-
RUN apk add git openssh
194-
# Enable Xdebug
195-
RUN docker-php-ext-enable xdebug
189+
RUN apk add git openssh;
190+
# Enable Xdebug
191+
docker-php-ext-enable xdebug; \
192+
193+
# For Xdebuger to work, it needs the docker host ID
194+
# - in Mac AND Windows, `host.docker.internal` resolve to Docker host IP
195+
# - in Linux, `172.17.0.1` is the host IP
196+
ENV XDEBUG_CLIENT_HOST="host.docker.internal"
196197

197198
# ---------------------------------------- ---------- Scripts ---------------------------------------------------------
198199

@@ -229,6 +230,7 @@ RUN chown -R www-data /etc/nginx/ && chmod +x /usr/local/bin/nginx-*
229230
## Localhost is the sensible default assuming image run on a k8S Pod
230231
ENV PHP_FPM_HOST "localhost"
231232
ENV PHP_FPM_PORT "9000"
233+
ENV NGINX_LOG_FORMAT "json"
232234

233235
# For Documentation
234236
EXPOSE 8080
@@ -253,4 +255,5 @@ COPY --chown=www-data:www-data --from=app /app/public /app/public
253255

254256
# ----------------------------------------------------- NGINX ----------------------------------------------------------
255257
FROM nginx AS web-dev
256-
## Place holder to have a consistent naming.
258+
259+
ENV NGINX_LOG_FORMAT "combined"

docker-compose.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ services:
1010
# Please add Composer Auth JSON Object
1111
COMPOSER_AUTH: "{}"
1212
restart: unless-stopped
13+
environment:
14+
# For Xdebuger to work, it needs the docker host ID
15+
# - in Mac AND Windows, `host.docker.internal` resolve to Docker host IP
16+
# - in Linux, `172.17.0.1` is the host IP
17+
XDEBUG_CLIENT_HOST: 'host.docker.internal'
1318
volumes:
1419
- .:/app
1520

docker/php/dev-xdebug.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ xdebug.start_with_request=yes
88
xdebug.discover_client_host=0
99
xdebug.output_dir="/app/"
1010
xdebug.client_port=9000
11-
xdebug.client_host=172.17.0.1
12-
; FOR MAC Replace xdebug.client_host with host.docker.internal
13-
; xdebug.client_host=host.docker.internal
11+
# for mac use host.docker.internal
12+
# for linux use 172.17.0.1
13+
xdebug.client_host=${XDEBUG_CLIENT_HOST}
1414
xdebug.idekey=kubephp
1515
xdebug.show_error_trace = 1
1616
xdebug.log_level=0

0 commit comments

Comments
 (0)