Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions images/php/7.2-fpm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ ENV MAGENTO_RUN_MODE production
ENV UPLOAD_MAX_FILESIZE 64M
ENV UPDATE_UID_GID false
ENV ENABLE_SENDMAIL true
ENV SET_DOCKER_HOST false

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

Expand Down
7 changes: 7 additions & 0 deletions images/php/7.2-fpm/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,11 @@ fi
# Configure PHP-FPM
[ ! -z "${MAGENTO_RUN_MODE}" ] && sed -i "s/!MAGENTO_RUN_MODE!/${MAGENTO_RUN_MODE}/" /usr/local/etc/php-fpm.conf

# Set host.docker.inernal for LINUX os
if [[ "$SET_DOCKER_HOST" = "true" ]]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have it enabled by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need it by default? This option has a sense only for Linux system.
Also I tested it on macOS with generated host.docker.inernal and xdebug didn't work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ic, thanks

apt update
apt install -y iproute2
echo -e "`/sbin/ip route|awk '/default/ { print $3 }'`\thost.docker.internal" | sudo tee -a /etc/hosts > /dev/null
fi

exec "$@"
1 change: 1 addition & 0 deletions images/php/7.3-fpm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ ENV MAGENTO_RUN_MODE production
ENV UPLOAD_MAX_FILESIZE 64M
ENV UPDATE_UID_GID false
ENV ENABLE_SENDMAIL true
ENV SET_DOCKER_HOST false

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

Expand Down
7 changes: 7 additions & 0 deletions images/php/7.3-fpm/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,11 @@ fi
# Configure PHP-FPM
[ ! -z "${MAGENTO_RUN_MODE}" ] && sed -i "s/!MAGENTO_RUN_MODE!/${MAGENTO_RUN_MODE}/" /usr/local/etc/php-fpm.conf

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

exec "$@"
1 change: 1 addition & 0 deletions images/php/7.4-fpm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ ENV MAGENTO_RUN_MODE production
ENV UPLOAD_MAX_FILESIZE 64M
ENV UPDATE_UID_GID false
ENV ENABLE_SENDMAIL true
ENV SET_DOCKER_HOST false

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

Expand Down
7 changes: 7 additions & 0 deletions images/php/7.4-fpm/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,11 @@ fi
# Configure PHP-FPM
[ ! -z "${MAGENTO_RUN_MODE}" ] && sed -i "s/!MAGENTO_RUN_MODE!/${MAGENTO_RUN_MODE}/" /usr/local/etc/php-fpm.conf

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

exec "$@"
1 change: 1 addition & 0 deletions images/php/fpm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ ENV MAGENTO_RUN_MODE production
ENV UPLOAD_MAX_FILESIZE 64M
ENV UPDATE_UID_GID false
ENV ENABLE_SENDMAIL true
ENV SET_DOCKER_HOST false

{%env_php_extensions%}

Expand Down
7 changes: 7 additions & 0 deletions images/php/fpm/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,11 @@ fi
# Configure PHP-FPM
[ ! -z "${MAGENTO_RUN_MODE}" ] && sed -i "s/!MAGENTO_RUN_MODE!/${MAGENTO_RUN_MODE}/" /usr/local/etc/php-fpm.conf

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

exec "$@"
5 changes: 5 additions & 0 deletions src/Command/BuildCompose.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ protected function configure(): void
null,
InputOption::VALUE_NONE,
'Disable mailhog'
)->addOption(
Source\CliSource::OPTION_SET_DOCKER_HOST_XDEBUG,
null,
InputOption::VALUE_NONE,
'Sets host.docker.internal for fpm_xdebug container to resolve debug issue for LINUX system'
);

