Skip to content

Commit 00b015a

Browse files
authored
MCLOUD-6430: Xdebug not working on Magento Cloud Docker 1.1 (#282)
1 parent d18e951 commit 00b015a

File tree

14 files changed

+49
-7
lines changed

14 files changed

+49
-7
lines changed

images/php/7.2-fpm/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ ENV MAGENTO_RUN_MODE production
99
ENV UPLOAD_MAX_FILESIZE 64M
1010
ENV UPDATE_UID_GID false
1111
ENV ENABLE_SENDMAIL true
12+
ENV SET_DOCKER_HOST false
1213

1314
ENV PHP_EXTENSIONS bcmath bz2 calendar exif gd gettext intl mysqli opcache pdo_mysql redis soap sockets sysvmsg sysvsem sysvshm xsl zip pcntl
1415

images/php/7.2-fpm/docker-entrypoint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,11 @@ fi
5858
# Configure PHP-FPM
5959
[ ! -z "${MAGENTO_RUN_MODE}" ] && sed -i "s/!MAGENTO_RUN_MODE!/${MAGENTO_RUN_MODE}/" /usr/local/etc/php-fpm.conf
6060

61+
# Set host.docker.inernal for LINUX os
62+
if [[ "$SET_DOCKER_HOST" = "true" ]]; then
63+
apt update
64+
apt install -y iproute2
65+
echo -e "`/sbin/ip route|awk '/default/ { print $3 }'`\thost.docker.internal" | sudo tee -a /etc/hosts > /dev/null
66+
fi
67+
6168
exec "$@"

images/php/7.3-fpm/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ ENV MAGENTO_RUN_MODE production
99
ENV UPLOAD_MAX_FILESIZE 64M
1010
ENV UPDATE_UID_GID false
1111
ENV ENABLE_SENDMAIL true
12+
ENV SET_DOCKER_HOST false
1213

1314
ENV PHP_EXTENSIONS bcmath bz2 calendar exif gd gettext intl mysqli opcache pdo_mysql redis soap sockets sysvmsg sysvsem sysvshm xsl zip pcntl
1415

images/php/7.3-fpm/docker-entrypoint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,11 @@ fi
5858
# Configure PHP-FPM
5959
[ ! -z "${MAGENTO_RUN_MODE}" ] && sed -i "s/!MAGENTO_RUN_MODE!/${MAGENTO_RUN_MODE}/" /usr/local/etc/php-fpm.conf
6060

61+
# Set host.docker.inernal for LINUX os
62+
if [[ "$SET_DOCKER_HOST" = "true" ]]; then
63+
apt update
64+
apt install -y iproute2
65+
echo -e "`/sbin/ip route|awk '/default/ { print $3 }'`\thost.docker.internal" | sudo tee -a /etc/hosts > /dev/null
66+
fi
67+
6168
exec "$@"

images/php/7.4-fpm/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ ENV MAGENTO_RUN_MODE production
99
ENV UPLOAD_MAX_FILESIZE 64M
1010
ENV UPDATE_UID_GID false
1111
ENV ENABLE_SENDMAIL true
12+
ENV SET_DOCKER_HOST false
1213

1314
ENV PHP_EXTENSIONS bcmath bz2 calendar exif gd gettext intl mysqli opcache pdo_mysql redis soap sockets sysvmsg sysvsem sysvshm xsl zip pcntl
1415

images/php/7.4-fpm/docker-entrypoint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,11 @@ fi
5858
# Configure PHP-FPM
5959
[ ! -z "${MAGENTO_RUN_MODE}" ] && sed -i "s/!MAGENTO_RUN_MODE!/${MAGENTO_RUN_MODE}/" /usr/local/etc/php-fpm.conf
6060

61+
# Set host.docker.inernal for LINUX os
62+
if [[ "$SET_DOCKER_HOST" = "true" ]]; then
63+
apt update
64+
apt install -y iproute2
65+
echo -e "`/sbin/ip route|awk '/default/ { print $3 }'`\thost.docker.internal" | sudo tee -a /etc/hosts > /dev/null
66+
fi
67+
6168
exec "$@"

images/php/fpm/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ ENV MAGENTO_RUN_MODE production
99
ENV UPLOAD_MAX_FILESIZE 64M
1010
ENV UPDATE_UID_GID false
1111
ENV ENABLE_SENDMAIL true
12+
ENV SET_DOCKER_HOST false
1213

1314
{%env_php_extensions%}
1415

images/php/fpm/docker-entrypoint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,11 @@ fi
5858
# Configure PHP-FPM
5959
[ ! -z "${MAGENTO_RUN_MODE}" ] && sed -i "s/!MAGENTO_RUN_MODE!/${MAGENTO_RUN_MODE}/" /usr/local/etc/php-fpm.conf
6060

61+
# Set host.docker.inernal for LINUX os
62+
if [[ "$SET_DOCKER_HOST" = "true" ]]; then
63+
apt update
64+
apt install -y iproute2
65+
echo -e "`/sbin/ip route|awk '/default/ { print $3 }'`\thost.docker.internal" | sudo tee -a /etc/hosts > /dev/null
66+
fi
67+
6168
exec "$@"

src/Command/BuildCompose.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ protected function configure(): void
171171
null,
172172
InputOption::VALUE_NONE,
173173
'Disable mailhog'
174+
)->addOption(
175+
Source\CliSource::OPTION_SET_DOCKER_HOST_XDEBUG,
176+
null,
177+
InputOption::VALUE_NONE,
178+
'Sets host.docker.internal for fpm_xdebug container to resolve debug issue for LINUX system'
174179
);
175180

176181
$this->addOption(

src/Compose/ProductionBuilder.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,14 +333,18 @@ public function build(Config $config): Manager
333333
* Include Xdebug if --with-xdebug is set
334334
*/
335335
if ($config->hasServiceEnabled(ServiceInterface::SERVICE_FPM_XDEBUG)) {
336+
$envVariables = ['PHP_EXTENSIONS' => implode(' ', array_unique(array_merge($phpExtensions, ['xdebug'])))];
337+
if ($config->get(SourceInterface::SYSTEM_SET_DOCKER_HOST)) {
338+
$envVariables['SET_DOCKER_HOST'] = true;
339+
}
336340
$manager->addService(
337341
self::SERVICE_FPM_XDEBUG,
338342
$this->serviceFactory->create(
339343
ServiceInterface::SERVICE_FPM_XDEBUG,
340344
$phpVersion,
341345
[
342346
'volumes' => $volumesRo,
343-
'environment' => $this->converter->convert(['PHP_EXTENSIONS' => implode(' ', $phpExtensions)])
347+
'environment' => $this->converter->convert($envVariables)
344348
]
345349
),
346350
[self::NETWORK_MAGENTO],

0 commit comments

Comments
 (0)