$this->addOption(
Expand Down
6 changes: 5 additions & 1 deletion src/Compose/ProductionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,14 +333,18 @@ public function build(Config $config): Manager
* Include Xdebug if --with-xdebug is set
*/
if ($config->hasServiceEnabled(ServiceInterface::SERVICE_FPM_XDEBUG)) {
$envVariables = ['PHP_EXTENSIONS' => implode(' ', array_unique(array_merge($phpExtensions, ['xdebug'])))];
Copy link
Contributor

@NadiyaS NadiyaS Aug 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you merge with xdebug here? Should not it be in the config already?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this configuration only for fpm_xdebug container and it needs to have enabled xdebug extension.
$phpExtensions may not have xdebug if it not set-up in .magento.app.yaml

if ($config->get(SourceInterface::SYSTEM_SET_DOCKER_HOST)) {
$envVariables['SET_DOCKER_HOST'] = true;
}
$manager->addService(
self::SERVICE_FPM_XDEBUG,
$this->serviceFactory->create(
ServiceInterface::SERVICE_FPM_XDEBUG,
$phpVersion,
[
'volumes' => $volumesRo,
'environment' => $this->converter->convert(['PHP_EXTENSIONS' => implode(' ', $phpExtensions)])
'environment' => $this->converter->convert($envVariables)
]
),
[self::NETWORK_MAGENTO],
Expand Down
5 changes: 5 additions & 0 deletions src/Config/Source/CliSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class CliSource implements SourceInterface
public const OPTION_NO_TMP_MOUNTS = 'no-tmp-mounts';
public const OPTION_SYNC_ENGINE = 'sync-engine';
public const OPTION_WITH_XDEBUG = 'with-xdebug';
public const OPTION_SET_DOCKER_HOST_XDEBUG = 'set-docker-host';
public const OPTION_WITH_ENTRYPOINT = 'with-entrypoint';
public const OPTION_WITH_MARIADB_CONF = 'with-mariadb-conf';

Expand Down Expand Up @@ -220,6 +221,10 @@ public function read(): Repository
]);
}

if ($this->input->getOption(self::OPTION_SET_DOCKER_HOST_XDEBUG)) {
$repository->set(self::SYSTEM_SET_DOCKER_HOST, true);
}

if ($envs = $this->input->getOption(self::OPTION_ENV_VARIABLES)) {
$repository->set(self::VARIABLES, (array)json_decode($envs, true));
}
Expand Down
1 change: 1 addition & 0 deletions src/Config/Source/SourceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ interface SourceInterface
public const SYSTEM_EXPOSE_DB_SALES_PORTS = 'system.expose_db_sales_ports';
public const SYSTEM_DB_ENTRYPOINT = 'system.db_entrypoint';
public const SYSTEM_MARIADB_CONF = 'system.mariadb_conf';
public const SYSTEM_SET_DOCKER_HOST = 'system.set_docker_host';

public const SYSTEM_DB_INCREMENT_INCREMENT = 'system.db.increment_increment';
public const SYSTEM_DB_INCREMENT_OFFSET = 'system.db.increment_offset';
Expand Down
3 changes: 0 additions & 3 deletions src/Service/ServiceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ class ServiceFactory
'pattern' => '%s:%s-fpm-%s',
'config' => [
'extends' => ServiceInterface::SERVICE_GENERIC,
'ports' => [
'9001:9001',
]
]
],
ServiceInterface::SERVICE_DB => self::SERVICE_DB_CONFIG,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ services:
hostname: fpm_xdebug.magento2.docker
image: 'magento/magento-cloud-docker-php:7.3-fpm-1.1'
extends: generic
ports:
- '9001:9001'
volumes:
- '.:/app:ro,delegated'
- './dev:/app/dev:rw,delegated'
Expand All @@ -165,7 +163,7 @@ services:
- 'magento-pub-static:/app/pub/static:rw,delegated'
- '.docker/mnt:/mnt:rw,delegated'
environment:
- 'PHP_EXTENSIONS=bcmath bz2 calendar exif gd gettext intl mysqli pcntl pdo_mysql soap sockets sysvmsg sysvsem sysvshm opcache zip redis xsl sodium'
- 'PHP_EXTENSIONS=bcmath bz2 calendar exif gd gettext intl mysqli pcntl pdo_mysql soap sockets sysvmsg sysvsem sysvshm opcache zip redis xsl sodium xdebug'
networks:
magento:
aliases:
Expand Down