From 221845dd592b904fdebe69e1d72dee95a95546b1 Mon Sep 17 00:00:00 2001 From: Oleksandr Shmyheliuk Date: Tue, 24 Nov 2020 12:29:15 -0600 Subject: [PATCH 01/17] MCLOUD-7310: Fix functional tests for cloud docker (#15) --- src/Test/Functional/Acceptance/AbstractCest.php | 2 +- src/Test/Functional/Acceptance/AcceptanceCest.php | 2 +- travis.php.ini | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 travis.php.ini diff --git a/src/Test/Functional/Acceptance/AbstractCest.php b/src/Test/Functional/Acceptance/AbstractCest.php index 65afb8e2..1929bd16 100644 --- a/src/Test/Functional/Acceptance/AbstractCest.php +++ b/src/Test/Functional/Acceptance/AbstractCest.php @@ -40,7 +40,7 @@ public function _before(\CliTester $I): void $I->addEceToolsGitRepoToComposer(); $I->addDependencyToComposer('magento/ece-tools', 'dev-develop as 2002.1.99'); - $I->composerUpdate(); + $I->assertTrue($I->composerUpdate(), 'Composer update failed'); $I->cacheWorkDir(static::TEMPLATE_VERSION); } diff --git a/src/Test/Functional/Acceptance/AcceptanceCest.php b/src/Test/Functional/Acceptance/AcceptanceCest.php index 9f48d46f..6fff1bb3 100644 --- a/src/Test/Functional/Acceptance/AcceptanceCest.php +++ b/src/Test/Functional/Acceptance/AcceptanceCest.php @@ -20,7 +20,7 @@ class AcceptanceCest extends AbstractCest */ public function testProductionMode(\CliTester $I): void { - $I->runEceDockerCommand('build:compose --mode=production'); + $I->assertTrue($I->runEceDockerCommand('build:compose --mode=production'), 'Command build:compose failed'); $I->replaceImagesWithGenerated(); $I->startEnvironment(); $I->runDockerComposeCommand('run build cloud-build'); diff --git a/travis.php.ini b/travis.php.ini new file mode 100644 index 00000000..0b134267 --- /dev/null +++ b/travis.php.ini @@ -0,0 +1 @@ +memory_limit = 4G From 26ad8a7345d9cc27363219a735631a5908631ab8 Mon Sep 17 00:00:00 2001 From: Oleksandr Shmyheliuk Date: Tue, 24 Nov 2020 14:58:21 -0600 Subject: [PATCH 02/17] MCLOUD-7232: Fix healtchecker for docker php-fpm (#14) --- composer.json | 2 +- images/nginx/1.19/Dockerfile | 2 +- images/php/7.2-fpm/fpm-healthcheck.sh | 2 +- images/php/7.3-fpm/fpm-healthcheck.sh | 2 +- images/php/7.4-fpm/fpm-healthcheck.sh | 2 +- images/php/fpm/fpm-healthcheck.sh | 2 +- tests/functional/Codeception/TestInfrastructure.php | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 7f045afa..b2384919 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "magento/magento-cloud-docker", "description": "Magento Cloud Docker", "type": "magento2-component", - "version": "1.2.0", + "version": "1.2.1", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/images/nginx/1.19/Dockerfile b/images/nginx/1.19/Dockerfile index 95dcd81c..38d5119f 100644 --- a/images/nginx/1.19/Dockerfile +++ b/images/nginx/1.19/Dockerfile @@ -1,4 +1,4 @@ -FROM nginx +FROM nginx:1.19 ENV UPLOAD_MAX_FILESIZE 64M ENV XDEBUG_HOST fpm_xdebug diff --git a/images/php/7.2-fpm/fpm-healthcheck.sh b/images/php/7.2-fpm/fpm-healthcheck.sh index 2207bd57..16f1ce2a 100644 --- a/images/php/7.2-fpm/fpm-healthcheck.sh +++ b/images/php/7.2-fpm/fpm-healthcheck.sh @@ -1,7 +1,7 @@ #!/bin/bash set -eo pipefail -fpm_response=$(curl -o /dev/null -s -w "%{http_code}\n" http://${WEB_HOST:-web}:${WEB_PORT:-80}/status) +fpm_response=$(curl -o /dev/null -s -w "%{http_code}\n" http://${WEB_HOST:-web}:${WEB_PORT:-8080}/status) if [ "$fpm_response" == "200" ] then diff --git a/images/php/7.3-fpm/fpm-healthcheck.sh b/images/php/7.3-fpm/fpm-healthcheck.sh index 2207bd57..16f1ce2a 100644 --- a/images/php/7.3-fpm/fpm-healthcheck.sh +++ b/images/php/7.3-fpm/fpm-healthcheck.sh @@ -1,7 +1,7 @@ #!/bin/bash set -eo pipefail -fpm_response=$(curl -o /dev/null -s -w "%{http_code}\n" http://${WEB_HOST:-web}:${WEB_PORT:-80}/status) +fpm_response=$(curl -o /dev/null -s -w "%{http_code}\n" http://${WEB_HOST:-web}:${WEB_PORT:-8080}/status) if [ "$fpm_response" == "200" ] then diff --git a/images/php/7.4-fpm/fpm-healthcheck.sh b/images/php/7.4-fpm/fpm-healthcheck.sh index 2207bd57..16f1ce2a 100644 --- a/images/php/7.4-fpm/fpm-healthcheck.sh +++ b/images/php/7.4-fpm/fpm-healthcheck.sh @@ -1,7 +1,7 @@ #!/bin/bash set -eo pipefail -fpm_response=$(curl -o /dev/null -s -w "%{http_code}\n" http://${WEB_HOST:-web}:${WEB_PORT:-80}/status) +fpm_response=$(curl -o /dev/null -s -w "%{http_code}\n" http://${WEB_HOST:-web}:${WEB_PORT:-8080}/status) if [ "$fpm_response" == "200" ] then diff --git a/images/php/fpm/fpm-healthcheck.sh b/images/php/fpm/fpm-healthcheck.sh index 2207bd57..16f1ce2a 100644 --- a/images/php/fpm/fpm-healthcheck.sh +++ b/images/php/fpm/fpm-healthcheck.sh @@ -1,7 +1,7 @@ #!/bin/bash set -eo pipefail -fpm_response=$(curl -o /dev/null -s -w "%{http_code}\n" http://${WEB_HOST:-web}:${WEB_PORT:-80}/status) +fpm_response=$(curl -o /dev/null -s -w "%{http_code}\n" http://${WEB_HOST:-web}:${WEB_PORT:-8080}/status) if [ "$fpm_response" == "200" ] then diff --git a/tests/functional/Codeception/TestInfrastructure.php b/tests/functional/Codeception/TestInfrastructure.php index 7381138c..2a14f46f 100644 --- a/tests/functional/Codeception/TestInfrastructure.php +++ b/tests/functional/Codeception/TestInfrastructure.php @@ -226,7 +226,7 @@ public function createArtifactCurrentTestedCode(string $name, string $version, a ->wasSuccessful(); $skippedFiles = array_merge( - ['..', '.', 'vendor', '.git', '_workdir', 'vendor', 'composer.lock'], + ['..', '.', 'vendor', '.git', BaseModule::WORK_DIR, BaseModule::WORK_DIR_CACHE, 'composer.lock'], $skippedFiles ); $files = []; From c61fb0f6d25fbf42c2ff35d3a9c7735dca763a3b Mon Sep 17 00:00:00 2001 From: Adarsh Manickam Date: Tue, 1 Dec 2020 20:24:54 +0530 Subject: [PATCH 03/17] Fixed incorrect port --- images/nginx/1.19/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/nginx/1.19/Dockerfile b/images/nginx/1.19/Dockerfile index 38d5119f..8067b8cb 100644 --- a/images/nginx/1.19/Dockerfile +++ b/images/nginx/1.19/Dockerfile @@ -5,7 +5,7 @@ ENV XDEBUG_HOST fpm_xdebug ENV FPM_HOST fpm ENV FPM_PORT 9000 ENV UPSTREAM_HOST web -ENV UPSTREAM_PORT 80 +ENV UPSTREAM_PORT 8080 ENV MAGENTO_ROOT /app ENV MAGENTO_RUN_MODE production ENV MFTF_UTILS 0 From 0bb2a8dd15d5a912f90b6fced5b76056c11829c0 Mon Sep 17 00:00:00 2001 From: Oleh Posyniak Date: Tue, 1 Dec 2020 16:13:33 -0600 Subject: [PATCH 04/17] Fixed incorrect port --- src/Compose/ProductionBuilder/Service/Tls.php | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Compose/ProductionBuilder/Service/Tls.php b/src/Compose/ProductionBuilder/Service/Tls.php index 6be1cb19..66ad05f0 100644 --- a/src/Compose/ProductionBuilder/Service/Tls.php +++ b/src/Compose/ProductionBuilder/Service/Tls.php @@ -62,7 +62,7 @@ public function getConfig(Config $config): array 'aliases' => [$config->getHost()] ] ], - 'environment' => ['UPSTREAM_HOST' => $this->getBackendService($config)], + 'environment' => $this->getBackendServiceUpstream($config), 'ports' => [ $config->getPort() . ':80', $config->getTlsPort() . ':443' @@ -100,4 +100,24 @@ private function getBackendService(Config $config): string ? BuilderInterface::SERVICE_VARNISH : BuilderInterface::SERVICE_WEB; } + + /** + * @param Config $config + * @return string[] + * @throws ConfigurationMismatchException + */ + private function getBackendServiceUpstream(Config $config): array + { + if ($config->hasServiceEnabled(ServiceInterface::SERVICE_VARNISH)) { + return [ + 'UPSTREAM_HOST=' . BuilderInterface::SERVICE_VARNISH, + 'UPSTREAM_PORT=80' + ]; + } + + return [ + 'UPSTREAM_HOST=' . BuilderInterface::SERVICE_WEB, + 'UPSTREAM_PORT=8080' + ]; + } } From c59c8701d2f69368a668fb72ba5da7c2270cef5d Mon Sep 17 00:00:00 2001 From: Oleh Posyniak Date: Tue, 1 Dec 2020 16:34:41 -0600 Subject: [PATCH 05/17] Fixed incorrect port --- src/Test/Integration/_files/cloud_base/docker-compose.exp.yml | 3 ++- .../Integration/_files/cloud_base_mftf/docker-compose.exp.yml | 3 ++- .../Integration/_files/cloud_base_test/docker-compose.exp.yml | 3 ++- .../_files/custom_cloud_base/docker-compose.exp.yml | 3 ++- .../_files/custom_cloud_custom_images/docker-compose.exp.yml | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Test/Integration/_files/cloud_base/docker-compose.exp.yml b/src/Test/Integration/_files/cloud_base/docker-compose.exp.yml index c7e9f54c..b011cddb 100644 --- a/src/Test/Integration/_files/cloud_base/docker-compose.exp.yml +++ b/src/Test/Integration/_files/cloud_base/docker-compose.exp.yml @@ -110,7 +110,8 @@ services: aliases: - magento2.docker environment: - UPSTREAM_HOST: varnish + - UPSTREAM_HOST=varnish + - UPSTREAM_PORT=80 ports: - '80:80' - '443:443' diff --git a/src/Test/Integration/_files/cloud_base_mftf/docker-compose.exp.yml b/src/Test/Integration/_files/cloud_base_mftf/docker-compose.exp.yml index bbc26809..8c9f71e2 100644 --- a/src/Test/Integration/_files/cloud_base_mftf/docker-compose.exp.yml +++ b/src/Test/Integration/_files/cloud_base_mftf/docker-compose.exp.yml @@ -104,7 +104,8 @@ services: aliases: - magento2.docker environment: - UPSTREAM_HOST: varnish + - UPSTREAM_HOST=varnish + - UPSTREAM_PORT=80 ports: - '80:80' - '4443:443' diff --git a/src/Test/Integration/_files/cloud_base_test/docker-compose.exp.yml b/src/Test/Integration/_files/cloud_base_test/docker-compose.exp.yml index 18a99e5a..f18493bf 100644 --- a/src/Test/Integration/_files/cloud_base_test/docker-compose.exp.yml +++ b/src/Test/Integration/_files/cloud_base_test/docker-compose.exp.yml @@ -104,7 +104,8 @@ services: aliases: - magento2.docker environment: - UPSTREAM_HOST: varnish + - UPSTREAM_HOST=varnish + - UPSTREAM_PORT=80 ports: - '80:80' - '4443:443' diff --git a/src/Test/Integration/_files/custom_cloud_base/docker-compose.exp.yml b/src/Test/Integration/_files/custom_cloud_base/docker-compose.exp.yml index 588b420b..cf72b33c 100644 --- a/src/Test/Integration/_files/custom_cloud_base/docker-compose.exp.yml +++ b/src/Test/Integration/_files/custom_cloud_base/docker-compose.exp.yml @@ -84,7 +84,8 @@ services: aliases: - magento2.test environment: - UPSTREAM_HOST: varnish + - UPSTREAM_HOST=varnish + - UPSTREAM_PORT=80 ports: - '8080:80' - '443:443' diff --git a/src/Test/Integration/_files/custom_cloud_custom_images/docker-compose.exp.yml b/src/Test/Integration/_files/custom_cloud_custom_images/docker-compose.exp.yml index dd9fc2bb..04e3ca4d 100644 --- a/src/Test/Integration/_files/custom_cloud_custom_images/docker-compose.exp.yml +++ b/src/Test/Integration/_files/custom_cloud_custom_images/docker-compose.exp.yml @@ -109,7 +109,8 @@ services: aliases: - magento2.test environment: - UPSTREAM_HOST: varnish + - UPSTREAM_HOST=varnish + - UPSTREAM_PORT=80 ports: - '8080:80' - '443:443' From e6784c759d73e24437d409337b7bf96a93e528c0 Mon Sep 17 00:00:00 2001 From: Bohdan Korablov Date: Wed, 2 Dec 2020 14:27:34 -0600 Subject: [PATCH 06/17] Added retrier to Functional tests (#17) --- .../Codeception/TestInfrastructure.php | 59 ++++++++++++++----- 1 file changed, 44 insertions(+), 15 deletions(-) diff --git a/tests/functional/Codeception/TestInfrastructure.php b/tests/functional/Codeception/TestInfrastructure.php index 2a14f46f..430141ce 100644 --- a/tests/functional/Codeception/TestInfrastructure.php +++ b/tests/functional/Codeception/TestInfrastructure.php @@ -303,15 +303,40 @@ public function addArtifactsRepoToComposer(): bool */ public function addDependencyToComposer(string $name, string $version): bool { - return $this->taskComposerRequire('composer') - ->dependency($name, $version) - ->noInteraction() - ->option('--no-update') - ->printOutput($this->_getConfig('printOutput')) - ->interactive(false) - ->dir($this->getWorkDirPath()) - ->run() - ->wasSuccessful(); + return $this->retry( + function () use ($name, $version) { + return $this->taskComposerRequire('composer') + ->dependency($name, $version) + ->noInteraction() + ->option('--no-update') + ->printOutput($this->_getConfig('printOutput')) + ->interactive(false) + ->dir($this->getWorkDirPath()) + ->run() + ->wasSuccessful(); + } + ); + } + + /** + * @param callable $callback + * @param int $retries + * @return bool + */ + private function retry(callable $callback, int $retries = 2): bool + { + $result = false; + + for ($i = $retries; $i > 0; $i--) { + $result = $callback(); + if ($result) { + return $result; + } + + sleep(5); + } + + return $result; } /** @@ -507,12 +532,16 @@ public function replaceImagesWithCurrentDockerVersion(): bool */ public function composerUpdate(): bool { - return $this->taskComposerUpdate('composer') - ->printOutput($this->_getConfig('printOutput')) - ->interactive(false) - ->dir($this->getWorkDirPath()) - ->run() - ->wasSuccessful(); + return $this->retry( + function () { + return $this->taskComposerUpdate('composer') + ->printOutput($this->_getConfig('printOutput')) + ->interactive(false) + ->dir($this->getWorkDirPath()) + ->run() + ->wasSuccessful(); + } + ); } /** From 29bc15269d54fc43dcccaf160387e19efa54891c Mon Sep 17 00:00:00 2001 From: Igor Vitol Date: Sun, 6 Dec 2020 13:38:58 +0200 Subject: [PATCH 07/17] Fix loading of blackfire - now it could be disabled or enabled by PHP_EXTENSIONS variable --- images/php/7.2-cli/Dockerfile | 3 +-- images/php/7.2-fpm/Dockerfile | 3 +-- images/php/7.3-cli/Dockerfile | 3 +-- images/php/7.3-fpm/Dockerfile | 3 +-- images/php/7.4-cli/Dockerfile | 3 +-- images/php/7.4-fpm/Dockerfile | 3 +-- 6 files changed, 6 insertions(+), 12 deletions(-) diff --git a/images/php/7.2-cli/Dockerfile b/images/php/7.2-cli/Dockerfile index 138d9c99..a9f0c957 100644 --- a/images/php/7.2-cli/Dockerfile +++ b/images/php/7.2-cli/Dockerfile @@ -134,8 +134,7 @@ RUN curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire && mkdir -p /tmp/blackfire \ && tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \ && mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get ('extension_dir');")/blackfire.so \ - && ( echo extension=blackfire.so \ - && echo blackfire.agent_socket=tcp://blackfire:8707 ) > $(php -i | grep "additional .ini" | awk '{print $9}')/blackfire.ini \ + && echo blackfire.agent_socket=tcp://blackfire:8707 > $(php -i | grep "additional .ini" | awk '{print $9}')/blackfire.ini \ && rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz RUN rm -f /usr/local/etc/php/conf.d/*sodium.ini \ && rm -f /usr/local/lib/php/extensions/*/*sodium.so \ diff --git a/images/php/7.2-fpm/Dockerfile b/images/php/7.2-fpm/Dockerfile index a8a15a36..b6dd1704 100644 --- a/images/php/7.2-fpm/Dockerfile +++ b/images/php/7.2-fpm/Dockerfile @@ -113,8 +113,7 @@ RUN curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire && mkdir -p /tmp/blackfire \ && tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \ && mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get ('extension_dir');")/blackfire.so \ - && ( echo extension=blackfire.so \ - && echo blackfire.agent_socket=tcp://blackfire:8707 ) > $(php -i | grep "additional .ini" | awk '{print $9}')/blackfire.ini \ + && echo blackfire.agent_socket=tcp://blackfire:8707 > $(php -i | grep "additional .ini" | awk '{print $9}')/blackfire.ini \ && rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz RUN rm -f /usr/local/etc/php/conf.d/*sodium.ini \ && rm -f /usr/local/lib/php/extensions/*/*sodium.so \ diff --git a/images/php/7.3-cli/Dockerfile b/images/php/7.3-cli/Dockerfile index e29b3bbe..33db52ed 100644 --- a/images/php/7.3-cli/Dockerfile +++ b/images/php/7.3-cli/Dockerfile @@ -131,8 +131,7 @@ RUN curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire && mkdir -p /tmp/blackfire \ && tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \ && mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get ('extension_dir');")/blackfire.so \ - && ( echo extension=blackfire.so \ - && echo blackfire.agent_socket=tcp://blackfire:8707 ) > $(php -i | grep "additional .ini" | awk '{print $9}')/blackfire.ini \ + && echo blackfire.agent_socket=tcp://blackfire:8707 > $(php -i | grep "additional .ini" | awk '{print $9}')/blackfire.ini \ && rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz RUN rm -f /usr/local/etc/php/conf.d/*sodium.ini \ && rm -f /usr/local/lib/php/extensions/*/*sodium.so \ diff --git a/images/php/7.3-fpm/Dockerfile b/images/php/7.3-fpm/Dockerfile index 14b6e801..6b44b8ab 100644 --- a/images/php/7.3-fpm/Dockerfile +++ b/images/php/7.3-fpm/Dockerfile @@ -110,8 +110,7 @@ RUN curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire && mkdir -p /tmp/blackfire \ && tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \ && mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get ('extension_dir');")/blackfire.so \ - && ( echo extension=blackfire.so \ - && echo blackfire.agent_socket=tcp://blackfire:8707 ) > $(php -i | grep "additional .ini" | awk '{print $9}')/blackfire.ini \ + && echo blackfire.agent_socket=tcp://blackfire:8707 > $(php -i | grep "additional .ini" | awk '{print $9}')/blackfire.ini \ && rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz RUN rm -f /usr/local/etc/php/conf.d/*sodium.ini \ && rm -f /usr/local/lib/php/extensions/*/*sodium.so \ diff --git a/images/php/7.4-cli/Dockerfile b/images/php/7.4-cli/Dockerfile index 856dea1c..f8760050 100644 --- a/images/php/7.4-cli/Dockerfile +++ b/images/php/7.4-cli/Dockerfile @@ -121,8 +121,7 @@ RUN curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire && mkdir -p /tmp/blackfire \ && tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \ && mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get ('extension_dir');")/blackfire.so \ - && ( echo extension=blackfire.so \ - && echo blackfire.agent_socket=tcp://blackfire:8707 ) > $(php -i | grep "additional .ini" | awk '{print $9}')/blackfire.ini \ + && echo blackfire.agent_socket=tcp://blackfire:8707 > $(php -i | grep "additional .ini" | awk '{print $9}')/blackfire.ini \ && rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz RUN rm -f /usr/local/etc/php/conf.d/*sodium.ini \ && rm -f /usr/local/lib/php/extensions/*/*sodium.so \ diff --git a/images/php/7.4-fpm/Dockerfile b/images/php/7.4-fpm/Dockerfile index 1bf64920..22c5ae66 100644 --- a/images/php/7.4-fpm/Dockerfile +++ b/images/php/7.4-fpm/Dockerfile @@ -100,8 +100,7 @@ RUN curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire && mkdir -p /tmp/blackfire \ && tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \ && mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get ('extension_dir');")/blackfire.so \ - && ( echo extension=blackfire.so \ - && echo blackfire.agent_socket=tcp://blackfire:8707 ) > $(php -i | grep "additional .ini" | awk '{print $9}')/blackfire.ini \ + && echo blackfire.agent_socket=tcp://blackfire:8707 > $(php -i | grep "additional .ini" | awk '{print $9}')/blackfire.ini \ && rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz RUN rm -f /usr/local/etc/php/conf.d/*sodium.ini \ && rm -f /usr/local/lib/php/extensions/*/*sodium.so \ From e822ebab3483c4d3194aa71ae07e64ea9633158b Mon Sep 17 00:00:00 2001 From: Igor Vitol Date: Thu, 10 Dec 2020 23:59:56 +0200 Subject: [PATCH 08/17] Blackfire is enabled by default as it was before. Added option to disable it. Keeping switcher in PHP_EXTENSIONS env variable --- src/Command/BuildCompose.php | 5 +++++ src/Compose/Php/ExtensionResolver.php | 4 ++-- src/Config/Source/CliSource.php | 7 +++++++ src/Test/Integration/BuildComposeTest.php | 2 ++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Command/BuildCompose.php b/src/Command/BuildCompose.php index 093303c5..ca11a86f 100644 --- a/src/Command/BuildCompose.php +++ b/src/Command/BuildCompose.php @@ -240,6 +240,11 @@ protected function configure(): void null, InputOption::VALUE_NONE, 'Enables XDebug' + )->addOption( + Source\CliSource::OPTION_WITHOUT_BLACKFIRE, + null, + InputOption::VALUE_NONE, + 'Do not load blackfire php extension by default' )->addOption( Source\CliSource::OPTION_ENV_VARIABLES, null, diff --git a/src/Compose/Php/ExtensionResolver.php b/src/Compose/Php/ExtensionResolver.php index a4ed0dc8..7dd587d5 100644 --- a/src/Compose/Php/ExtensionResolver.php +++ b/src/Compose/Php/ExtensionResolver.php @@ -47,6 +47,7 @@ class ExtensionResolver 'sysvshm', 'opcache', 'zip', + 'blackfire' ]; /** @@ -172,8 +173,7 @@ public static function getConfig(): array mkdir -p /tmp/blackfire tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get ('extension_dir');")/blackfire.so -( echo extension=blackfire.so -echo blackfire.agent_socket=tcp://blackfire:8707 ) > $(php -i | grep "additional .ini" | awk '{print $9}')/blackfire.ini +echo blackfire.agent_socket=tcp://blackfire:8707 > $(php -i | grep "additional .ini" | awk '{print $9}')/blackfire.ini rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz BASH // phpcs:enable diff --git a/src/Config/Source/CliSource.php b/src/Config/Source/CliSource.php index 6224d412..834c4735 100644 --- a/src/Config/Source/CliSource.php +++ b/src/Config/Source/CliSource.php @@ -52,6 +52,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_WITHOUT_BLACKFIRE = 'without-blackfire'; 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'; @@ -234,6 +235,12 @@ public function read(): Repository ]); } + if ($this->input->getOption(self::OPTION_WITHOUT_BLACKFIRE)) { + $repository->set([ + self::PHP_DISABLED_EXTENSIONS => ['blackfire'] + ]); + } + if ($this->input->getOption(self::OPTION_SET_DOCKER_HOST_XDEBUG)) { $repository->set(self::SYSTEM_SET_DOCKER_HOST, true); } diff --git a/src/Test/Integration/BuildComposeTest.php b/src/Test/Integration/BuildComposeTest.php index df35305c..a7448363 100644 --- a/src/Test/Integration/BuildComposeTest.php +++ b/src/Test/Integration/BuildComposeTest.php @@ -87,6 +87,7 @@ public function buildDataProvider(): array [CliSource::OPTION_WITH_TEST, true], [CliSource::OPTION_WITH_CRON, true], [CliSource::OPTION_WITH_XDEBUG, true], + [CliSource::OPTION_WITHOUT_BLACKFIRE, true], [CliSource::OPTION_ES, '5.2'], [CliSource::OPTION_NO_ES, true], [CliSource::OPTION_DB_INCREMENT_INCREMENT, 3], @@ -104,6 +105,7 @@ public function buildDataProvider(): array [CliSource::OPTION_WITH_TEST, true], [CliSource::OPTION_WITH_CRON, true], [CliSource::OPTION_WITH_XDEBUG, true], + [CliSource::OPTION_WITHOUT_BLACKFIRE, true], [CliSource::OPTION_ES, '5.2'], [CliSource::OPTION_NO_ES, true], [CliSource::OPTION_DB_INCREMENT_INCREMENT, 3], From 25b0cdbb523b6331009976957c38f1505aecc001 Mon Sep 17 00:00:00 2001 From: Igor Vitol Date: Fri, 11 Dec 2020 00:24:21 +0200 Subject: [PATCH 09/17] Fix blackfire inegration test --- src/Test/Integration/_files/cloud_base/docker-compose.exp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Test/Integration/_files/cloud_base/docker-compose.exp.yml b/src/Test/Integration/_files/cloud_base/docker-compose.exp.yml index b011cddb..2d16a1f3 100644 --- a/src/Test/Integration/_files/cloud_base/docker-compose.exp.yml +++ b/src/Test/Integration/_files/cloud_base/docker-compose.exp.yml @@ -123,7 +123,7 @@ services: image: 'magento/magento-cloud-docker-php:7.3-cli-1.2.0' env_file: ./.docker/config.env 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 blackfire redis xsl sodium' build: hostname: build.magento2.docker image: 'magento/magento-cloud-docker-php:7.3-cli-1.2.0' From 381d9c540d5c3800d71c02aa439e1af8794c2246 Mon Sep 17 00:00:00 2001 From: Igor Vitol Date: Fri, 11 Dec 2020 00:33:47 +0200 Subject: [PATCH 10/17] Fix blackfire integration tests --- .../Integration/_files/custom_cloud_base/docker-compose.exp.yml | 2 +- .../_files/custom_cloud_custom_images/docker-compose.exp.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Test/Integration/_files/custom_cloud_base/docker-compose.exp.yml b/src/Test/Integration/_files/custom_cloud_base/docker-compose.exp.yml index cf72b33c..cf7dbab3 100644 --- a/src/Test/Integration/_files/custom_cloud_base/docker-compose.exp.yml +++ b/src/Test/Integration/_files/custom_cloud_base/docker-compose.exp.yml @@ -97,7 +97,7 @@ services: image: 'magento/magento-cloud-docker-php:7.2-cli-1.2.0' env_file: ./.docker/config.env environment: - - 'PHP_EXTENSIONS=bcmath bz2 calendar exif gd gettext intl mysqli pcntl pdo_mysql soap sockets sysvmsg sysvsem sysvshm opcache zip xsl' + - 'PHP_EXTENSIONS=bcmath bz2 calendar exif gd gettext intl mysqli pcntl pdo_mysql soap sockets sysvmsg sysvsem sysvshm opcache zip blackfire xsl' build: hostname: build.magento2.test image: 'magento/magento-cloud-docker-php:7.2-cli-1.2.0' diff --git a/src/Test/Integration/_files/custom_cloud_custom_images/docker-compose.exp.yml b/src/Test/Integration/_files/custom_cloud_custom_images/docker-compose.exp.yml index 04e3ca4d..e46913df 100644 --- a/src/Test/Integration/_files/custom_cloud_custom_images/docker-compose.exp.yml +++ b/src/Test/Integration/_files/custom_cloud_custom_images/docker-compose.exp.yml @@ -148,7 +148,7 @@ services: image: 'php-v1:7.4-cli' env_file: ./.docker/config.env environment: - - 'PHP_EXTENSIONS=bcmath bz2 calendar exif gd gettext intl mysqli pcntl pdo_mysql soap sockets sysvmsg sysvsem sysvshm opcache zip xsl' + - 'PHP_EXTENSIONS=bcmath bz2 calendar exif gd gettext intl mysqli pcntl pdo_mysql soap sockets sysvmsg sysvsem sysvshm opcache zip blackfire xsl' build: hostname: build.magento2.test image: 'php-v1:7.4-cli' From 95b932f2e951276b3c224186d4b1adcf1ca47f50 Mon Sep 17 00:00:00 2001 From: Igor Vitol Date: Fri, 11 Dec 2020 10:40:17 +0200 Subject: [PATCH 11/17] Do not override disabled modules in blackfire config --- src/Config/Source/CliSource.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Config/Source/CliSource.php b/src/Config/Source/CliSource.php index 834c4735..7c3e925e 100644 --- a/src/Config/Source/CliSource.php +++ b/src/Config/Source/CliSource.php @@ -236,9 +236,7 @@ public function read(): Repository } if ($this->input->getOption(self::OPTION_WITHOUT_BLACKFIRE)) { - $repository->set([ - self::PHP_DISABLED_EXTENSIONS => ['blackfire'] - ]); + $repository->push(self::PHP_DISABLED_EXTENSIONS, 'blackfire'); } if ($this->input->getOption(self::OPTION_SET_DOCKER_HOST_XDEBUG)) { From dc58ec50c17917303a9450839edcaf2abd85d795 Mon Sep 17 00:00:00 2001 From: Igor Vitol Date: Fri, 11 Dec 2020 10:54:42 +0200 Subject: [PATCH 12/17] Do not override disabled modules in blackfire config --- src/Config/Source/CliSource.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Config/Source/CliSource.php b/src/Config/Source/CliSource.php index 7c3e925e..08432faa 100644 --- a/src/Config/Source/CliSource.php +++ b/src/Config/Source/CliSource.php @@ -236,7 +236,7 @@ public function read(): Repository } if ($this->input->getOption(self::OPTION_WITHOUT_BLACKFIRE)) { - $repository->push(self::PHP_DISABLED_EXTENSIONS, 'blackfire'); + $repository->set(self::PHP_DISABLED_EXTENSIONS, ['blackfire' => 'blackfire']); } if ($this->input->getOption(self::OPTION_SET_DOCKER_HOST_XDEBUG)) { From 441f75e035ebdd5bb6b1eefcc0e3b61a93709796 Mon Sep 17 00:00:00 2001 From: Igor Vitol Date: Fri, 11 Dec 2020 11:12:00 +0200 Subject: [PATCH 13/17] Do not override disabled modules in blackfire config --- src/Config/Source/CliSource.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Config/Source/CliSource.php b/src/Config/Source/CliSource.php index 08432faa..24680840 100644 --- a/src/Config/Source/CliSource.php +++ b/src/Config/Source/CliSource.php @@ -141,6 +141,7 @@ public function __construct(InputInterface $input) public function read(): Repository { $repository = new Repository(); + $disabledExtensions = []; if ($mode = $this->input->getOption(self::OPTION_MODE)) { $repository->set([ @@ -236,7 +237,7 @@ public function read(): Repository } if ($this->input->getOption(self::OPTION_WITHOUT_BLACKFIRE)) { - $repository->set(self::PHP_DISABLED_EXTENSIONS, ['blackfire' => 'blackfire']); + $disabledExtensions['blackfire'] = 'blackfire'; } if ($this->input->getOption(self::OPTION_SET_DOCKER_HOST_XDEBUG)) { @@ -303,6 +304,7 @@ public function read(): Repository $repository->set(self::SYSTEM_MAILHOG_HTTP_PORT, $port); } + $repository->set(self::PHP_DISABLED_EXTENSIONS, $disabledExtensions); return $repository; } } From 9b5cfb4c7e3857652965dbef8866e3b9c511d4a2 Mon Sep 17 00:00:00 2001 From: Yevhen Miroshnychenko Date: Tue, 15 Dec 2020 10:09:19 -0600 Subject: [PATCH 14/17] MCLOUD-7259 Ability to disable TLS container from build:custom:compose (#18) --- images/nginx/1.19/Dockerfile | 2 + images/nginx/1.19/docker-entrypoint.sh | 2 + images/nginx/1.19/etc/nginx.conf | 4 +- src/Command/BuildCompose.php | 17 ++ src/Compose/ProductionBuilder.php | 25 ++- src/Compose/ProductionBuilder/Service/Tls.php | 25 ++- .../ProductionBuilder/Service/Varnish.php | 14 +- src/Compose/ProductionBuilder/Service/Web.php | 21 +- src/Config/Config.php | 24 +++ src/Config/Source/BaseSource.php | 6 +- src/Config/Source/CliSource.php | 12 ++ src/Config/Source/SourceInterface.php | 9 + src/Test/Integration/BuildComposeTest.php | 31 ++- .../Integration/BuildCustomComposeTest.php | 82 +++++++- .../_files/cloud_base/docker-compose.exp.yml | 4 + .../cloud_base_mftf/docker-compose.exp.yml | 4 + .../cloud_base_test/docker-compose.exp.yml | 4 + .../cloud_no_tls_service/.docker/.gitignore | 0 .../.docker/config.php.dist | 47 +++++ .../cloud_no_tls_service/.magento.app.yaml | 29 +++ .../.magento/services.yaml | 14 ++ .../_files/cloud_no_tls_service/composer.json | 6 + .../docker-compose.exp.yml | 178 +++++++++++++++++ .../.docker/.gitignore | 0 .../.docker/config.php.dist | 47 +++++ .../.magento.app.yaml | 29 +++ .../.magento/services.yaml | 14 ++ .../composer.json | 6 + .../docker-compose.exp.yml | 168 ++++++++++++++++ .../.docker/.gitignore | 0 .../.docker/config.php.dist | 47 +++++ .../.magento.app.yaml | 29 +++ .../.magento/services.yaml | 14 ++ .../cloud_no_varnish_service/composer.json | 6 + .../docker-compose.exp.yml | 185 ++++++++++++++++++ .../custom_cloud_base/docker-compose.exp.yml | 4 + .../docker-compose.exp.yml | 4 + .../.docker/.gitignore | 0 .../.docker/config.php.dist | 35 ++++ .../custom_cloud_no_tls_service/composer.json | 6 + .../docker-compose.exp.yml | 119 +++++++++++ .../.docker/.gitignore | 0 .../.docker/config.php.dist | 35 ++++ .../composer.json | 6 + .../docker-compose.exp.yml | 109 +++++++++++ .../.docker/.gitignore | 0 .../.docker/config.php.dist | 35 ++++ .../composer.json | 6 + .../docker-compose.exp.yml | 126 ++++++++++++ 49 files changed, 1567 insertions(+), 23 deletions(-) create mode 100644 src/Test/Integration/_files/cloud_no_tls_service/.docker/.gitignore create mode 100644 src/Test/Integration/_files/cloud_no_tls_service/.docker/config.php.dist create mode 100644 src/Test/Integration/_files/cloud_no_tls_service/.magento.app.yaml create mode 100644 src/Test/Integration/_files/cloud_no_tls_service/.magento/services.yaml create mode 100644 src/Test/Integration/_files/cloud_no_tls_service/composer.json create mode 100644 src/Test/Integration/_files/cloud_no_tls_service/docker-compose.exp.yml create mode 100644 src/Test/Integration/_files/cloud_no_varnish_and_tls_service/.docker/.gitignore create mode 100644 src/Test/Integration/_files/cloud_no_varnish_and_tls_service/.docker/config.php.dist create mode 100644 src/Test/Integration/_files/cloud_no_varnish_and_tls_service/.magento.app.yaml create mode 100644 src/Test/Integration/_files/cloud_no_varnish_and_tls_service/.magento/services.yaml create mode 100644 src/Test/Integration/_files/cloud_no_varnish_and_tls_service/composer.json create mode 100644 src/Test/Integration/_files/cloud_no_varnish_and_tls_service/docker-compose.exp.yml create mode 100644 src/Test/Integration/_files/cloud_no_varnish_service/.docker/.gitignore create mode 100644 src/Test/Integration/_files/cloud_no_varnish_service/.docker/config.php.dist create mode 100644 src/Test/Integration/_files/cloud_no_varnish_service/.magento.app.yaml create mode 100644 src/Test/Integration/_files/cloud_no_varnish_service/.magento/services.yaml create mode 100644 src/Test/Integration/_files/cloud_no_varnish_service/composer.json create mode 100644 src/Test/Integration/_files/cloud_no_varnish_service/docker-compose.exp.yml create mode 100644 src/Test/Integration/_files/custom_cloud_no_tls_service/.docker/.gitignore create mode 100644 src/Test/Integration/_files/custom_cloud_no_tls_service/.docker/config.php.dist create mode 100644 src/Test/Integration/_files/custom_cloud_no_tls_service/composer.json create mode 100644 src/Test/Integration/_files/custom_cloud_no_tls_service/docker-compose.exp.yml create mode 100644 src/Test/Integration/_files/custom_cloud_no_varnish_and_tls_services/.docker/.gitignore create mode 100644 src/Test/Integration/_files/custom_cloud_no_varnish_and_tls_services/.docker/config.php.dist create mode 100644 src/Test/Integration/_files/custom_cloud_no_varnish_and_tls_services/composer.json create mode 100644 src/Test/Integration/_files/custom_cloud_no_varnish_and_tls_services/docker-compose.exp.yml create mode 100644 src/Test/Integration/_files/custom_cloud_no_varnish_service/.docker/.gitignore create mode 100644 src/Test/Integration/_files/custom_cloud_no_varnish_service/.docker/config.php.dist create mode 100644 src/Test/Integration/_files/custom_cloud_no_varnish_service/composer.json create mode 100644 src/Test/Integration/_files/custom_cloud_no_varnish_service/docker-compose.exp.yml diff --git a/images/nginx/1.19/Dockerfile b/images/nginx/1.19/Dockerfile index 8067b8cb..185a10a7 100644 --- a/images/nginx/1.19/Dockerfile +++ b/images/nginx/1.19/Dockerfile @@ -10,6 +10,8 @@ ENV MAGENTO_ROOT /app ENV MAGENTO_RUN_MODE production ENV MFTF_UTILS 0 ENV DEBUG false +ENV NGINX_WORKER_PROCESSES 1 +ENV NGINX_WORKER_CONNECTIONS 1024 COPY etc/nginx.conf /etc/nginx/ COPY etc/vhost.conf /etc/nginx/conf.d/default.conf diff --git a/images/nginx/1.19/docker-entrypoint.sh b/images/nginx/1.19/docker-entrypoint.sh index d0c6fe5b..c8bd0383 100755 --- a/images/nginx/1.19/docker-entrypoint.sh +++ b/images/nginx/1.19/docker-entrypoint.sh @@ -18,6 +18,8 @@ XDEBUG_UPSTREAM_FILE="/etc/nginx/conf.d/xdebug/upstream.conf" [ ! -z "${UPLOAD_MAX_FILESIZE}" ] && sed -i "s/!UPLOAD_MAX_FILESIZE!/${UPLOAD_MAX_FILESIZE}/" $VHOST_FILE [ ! -z "${WITH_XDEBUG}" ] && sed -i "s/!WITH_XDEBUG!/${WITH_XDEBUG}/" $VHOST_FILE [ "${WITH_XDEBUG}" == "1" ] && sed -i "s/#include_xdebug_upstream/include/" $NGINX_FILE +[ ! -z "${NGINX_WORKER_PROCESSES}" ] && sed -i "s/!NGINX_WORKER_PROCESSES!/${NGINX_WORKER_PROCESSES}/" $NGINX_FILE +[ ! -z "${NGINX_WORKER_CONNECTIONS}" ] && sed -i "s/!NGINX_WORKER_CONNECTIONS!/${NGINX_WORKER_CONNECTIONS}/" $NGINX_FILE # Check if the nginx syntax is fine, then launch. nginx -t diff --git a/images/nginx/1.19/etc/nginx.conf b/images/nginx/1.19/etc/nginx.conf index 2be3e740..530fb8b6 100644 --- a/images/nginx/1.19/etc/nginx.conf +++ b/images/nginx/1.19/etc/nginx.conf @@ -1,4 +1,4 @@ -worker_processes 2; +worker_processes !NGINX_WORKER_PROCESSES!; error_log /var/log/nginx/error.log debug; pid /var/run/nginx.pid; @@ -6,7 +6,7 @@ pid /var/run/nginx.pid; events { # this should be equal to value of "ulimit -n" # reference: https://www.digitalocean.com/community/tutorials/how-to-optimize-nginx-configuration - worker_connections 1048576; + worker_connections !NGINX_WORKER_CONNECTIONS!; } http { diff --git a/src/Command/BuildCompose.php b/src/Command/BuildCompose.php index 093303c5..79e2d849 100644 --- a/src/Command/BuildCompose.php +++ b/src/Command/BuildCompose.php @@ -186,6 +186,18 @@ protected function configure(): void null, InputOption::VALUE_NONE, 'Sets host.docker.internal for fpm_xdebug container to resolve debug issue for LINUX system' + )->addOption( + Source\CliSource::OPTION_NGINX_WORKER_PROCESSES, + null, + InputOption::VALUE_OPTIONAL, + 'The number of NGINX worker processes', + Source\BaseSource::DEFAULT_NGINX_WORKER_PROCESSES + )->addOption( + Source\CliSource::OPTION_NGINX_WORKER_CONNECTIONS, + null, + InputOption::VALUE_OPTIONAL, + 'The maximum number of connections that each worker process can handle simultaneously', + Source\BaseSource::DEFAULT_NGINX_WORKER_CONNECTIONS ); $this->addOption( @@ -261,6 +273,11 @@ protected function configure(): void null, InputOption::VALUE_REQUIRED, 'Port' + )->addOption( + Source\CliSource::OPTION_NO_TLS, + null, + InputOption::VALUE_NONE, + 'Disable TLS' )->addOption( Source\CliSource::OPTION_TLS_PORT, null, diff --git a/src/Compose/ProductionBuilder.php b/src/Compose/ProductionBuilder.php index 7fe1e08b..2488b4fa 100644 --- a/src/Compose/ProductionBuilder.php +++ b/src/Compose/ProductionBuilder.php @@ -7,6 +7,8 @@ namespace Magento\CloudDocker\Compose; +use Magento\CloudDocker\App\ConfigurationMismatchException; +use Magento\CloudDocker\Compose\ProductionBuilder\ServiceBuilderInterface; use Magento\CloudDocker\Compose\ProductionBuilder\ServicePool; use Magento\CloudDocker\Compose\ProductionBuilder\VolumeResolver; use Magento\CloudDocker\Config\Config; @@ -35,7 +37,6 @@ class ProductionBuilder implements BuilderInterface self::SERVICE_GENERIC, self::SERVICE_DEPLOY, self::SERVICE_BUILD, - self::SERVICE_TLS, self::SERVICE_WEB, self::SERVICE_FPM, self::SERVICE_DB, @@ -91,7 +92,7 @@ public function build(Config $config): Manager $manager = $this->managerFactory->create($config); foreach ($this->servicePool->getServices() as $service) { - if ($config->hasServiceEnabled($service->getServiceName()) + if ($this->hasServiceEnabled($service, $config) || in_array($service->getName(), self::$requiredServices) ) { $manager->addService($service); @@ -135,4 +136,24 @@ public function getPath(): string { return $this->fileList->getMagentoDockerCompose(); } + + /** + * Checks the availability of the service + * + * @param ServiceBuilderInterface $service + * @param Config $config + * @return bool + * @throws ConfigurationMismatchException + */ + private function hasServiceEnabled(ServiceBuilderInterface $service, Config $config): bool + { + $serviceNames = [ + BuilderInterface::SERVICE_FPM_XDEBUG, + BuilderInterface::SERVICE_DB_QUOTE, + BuilderInterface::SERVICE_DB_SALES, + ]; + $service = in_array($service->getName(), $serviceNames) ? $service->getServiceName() : $service->getName(); + + return $config->hasServiceEnabled($service); + } } diff --git a/src/Compose/ProductionBuilder/Service/Tls.php b/src/Compose/ProductionBuilder/Service/Tls.php index 66ad05f0..606a794f 100644 --- a/src/Compose/ProductionBuilder/Service/Tls.php +++ b/src/Compose/ProductionBuilder/Service/Tls.php @@ -62,7 +62,7 @@ public function getConfig(Config $config): array 'aliases' => [$config->getHost()] ] ], - 'environment' => $this->getBackendServiceUpstream($config), + 'environment' => $this->getEnvironmentVariables($config), 'ports' => [ $config->getPort() . ':80', $config->getTlsPort() . ':443' @@ -106,18 +106,23 @@ private function getBackendService(Config $config): string * @return string[] * @throws ConfigurationMismatchException */ - private function getBackendServiceUpstream(Config $config): array + private function getEnvironmentVariables(Config $config): array { + $envVariables = [ + 'NGINX_WORKER_PROCESSES=' . $config->getNginxWorkerProcesses(), + 'NGINX_WORKER_CONNECTIONS=' . $config->getNginxWorkerConnections(), + ]; + if ($config->hasServiceEnabled(ServiceInterface::SERVICE_VARNISH)) { - return [ - 'UPSTREAM_HOST=' . BuilderInterface::SERVICE_VARNISH, - 'UPSTREAM_PORT=80' - ]; + $envVariables[] = 'UPSTREAM_HOST=' . BuilderInterface::SERVICE_VARNISH; + $envVariables[] = 'UPSTREAM_PORT=80'; + + return $envVariables; } - return [ - 'UPSTREAM_HOST=' . BuilderInterface::SERVICE_WEB, - 'UPSTREAM_PORT=8080' - ]; + $envVariables[] = 'UPSTREAM_HOST=' . BuilderInterface::SERVICE_WEB; + $envVariables[] = 'UPSTREAM_PORT=8080'; + + return $envVariables; } } diff --git a/src/Compose/ProductionBuilder/Service/Varnish.php b/src/Compose/ProductionBuilder/Service/Varnish.php index 0fffb6d6..aee12c50 100644 --- a/src/Compose/ProductionBuilder/Service/Varnish.php +++ b/src/Compose/ProductionBuilder/Service/Varnish.php @@ -11,6 +11,7 @@ use Magento\CloudDocker\Compose\ProductionBuilder\ServiceBuilderInterface; use Magento\CloudDocker\Config\Config; use Magento\CloudDocker\Service\ServiceFactory; +use Magento\CloudDocker\Service\ServiceInterface; /** * Returns Varnish service configuration @@ -51,13 +52,24 @@ public function getServiceName(): string */ public function getConfig(Config $config): array { - return $this->serviceFactory->create( + $result = $this->serviceFactory->create( $this->getServiceName(), $config->getServiceVersion($this->getServiceName()), [], $config->getServiceImage($this->getServiceName()), $config->getServiceImagePattern($this->getServiceName()) ); + + if (!$config->hasServiceEnabled(ServiceInterface::SERVICE_TLS)) { + $result['ports'] = [$config->getPort() . ':80']; + $result['networks'] = [ + BuilderInterface::NETWORK_MAGENTO => [ + 'aliases' => [$config->getHost()] + ] + ]; + } + + return $result; } /** diff --git a/src/Compose/ProductionBuilder/Service/Web.php b/src/Compose/ProductionBuilder/Service/Web.php index 9296983a..c2a33bf7 100644 --- a/src/Compose/ProductionBuilder/Service/Web.php +++ b/src/Compose/ProductionBuilder/Service/Web.php @@ -60,18 +60,33 @@ public function getServiceName(): string */ public function getConfig(Config $config): array { - return $this->serviceFactory->create( + $result = $this->serviceFactory->create( $this->getServiceName(), $config->getServiceVersion(ServiceInterface::SERVICE_NGINX), [ 'volumes' => $this->volume->getRo($config), 'environment' => [ - 'WITH_XDEBUG=' . (int)$config->hasServiceEnabled(ServiceInterface::SERVICE_FPM_XDEBUG) - ] + 'WITH_XDEBUG=' . (int)$config->hasServiceEnabled(ServiceInterface::SERVICE_FPM_XDEBUG), + 'NGINX_WORKER_PROCESSES=' . $config->getNginxWorkerProcesses(), + 'NGINX_WORKER_CONNECTIONS=' . $config->getNginxWorkerConnections(), + ], ], $config->getServiceImage(ServiceInterface::SERVICE_NGINX), $config->getServiceImagePattern(ServiceInterface::SERVICE_NGINX) ); + + if (!$config->hasServiceEnabled(ServiceInterface::SERVICE_TLS) + && !$config->hasServiceEnabled(ServiceInterface::SERVICE_VARNISH) + ) { + $result['ports'] = [$config->getPort() . ':8080']; + $result['networks'] = [ + BuilderInterface::NETWORK_MAGENTO => [ + 'aliases' => [$config->getHost()] + ] + ]; + } + + return $result; } /** diff --git a/src/Config/Config.php b/src/Config/Config.php index cb53d528..5aa266eb 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -467,4 +467,28 @@ public function getMailHogHttpPort(): ?string { return $this->all()->get(SourceInterface::SYSTEM_MAILHOG_HTTP_PORT); } + + /** + * Returns the value of the `worker_processes` parameter of the Nginx service + * + * @return string + * @throws ConfigurationMismatchException + */ + public function getNginxWorkerProcesses(): string + { + $value = $this->all()->get(SourceInterface::SYSTEM_NGINX_WORKER_PROCESSES); + if (SourceInterface::NGINX_WORKER_PROCESSES_AUTO === $value) { + return $value; + } + return (string)$value; + } + + /** + * @return int + * @throws ConfigurationMismatchException + */ + public function getNginxWorkerConnections() + { + return (int)$this->all()->get(SourceInterface::SYSTEM_NGINX_WORKER_CONNECTIONS); + } } diff --git a/src/Config/Source/BaseSource.php b/src/Config/Source/BaseSource.php index 202537c7..695b19fa 100644 --- a/src/Config/Source/BaseSource.php +++ b/src/Config/Source/BaseSource.php @@ -29,6 +29,8 @@ class BaseSource implements SourceInterface public const DEFAULT_TLS_PORT = '443'; public const DEFAULT_MAILHOG_SMTP_PORT = '1025'; public const DEFAULT_MAILHOG_HTTP_PORT = '8025'; + public const DEFAULT_NGINX_WORKER_PROCESSES = '1'; + public const DEFAULT_NGINX_WORKER_CONNECTIONS = '1024'; /** * @var EnvReader @@ -77,7 +79,9 @@ public function read(): Repository self::INSTALLATION_TYPE => self::INSTALLATION_TYPE_COMPOSER, self::MAGENTO_VERSION => $this->getMagentoVersion(), self::SYSTEM_MAILHOG_SMTP_PORT => self::DEFAULT_MAILHOG_SMTP_PORT, - self::SYSTEM_MAILHOG_HTTP_PORT => self::DEFAULT_MAILHOG_HTTP_PORT + self::SYSTEM_MAILHOG_HTTP_PORT => self::DEFAULT_MAILHOG_HTTP_PORT, + self::SYSTEM_NGINX_WORKER_PROCESSES => self::DEFAULT_NGINX_WORKER_PROCESSES, + self::SYSTEM_NGINX_WORKER_CONNECTIONS => self::DEFAULT_NGINX_WORKER_CONNECTIONS, ]); try { diff --git a/src/Config/Source/CliSource.php b/src/Config/Source/CliSource.php index 6224d412..09dfbfba 100644 --- a/src/Config/Source/CliSource.php +++ b/src/Config/Source/CliSource.php @@ -33,6 +33,7 @@ class CliSource implements SourceInterface public const OPTION_INSTALLATION_TYPE = 'installation-type'; public const OPTION_NO_ES = 'no-es'; public const OPTION_NO_MAILHOG = 'no-mailhog'; + public const OPTION_NO_TLS = 'no-tls'; /** * MailHog configuration @@ -67,6 +68,8 @@ class CliSource implements SourceInterface public const OPTION_HOST = 'host'; public const OPTION_PORT = 'port'; public const OPTION_TLS_PORT = 'tls-port'; + public const OPTION_NGINX_WORKER_PROCESSES = 'nginx-worker-processes'; + public const OPTION_NGINX_WORKER_CONNECTIONS = 'nginx-worker-connections'; public const OPTION_DB_INCREMENT_INCREMENT = 'db-increment-increment'; public const OPTION_DB_INCREMENT_OFFSET = 'db-increment-offset'; @@ -115,6 +118,7 @@ class CliSource implements SourceInterface private static $disableOptionsMap = [ self::OPTION_NO_ES => self::SERVICES_ES, self::OPTION_NO_MAILHOG => self::SERVICES_MAILHOG, + self::OPTION_NO_TLS => self::SERVICES_TLS, ]; /** @@ -298,6 +302,14 @@ public function read(): Repository $repository->set(self::SYSTEM_MAILHOG_HTTP_PORT, $port); } + if ($nginxWorkerProcesses = $this->input->getOption(self::OPTION_NGINX_WORKER_PROCESSES)) { + $repository->set(self::SYSTEM_NGINX_WORKER_PROCESSES, $nginxWorkerProcesses); + } + + if ($nginxWorkerConnections = $this->input->getOption(self::OPTION_NGINX_WORKER_CONNECTIONS)) { + $repository->set(self::SYSTEM_NGINX_WORKER_CONNECTIONS, $nginxWorkerConnections); + } + return $repository; } } diff --git a/src/Config/Source/SourceInterface.php b/src/Config/Source/SourceInterface.php index c4488b81..e8d50d85 100644 --- a/src/Config/Source/SourceInterface.php +++ b/src/Config/Source/SourceInterface.php @@ -20,6 +20,8 @@ interface SourceInterface public const MOUNTS = 'mounts'; public const NAME = 'name'; + public const NGINX_WORKER_PROCESSES_AUTO = 'auto'; + /** * Services */ @@ -125,6 +127,11 @@ interface SourceInterface public const MAGENTO_VERSION = 'magento.version'; + /** + * TLS + */ + public const SERVICES_TLS = self::SERVICES . '.' . ServiceInterface::SERVICE_TLS; + /** * Config */ @@ -142,6 +149,8 @@ interface SourceInterface public const SYSTEM_SET_DOCKER_HOST = 'system.set_docker_host'; public const SYSTEM_MAILHOG_SMTP_PORT = 'system.mailhog.smtp_port'; public const SYSTEM_MAILHOG_HTTP_PORT = 'system.mailhog.http_port'; + public const SYSTEM_NGINX_WORKER_PROCESSES = 'system.nginx.worker_processes'; + public const SYSTEM_NGINX_WORKER_CONNECTIONS = 'system.nginx.worker_connections'; public const SYSTEM_DB_INCREMENT_INCREMENT = 'system.db.increment_increment'; public const SYSTEM_DB_INCREMENT_OFFSET = 'system.db.increment_offset'; diff --git a/src/Test/Integration/BuildComposeTest.php b/src/Test/Integration/BuildComposeTest.php index df35305c..eafed492 100644 --- a/src/Test/Integration/BuildComposeTest.php +++ b/src/Test/Integration/BuildComposeTest.php @@ -94,7 +94,9 @@ public function buildDataProvider(): array [CliSource::OPTION_WITH_ENTRYPOINT, true], [CliSource::OPTION_WITH_MARIADB_CONF, true], [CliSource::OPTION_TLS_PORT, '4443'], - [CliSource::OPTION_NO_MAILHOG, true] + [CliSource::OPTION_NO_MAILHOG, true], + [CliSource::OPTION_NGINX_WORKER_PROCESSES, '8'], + [CliSource::OPTION_NGINX_WORKER_CONNECTIONS, '4096'], ] ], 'cloud-base-test' => [ @@ -111,9 +113,32 @@ public function buildDataProvider(): array [CliSource::OPTION_WITH_ENTRYPOINT, true], [CliSource::OPTION_WITH_MARIADB_CONF, true], [CliSource::OPTION_TLS_PORT, '4443'], - [CliSource::OPTION_NO_MAILHOG, true] + [CliSource::OPTION_NO_MAILHOG, true], + [CliSource::OPTION_NGINX_WORKER_PROCESSES, 'auto'], ] - ] + ], + 'without TLS service' => [ + __DIR__ . '/_files/cloud_no_tls_service', + [ + [CliSource::OPTION_MODE, BuilderFactory::BUILDER_PRODUCTION], + [CliSource::OPTION_NO_TLS, true], + ] + ], + 'without Varnish service' => [ + __DIR__ . '/_files/cloud_no_varnish_service', + [ + [CliSource::OPTION_MODE, BuilderFactory::BUILDER_PRODUCTION], + [CliSource::OPTION_NO_VARNISH, true], + ] + ], + 'without Varnish and TLS services' => [ + __DIR__ . '/_files/cloud_no_varnish_and_tls_service', + [ + [CliSource::OPTION_MODE, BuilderFactory::BUILDER_PRODUCTION], + [CliSource::OPTION_NO_VARNISH, true], + [CliSource::OPTION_NO_TLS, true], + ] + ], ]; } } diff --git a/src/Test/Integration/BuildCustomComposeTest.php b/src/Test/Integration/BuildCustomComposeTest.php index 1fb6fe26..6bf87f1b 100644 --- a/src/Test/Integration/BuildCustomComposeTest.php +++ b/src/Test/Integration/BuildCustomComposeTest.php @@ -144,6 +144,10 @@ public function buildDataProvider(): array 'mailhog' => [ 'smtp_port' => '1026', 'http_port' => '8026' + ], + 'nginx' => [ + 'worker_processes' => 'auto', + 'worker_connections' => 4096 ] ], 'services' => [ @@ -213,7 +217,83 @@ public function buildDataProvider(): array ]) ] ] - ] + ], + 'without TLS service' => [ + __DIR__ . '/_files/custom_cloud_no_tls_service', + [ + [ + BuildCustomCompose::ARG_SOURCE, + json_encode([ + 'name' => 'magento', + 'system' => [ + 'mode' => 'production', + 'nginx' => [ + 'worker_processes' => 4, + 'worker_connections' => 2048 + ] + ], + 'services' => [ + 'php' => [ + 'enabled' => true, + 'version' => '7.2', + ], + 'mysql' => [ + 'enabled' => true, + 'version' => '10.0', + ], + 'tls' => ['enabled' => false], + ], + ]) + ] + ] + ], + 'without Varnish service' => [ + __DIR__ . '/_files/custom_cloud_no_varnish_service', + [ + [ + BuildCustomCompose::ARG_SOURCE, + json_encode([ + 'name' => 'magento', + 'system' => ['mode' => 'production'], + 'services' => [ + 'php' => [ + 'enabled' => true, + 'version' => '7.2', + ], + 'mysql' => [ + 'enabled' => true, + 'version' => '10.0', + ], + 'varnish' => ['enabled' => false], + ], + ]) + ] + ] + ], + 'without Varnish and TLS services' => [ + __DIR__ . '/_files/custom_cloud_no_varnish_and_tls_services', + [ + [ + BuildCustomCompose::ARG_SOURCE, + json_encode([ + 'name' => 'magento', + 'system' => ['mode' => 'production'], + 'services' => [ + 'php' => [ + 'enabled' => true, + 'version' => '7.2', + ], + 'mysql' => [ + 'enabled' => true, + 'version' => '10.0', + ], + 'varnish' => ['enabled' => false], + 'tls' => ['enabled' => false], + ], + ]) + ] + ] + ], ]; } } diff --git a/src/Test/Integration/_files/cloud_base/docker-compose.exp.yml b/src/Test/Integration/_files/cloud_base/docker-compose.exp.yml index b011cddb..746a88b7 100644 --- a/src/Test/Integration/_files/cloud_base/docker-compose.exp.yml +++ b/src/Test/Integration/_files/cloud_base/docker-compose.exp.yml @@ -84,6 +84,8 @@ services: - '.docker/mnt:/mnt:rw,delegated' environment: - WITH_XDEBUG=0 + - NGINX_WORKER_PROCESSES=1 + - NGINX_WORKER_CONNECTIONS=1024 networks: magento: aliases: @@ -110,6 +112,8 @@ services: aliases: - magento2.docker environment: + - NGINX_WORKER_PROCESSES=1 + - NGINX_WORKER_CONNECTIONS=1024 - UPSTREAM_HOST=varnish - UPSTREAM_PORT=80 ports: diff --git a/src/Test/Integration/_files/cloud_base_mftf/docker-compose.exp.yml b/src/Test/Integration/_files/cloud_base_mftf/docker-compose.exp.yml index 8c9f71e2..a54dec99 100644 --- a/src/Test/Integration/_files/cloud_base_mftf/docker-compose.exp.yml +++ b/src/Test/Integration/_files/cloud_base_mftf/docker-compose.exp.yml @@ -78,6 +78,8 @@ services: - '.docker/mnt:/mnt:rw,delegated' environment: - WITH_XDEBUG=1 + - NGINX_WORKER_PROCESSES=8 + - NGINX_WORKER_CONNECTIONS=4096 networks: magento: aliases: @@ -104,6 +106,8 @@ services: aliases: - magento2.docker environment: + - NGINX_WORKER_PROCESSES=8 + - NGINX_WORKER_CONNECTIONS=4096 - UPSTREAM_HOST=varnish - UPSTREAM_PORT=80 ports: diff --git a/src/Test/Integration/_files/cloud_base_test/docker-compose.exp.yml b/src/Test/Integration/_files/cloud_base_test/docker-compose.exp.yml index f18493bf..b5e597eb 100644 --- a/src/Test/Integration/_files/cloud_base_test/docker-compose.exp.yml +++ b/src/Test/Integration/_files/cloud_base_test/docker-compose.exp.yml @@ -78,6 +78,8 @@ services: - '.docker/mnt:/mnt:rw,delegated' environment: - WITH_XDEBUG=1 + - NGINX_WORKER_PROCESSES=auto + - NGINX_WORKER_CONNECTIONS=1024 networks: magento: aliases: @@ -104,6 +106,8 @@ services: aliases: - magento2.docker environment: + - NGINX_WORKER_PROCESSES=auto + - NGINX_WORKER_CONNECTIONS=1024 - UPSTREAM_HOST=varnish - UPSTREAM_PORT=80 ports: diff --git a/src/Test/Integration/_files/cloud_no_tls_service/.docker/.gitignore b/src/Test/Integration/_files/cloud_no_tls_service/.docker/.gitignore new file mode 100644 index 00000000..e69de29b diff --git a/src/Test/Integration/_files/cloud_no_tls_service/.docker/config.php.dist b/src/Test/Integration/_files/cloud_no_tls_service/.docker/config.php.dist new file mode 100644 index 00000000..f7b4e9c7 --- /dev/null +++ b/src/Test/Integration/_files/cloud_no_tls_service/.docker/config.php.dist @@ -0,0 +1,47 @@ + base64_encode(json_encode([ + 'database' => [ + [ + 'host' => 'db', + 'path' => 'magento2', + 'password' => 'magento2', + 'username' => 'magento2', + 'port' => '3306' + ] + ], + 'redis' => [ + [ + 'host' => 'redis', + 'port' => '6379' + ] + ], + 'elasticsearch' => [ + [ + 'host' => 'elasticsearch', + 'port' => '9200' + ] + ] + ])), + 'MAGENTO_CLOUD_ROUTES' => base64_encode(json_encode([ + 'http://magento2.docker/' => [ + 'type' => 'upstream', + 'original_url' => 'http://{default}' + ], + 'https://magento2.docker/' => [ + 'type' => 'upstream', + 'original_url' => 'https://{default}' + ] + ])), + 'MAGENTO_CLOUD_VARIABLES' => base64_encode(json_encode([ + 'ADMIN_EMAIL' => 'admin@example.com', + 'ADMIN_PASSWORD' => '123123q', + 'ADMIN_URL' => 'admin' + ])), + 'MAGENTO_CLOUD_APPLICATION' => base64_encode(json_encode([ + 'hooks' => [ + + ] + ])), +]; diff --git a/src/Test/Integration/_files/cloud_no_tls_service/.magento.app.yaml b/src/Test/Integration/_files/cloud_no_tls_service/.magento.app.yaml new file mode 100644 index 00000000..aeaadbd0 --- /dev/null +++ b/src/Test/Integration/_files/cloud_no_tls_service/.magento.app.yaml @@ -0,0 +1,29 @@ +name: mymagento + +type: php:7.3 +build: + flavor: composer + +runtime: + extensions: + - redis + - xsl + - json + - newrelic + - sodium + +relationships: + database: "mysql:mysql" + redis: "redis:redis" + elasticsearch: "elasticsearch:elasticsearch" + +mounts: + "var": "shared:files/var" + "app/etc": "shared:files/etc" + "pub/media": "shared:files/media" + "pub/static": "shared:files/static" + +crons: + cronrun: + spec: "* * * * *" + cmd: "php bin/magento cron:run" diff --git a/src/Test/Integration/_files/cloud_no_tls_service/.magento/services.yaml b/src/Test/Integration/_files/cloud_no_tls_service/.magento/services.yaml new file mode 100644 index 00000000..9ddbe2c1 --- /dev/null +++ b/src/Test/Integration/_files/cloud_no_tls_service/.magento/services.yaml @@ -0,0 +1,14 @@ +mysql: + type: mysql:10.2 + disk: 2048 + +redis: + type: redis:5.0 + +elasticsearch: + type: elasticsearch:6.5 + disk: 1024 + configuration: + plugins: + - plugin_1 + - plugin_2 diff --git a/src/Test/Integration/_files/cloud_no_tls_service/composer.json b/src/Test/Integration/_files/cloud_no_tls_service/composer.json new file mode 100644 index 00000000..6ed415ed --- /dev/null +++ b/src/Test/Integration/_files/cloud_no_tls_service/composer.json @@ -0,0 +1,6 @@ +{ + "name": "magento/project-enterprise-edition", + "description": "Composer file for integration tests", + "type": "project", + "version": "2.2.0" +} diff --git a/src/Test/Integration/_files/cloud_no_tls_service/docker-compose.exp.yml b/src/Test/Integration/_files/cloud_no_tls_service/docker-compose.exp.yml new file mode 100644 index 00000000..c28669e6 --- /dev/null +++ b/src/Test/Integration/_files/cloud_no_tls_service/docker-compose.exp.yml @@ -0,0 +1,178 @@ +version: '2.1' +services: + db: + hostname: db.magento2.docker + image: 'mariadb:10.2' + environment: + - MYSQL_ROOT_PASSWORD=magento2 + - MYSQL_DATABASE=magento2 + - MYSQL_USER=magento2 + - MYSQL_PASSWORD=magento2 + ports: + - '3306' + volumes: + - '.docker/mnt:/mnt:rw,delegated' + - 'mymagento-magento-db:/var/lib/mysql' + healthcheck: + test: 'mysqladmin ping -h localhost -pmagento2' + interval: 30s + timeout: 30s + retries: 3 + networks: + magento: + aliases: + - db.magento2.docker + redis: + hostname: redis.magento2.docker + image: 'redis:5.0' + volumes: + - /data + ports: + - 6379 + healthcheck: + test: 'redis-cli ping || exit 1' + interval: 30s + timeout: 30s + retries: 3 + networks: + magento: + aliases: + - redis.magento2.docker + elasticsearch: + hostname: elasticsearch.magento2.docker + image: 'magento/magento-cloud-docker-elasticsearch:6.5-1.2.0' + environment: + - 'ES_PLUGINS=plugin_1 plugin_2' + networks: + magento: + aliases: + - elasticsearch.magento2.docker + fpm: + hostname: fpm.magento2.docker + image: 'magento/magento-cloud-docker-php:7.3-fpm-1.2.0' + extends: generic + volumes: + - '.:/app:ro,delegated' + - 'magento-vendor:/app/vendor:ro,delegated' + - 'magento-generated:/app/generated:ro,delegated' + - 'magento-var:/app/var:rw,delegated' + - 'magento-app-etc:/app/app/etc:rw,delegated' + - 'magento-pub-media:/app/pub/media:rw,delegated' + - 'magento-pub-static:/app/pub/static:rw,delegated' + - '.docker/mnt:/mnt:rw,delegated' + networks: + magento: + aliases: + - fpm.magento2.docker + depends_on: + db: + condition: service_healthy + web: + hostname: web.magento2.docker + image: 'magento/magento-cloud-docker-nginx:1.19-1.2.0' + extends: generic + volumes: + - '.:/app:ro,delegated' + - 'magento-vendor:/app/vendor:ro,delegated' + - 'magento-generated:/app/generated:ro,delegated' + - 'magento-var:/app/var:rw,delegated' + - 'magento-app-etc:/app/app/etc:rw,delegated' + - 'magento-pub-media:/app/pub/media:rw,delegated' + - 'magento-pub-static:/app/pub/static:rw,delegated' + - '.docker/mnt:/mnt:rw,delegated' + environment: + - WITH_XDEBUG=0 + - NGINX_WORKER_PROCESSES=1 + - NGINX_WORKER_CONNECTIONS=1024 + networks: + magento: + aliases: + - web.magento2.docker + depends_on: + fpm: + condition: service_started + varnish: + hostname: varnish.magento2.docker + image: 'magento/magento-cloud-docker-varnish:6.2-1.2.0' + ports: + - '80:80' + networks: + magento: + aliases: + - magento2.docker + depends_on: + web: + condition: service_started + generic: + hostname: generic.magento2.docker + image: 'magento/magento-cloud-docker-php:7.3-cli-1.2.0' + env_file: ./.docker/config.env + environment: + - 'PHP_EXTENSIONS=bcmath bz2 calendar exif gd gettext intl mysqli pcntl pdo_mysql soap sockets sysvmsg sysvsem sysvshm opcache zip redis xsl sodium' + build: + hostname: build.magento2.docker + image: 'magento/magento-cloud-docker-php:7.3-cli-1.2.0' + extends: generic + volumes: + - '.:/app:rw,delegated' + - 'magento-vendor:/app/vendor:rw,delegated' + - 'magento-generated:/app/generated:rw,delegated' + - '~/.composer/cache:/root/.composer/cache:rw,delegated' + networks: + magento-build: + aliases: + - build.magento2.docker + depends_on: + db: + condition: service_healthy + redis: + condition: service_healthy + elasticsearch: + condition: service_healthy + deploy: + hostname: deploy.magento2.docker + image: 'magento/magento-cloud-docker-php:7.3-cli-1.2.0' + extends: generic + volumes: + - '.:/app:ro,delegated' + - 'magento-vendor:/app/vendor:ro,delegated' + - 'magento-generated:/app/generated:ro,delegated' + - 'magento-var:/app/var:rw,delegated' + - 'magento-app-etc:/app/app/etc:rw,delegated' + - 'magento-pub-media:/app/pub/media:rw,delegated' + - 'magento-pub-static:/app/pub/static:rw,delegated' + - '.docker/mnt:/mnt:rw,delegated' + networks: + magento: + aliases: + - deploy.magento2.docker + depends_on: + db: + condition: service_healthy + redis: + condition: service_healthy + elasticsearch: + condition: service_healthy + mailhog: + hostname: mailhog.magento2.docker + image: 'mailhog/mailhog:latest' + ports: + - '1025:1025' + - '8025:8025' + networks: + magento: + aliases: + - mailhog.magento2.docker +volumes: + magento-vendor: { } + magento-generated: { } + magento-var: { } + magento-app-etc: { } + magento-pub-media: { } + magento-pub-static: { } + mymagento-magento-db: { } +networks: + magento: + driver: bridge + magento-build: + driver: bridge diff --git a/src/Test/Integration/_files/cloud_no_varnish_and_tls_service/.docker/.gitignore b/src/Test/Integration/_files/cloud_no_varnish_and_tls_service/.docker/.gitignore new file mode 100644 index 00000000..e69de29b diff --git a/src/Test/Integration/_files/cloud_no_varnish_and_tls_service/.docker/config.php.dist b/src/Test/Integration/_files/cloud_no_varnish_and_tls_service/.docker/config.php.dist new file mode 100644 index 00000000..f7b4e9c7 --- /dev/null +++ b/src/Test/Integration/_files/cloud_no_varnish_and_tls_service/.docker/config.php.dist @@ -0,0 +1,47 @@ + base64_encode(json_encode([ + 'database' => [ + [ + 'host' => 'db', + 'path' => 'magento2', + 'password' => 'magento2', + 'username' => 'magento2', + 'port' => '3306' + ] + ], + 'redis' => [ + [ + 'host' => 'redis', + 'port' => '6379' + ] + ], + 'elasticsearch' => [ + [ + 'host' => 'elasticsearch', + 'port' => '9200' + ] + ] + ])), + 'MAGENTO_CLOUD_ROUTES' => base64_encode(json_encode([ + 'http://magento2.docker/' => [ + 'type' => 'upstream', + 'original_url' => 'http://{default}' + ], + 'https://magento2.docker/' => [ + 'type' => 'upstream', + 'original_url' => 'https://{default}' + ] + ])), + 'MAGENTO_CLOUD_VARIABLES' => base64_encode(json_encode([ + 'ADMIN_EMAIL' => 'admin@example.com', + 'ADMIN_PASSWORD' => '123123q', + 'ADMIN_URL' => 'admin' + ])), + 'MAGENTO_CLOUD_APPLICATION' => base64_encode(json_encode([ + 'hooks' => [ + + ] + ])), +]; diff --git a/src/Test/Integration/_files/cloud_no_varnish_and_tls_service/.magento.app.yaml b/src/Test/Integration/_files/cloud_no_varnish_and_tls_service/.magento.app.yaml new file mode 100644 index 00000000..aeaadbd0 --- /dev/null +++ b/src/Test/Integration/_files/cloud_no_varnish_and_tls_service/.magento.app.yaml @@ -0,0 +1,29 @@ +name: mymagento + +type: php:7.3 +build: + flavor: composer + +runtime: + extensions: + - redis + - xsl + - json + - newrelic + - sodium + +relationships: + database: "mysql:mysql" + redis: "redis:redis" + elasticsearch: "elasticsearch:elasticsearch" + +mounts: + "var": "shared:files/var" + "app/etc": "shared:files/etc" + "pub/media": "shared:files/media" + "pub/static": "shared:files/static" + +crons: + cronrun: + spec: "* * * * *" + cmd: "php bin/magento cron:run" diff --git a/src/Test/Integration/_files/cloud_no_varnish_and_tls_service/.magento/services.yaml b/src/Test/Integration/_files/cloud_no_varnish_and_tls_service/.magento/services.yaml new file mode 100644 index 00000000..9ddbe2c1 --- /dev/null +++ b/src/Test/Integration/_files/cloud_no_varnish_and_tls_service/.magento/services.yaml @@ -0,0 +1,14 @@ +mysql: + type: mysql:10.2 + disk: 2048 + +redis: + type: redis:5.0 + +elasticsearch: + type: elasticsearch:6.5 + disk: 1024 + configuration: + plugins: + - plugin_1 + - plugin_2 diff --git a/src/Test/Integration/_files/cloud_no_varnish_and_tls_service/composer.json b/src/Test/Integration/_files/cloud_no_varnish_and_tls_service/composer.json new file mode 100644 index 00000000..6ed415ed --- /dev/null +++ b/src/Test/Integration/_files/cloud_no_varnish_and_tls_service/composer.json @@ -0,0 +1,6 @@ +{ + "name": "magento/project-enterprise-edition", + "description": "Composer file for integration tests", + "type": "project", + "version": "2.2.0" +} diff --git a/src/Test/Integration/_files/cloud_no_varnish_and_tls_service/docker-compose.exp.yml b/src/Test/Integration/_files/cloud_no_varnish_and_tls_service/docker-compose.exp.yml new file mode 100644 index 00000000..f13db647 --- /dev/null +++ b/src/Test/Integration/_files/cloud_no_varnish_and_tls_service/docker-compose.exp.yml @@ -0,0 +1,168 @@ +version: '2.1' +services: + db: + hostname: db.magento2.docker + image: 'mariadb:10.2' + environment: + - MYSQL_ROOT_PASSWORD=magento2 + - MYSQL_DATABASE=magento2 + - MYSQL_USER=magento2 + - MYSQL_PASSWORD=magento2 + ports: + - '3306' + volumes: + - '.docker/mnt:/mnt:rw,delegated' + - 'mymagento-magento-db:/var/lib/mysql' + healthcheck: + test: 'mysqladmin ping -h localhost -pmagento2' + interval: 30s + timeout: 30s + retries: 3 + networks: + magento: + aliases: + - db.magento2.docker + redis: + hostname: redis.magento2.docker + image: 'redis:5.0' + volumes: + - /data + ports: + - 6379 + healthcheck: + test: 'redis-cli ping || exit 1' + interval: 30s + timeout: 30s + retries: 3 + networks: + magento: + aliases: + - redis.magento2.docker + elasticsearch: + hostname: elasticsearch.magento2.docker + image: 'magento/magento-cloud-docker-elasticsearch:6.5-1.2.0' + environment: + - 'ES_PLUGINS=plugin_1 plugin_2' + networks: + magento: + aliases: + - elasticsearch.magento2.docker + fpm: + hostname: fpm.magento2.docker + image: 'magento/magento-cloud-docker-php:7.3-fpm-1.2.0' + extends: generic + volumes: + - '.:/app:ro,delegated' + - 'magento-vendor:/app/vendor:ro,delegated' + - 'magento-generated:/app/generated:ro,delegated' + - 'magento-var:/app/var:rw,delegated' + - 'magento-app-etc:/app/app/etc:rw,delegated' + - 'magento-pub-media:/app/pub/media:rw,delegated' + - 'magento-pub-static:/app/pub/static:rw,delegated' + - '.docker/mnt:/mnt:rw,delegated' + networks: + magento: + aliases: + - fpm.magento2.docker + depends_on: + db: + condition: service_healthy + web: + hostname: web.magento2.docker + image: 'magento/magento-cloud-docker-nginx:1.19-1.2.0' + extends: generic + volumes: + - '.:/app:ro,delegated' + - 'magento-vendor:/app/vendor:ro,delegated' + - 'magento-generated:/app/generated:ro,delegated' + - 'magento-var:/app/var:rw,delegated' + - 'magento-app-etc:/app/app/etc:rw,delegated' + - 'magento-pub-media:/app/pub/media:rw,delegated' + - 'magento-pub-static:/app/pub/static:rw,delegated' + - '.docker/mnt:/mnt:rw,delegated' + environment: + - WITH_XDEBUG=0 + - NGINX_WORKER_PROCESSES=1 + - NGINX_WORKER_CONNECTIONS=1024 + ports: + - '80:8080' + networks: + magento: + aliases: + - magento2.docker + depends_on: + fpm: + condition: service_started + generic: + hostname: generic.magento2.docker + image: 'magento/magento-cloud-docker-php:7.3-cli-1.2.0' + env_file: ./.docker/config.env + environment: + - 'PHP_EXTENSIONS=bcmath bz2 calendar exif gd gettext intl mysqli pcntl pdo_mysql soap sockets sysvmsg sysvsem sysvshm opcache zip redis xsl sodium' + build: + hostname: build.magento2.docker + image: 'magento/magento-cloud-docker-php:7.3-cli-1.2.0' + extends: generic + volumes: + - '.:/app:rw,delegated' + - 'magento-vendor:/app/vendor:rw,delegated' + - 'magento-generated:/app/generated:rw,delegated' + - '~/.composer/cache:/root/.composer/cache:rw,delegated' + networks: + magento-build: + aliases: + - build.magento2.docker + depends_on: + db: + condition: service_healthy + redis: + condition: service_healthy + elasticsearch: + condition: service_healthy + deploy: + hostname: deploy.magento2.docker + image: 'magento/magento-cloud-docker-php:7.3-cli-1.2.0' + extends: generic + volumes: + - '.:/app:ro,delegated' + - 'magento-vendor:/app/vendor:ro,delegated' + - 'magento-generated:/app/generated:ro,delegated' + - 'magento-var:/app/var:rw,delegated' + - 'magento-app-etc:/app/app/etc:rw,delegated' + - 'magento-pub-media:/app/pub/media:rw,delegated' + - 'magento-pub-static:/app/pub/static:rw,delegated' + - '.docker/mnt:/mnt:rw,delegated' + networks: + magento: + aliases: + - deploy.magento2.docker + depends_on: + db: + condition: service_healthy + redis: + condition: service_healthy + elasticsearch: + condition: service_healthy + mailhog: + hostname: mailhog.magento2.docker + image: 'mailhog/mailhog:latest' + ports: + - '1025:1025' + - '8025:8025' + networks: + magento: + aliases: + - mailhog.magento2.docker +volumes: + magento-vendor: { } + magento-generated: { } + magento-var: { } + magento-app-etc: { } + magento-pub-media: { } + magento-pub-static: { } + mymagento-magento-db: { } +networks: + magento: + driver: bridge + magento-build: + driver: bridge diff --git a/src/Test/Integration/_files/cloud_no_varnish_service/.docker/.gitignore b/src/Test/Integration/_files/cloud_no_varnish_service/.docker/.gitignore new file mode 100644 index 00000000..e69de29b diff --git a/src/Test/Integration/_files/cloud_no_varnish_service/.docker/config.php.dist b/src/Test/Integration/_files/cloud_no_varnish_service/.docker/config.php.dist new file mode 100644 index 00000000..f7b4e9c7 --- /dev/null +++ b/src/Test/Integration/_files/cloud_no_varnish_service/.docker/config.php.dist @@ -0,0 +1,47 @@ + base64_encode(json_encode([ + 'database' => [ + [ + 'host' => 'db', + 'path' => 'magento2', + 'password' => 'magento2', + 'username' => 'magento2', + 'port' => '3306' + ] + ], + 'redis' => [ + [ + 'host' => 'redis', + 'port' => '6379' + ] + ], + 'elasticsearch' => [ + [ + 'host' => 'elasticsearch', + 'port' => '9200' + ] + ] + ])), + 'MAGENTO_CLOUD_ROUTES' => base64_encode(json_encode([ + 'http://magento2.docker/' => [ + 'type' => 'upstream', + 'original_url' => 'http://{default}' + ], + 'https://magento2.docker/' => [ + 'type' => 'upstream', + 'original_url' => 'https://{default}' + ] + ])), + 'MAGENTO_CLOUD_VARIABLES' => base64_encode(json_encode([ + 'ADMIN_EMAIL' => 'admin@example.com', + 'ADMIN_PASSWORD' => '123123q', + 'ADMIN_URL' => 'admin' + ])), + 'MAGENTO_CLOUD_APPLICATION' => base64_encode(json_encode([ + 'hooks' => [ + + ] + ])), +]; diff --git a/src/Test/Integration/_files/cloud_no_varnish_service/.magento.app.yaml b/src/Test/Integration/_files/cloud_no_varnish_service/.magento.app.yaml new file mode 100644 index 00000000..aeaadbd0 --- /dev/null +++ b/src/Test/Integration/_files/cloud_no_varnish_service/.magento.app.yaml @@ -0,0 +1,29 @@ +name: mymagento + +type: php:7.3 +build: + flavor: composer + +runtime: + extensions: + - redis + - xsl + - json + - newrelic + - sodium + +relationships: + database: "mysql:mysql" + redis: "redis:redis" + elasticsearch: "elasticsearch:elasticsearch" + +mounts: + "var": "shared:files/var" + "app/etc": "shared:files/etc" + "pub/media": "shared:files/media" + "pub/static": "shared:files/static" + +crons: + cronrun: + spec: "* * * * *" + cmd: "php bin/magento cron:run" diff --git a/src/Test/Integration/_files/cloud_no_varnish_service/.magento/services.yaml b/src/Test/Integration/_files/cloud_no_varnish_service/.magento/services.yaml new file mode 100644 index 00000000..9ddbe2c1 --- /dev/null +++ b/src/Test/Integration/_files/cloud_no_varnish_service/.magento/services.yaml @@ -0,0 +1,14 @@ +mysql: + type: mysql:10.2 + disk: 2048 + +redis: + type: redis:5.0 + +elasticsearch: + type: elasticsearch:6.5 + disk: 1024 + configuration: + plugins: + - plugin_1 + - plugin_2 diff --git a/src/Test/Integration/_files/cloud_no_varnish_service/composer.json b/src/Test/Integration/_files/cloud_no_varnish_service/composer.json new file mode 100644 index 00000000..6ed415ed --- /dev/null +++ b/src/Test/Integration/_files/cloud_no_varnish_service/composer.json @@ -0,0 +1,6 @@ +{ + "name": "magento/project-enterprise-edition", + "description": "Composer file for integration tests", + "type": "project", + "version": "2.2.0" +} diff --git a/src/Test/Integration/_files/cloud_no_varnish_service/docker-compose.exp.yml b/src/Test/Integration/_files/cloud_no_varnish_service/docker-compose.exp.yml new file mode 100644 index 00000000..478e8e3d --- /dev/null +++ b/src/Test/Integration/_files/cloud_no_varnish_service/docker-compose.exp.yml @@ -0,0 +1,185 @@ +version: '2.1' +services: + db: + hostname: db.magento2.docker + image: 'mariadb:10.2' + environment: + - MYSQL_ROOT_PASSWORD=magento2 + - MYSQL_DATABASE=magento2 + - MYSQL_USER=magento2 + - MYSQL_PASSWORD=magento2 + ports: + - '3306' + volumes: + - '.docker/mnt:/mnt:rw,delegated' + - 'mymagento-magento-db:/var/lib/mysql' + healthcheck: + test: 'mysqladmin ping -h localhost -pmagento2' + interval: 30s + timeout: 30s + retries: 3 + networks: + magento: + aliases: + - db.magento2.docker + redis: + hostname: redis.magento2.docker + image: 'redis:5.0' + volumes: + - /data + ports: + - 6379 + healthcheck: + test: 'redis-cli ping || exit 1' + interval: 30s + timeout: 30s + retries: 3 + networks: + magento: + aliases: + - redis.magento2.docker + elasticsearch: + hostname: elasticsearch.magento2.docker + image: 'magento/magento-cloud-docker-elasticsearch:6.5-1.2.0' + environment: + - 'ES_PLUGINS=plugin_1 plugin_2' + networks: + magento: + aliases: + - elasticsearch.magento2.docker + fpm: + hostname: fpm.magento2.docker + image: 'magento/magento-cloud-docker-php:7.3-fpm-1.2.0' + extends: generic + volumes: + - '.:/app:ro,delegated' + - 'magento-vendor:/app/vendor:ro,delegated' + - 'magento-generated:/app/generated:ro,delegated' + - 'magento-var:/app/var:rw,delegated' + - 'magento-app-etc:/app/app/etc:rw,delegated' + - 'magento-pub-media:/app/pub/media:rw,delegated' + - 'magento-pub-static:/app/pub/static:rw,delegated' + - '.docker/mnt:/mnt:rw,delegated' + networks: + magento: + aliases: + - fpm.magento2.docker + depends_on: + db: + condition: service_healthy + web: + hostname: web.magento2.docker + image: 'magento/magento-cloud-docker-nginx:1.19-1.2.0' + extends: generic + volumes: + - '.:/app:ro,delegated' + - 'magento-vendor:/app/vendor:ro,delegated' + - 'magento-generated:/app/generated:ro,delegated' + - 'magento-var:/app/var:rw,delegated' + - 'magento-app-etc:/app/app/etc:rw,delegated' + - 'magento-pub-media:/app/pub/media:rw,delegated' + - 'magento-pub-static:/app/pub/static:rw,delegated' + - '.docker/mnt:/mnt:rw,delegated' + environment: + - WITH_XDEBUG=0 + - NGINX_WORKER_PROCESSES=1 + - NGINX_WORKER_CONNECTIONS=1024 + networks: + magento: + aliases: + - web.magento2.docker + depends_on: + fpm: + condition: service_started + tls: + hostname: tls.magento2.docker + image: 'magento/magento-cloud-docker-nginx:1.19-1.2.0' + extends: generic + networks: + magento: + aliases: + - magento2.docker + environment: + - NGINX_WORKER_PROCESSES=1 + - NGINX_WORKER_CONNECTIONS=1024 + - UPSTREAM_HOST=web + - UPSTREAM_PORT=8080 + ports: + - '80:80' + - '443:443' + depends_on: + web: + condition: service_started + generic: + hostname: generic.magento2.docker + image: 'magento/magento-cloud-docker-php:7.3-cli-1.2.0' + env_file: ./.docker/config.env + environment: + - 'PHP_EXTENSIONS=bcmath bz2 calendar exif gd gettext intl mysqli pcntl pdo_mysql soap sockets sysvmsg sysvsem sysvshm opcache zip redis xsl sodium' + build: + hostname: build.magento2.docker + image: 'magento/magento-cloud-docker-php:7.3-cli-1.2.0' + extends: generic + volumes: + - '.:/app:rw,delegated' + - 'magento-vendor:/app/vendor:rw,delegated' + - 'magento-generated:/app/generated:rw,delegated' + - '~/.composer/cache:/root/.composer/cache:rw,delegated' + networks: + magento-build: + aliases: + - build.magento2.docker + depends_on: + db: + condition: service_healthy + redis: + condition: service_healthy + elasticsearch: + condition: service_healthy + deploy: + hostname: deploy.magento2.docker + image: 'magento/magento-cloud-docker-php:7.3-cli-1.2.0' + extends: generic + volumes: + - '.:/app:ro,delegated' + - 'magento-vendor:/app/vendor:ro,delegated' + - 'magento-generated:/app/generated:ro,delegated' + - 'magento-var:/app/var:rw,delegated' + - 'magento-app-etc:/app/app/etc:rw,delegated' + - 'magento-pub-media:/app/pub/media:rw,delegated' + - 'magento-pub-static:/app/pub/static:rw,delegated' + - '.docker/mnt:/mnt:rw,delegated' + networks: + magento: + aliases: + - deploy.magento2.docker + depends_on: + db: + condition: service_healthy + redis: + condition: service_healthy + elasticsearch: + condition: service_healthy + mailhog: + hostname: mailhog.magento2.docker + image: 'mailhog/mailhog:latest' + ports: + - '1025:1025' + - '8025:8025' + networks: + magento: + aliases: + - mailhog.magento2.docker +volumes: + magento-vendor: { } + magento-generated: { } + magento-var: { } + magento-app-etc: { } + magento-pub-media: { } + magento-pub-static: { } + mymagento-magento-db: { } +networks: + magento: + driver: bridge + magento-build: + driver: bridge diff --git a/src/Test/Integration/_files/custom_cloud_base/docker-compose.exp.yml b/src/Test/Integration/_files/custom_cloud_base/docker-compose.exp.yml index cf72b33c..fcc5ca72 100644 --- a/src/Test/Integration/_files/custom_cloud_base/docker-compose.exp.yml +++ b/src/Test/Integration/_files/custom_cloud_base/docker-compose.exp.yml @@ -58,6 +58,8 @@ services: - '.docker/mnt:/mnt:rw,delegated' environment: - WITH_XDEBUG=0 + - NGINX_WORKER_PROCESSES=1 + - NGINX_WORKER_CONNECTIONS=1024 networks: magento: aliases: @@ -84,6 +86,8 @@ services: aliases: - magento2.test environment: + - NGINX_WORKER_PROCESSES=1 + - NGINX_WORKER_CONNECTIONS=1024 - UPSTREAM_HOST=varnish - UPSTREAM_PORT=80 ports: diff --git a/src/Test/Integration/_files/custom_cloud_custom_images/docker-compose.exp.yml b/src/Test/Integration/_files/custom_cloud_custom_images/docker-compose.exp.yml index 04e3ca4d..f6857432 100644 --- a/src/Test/Integration/_files/custom_cloud_custom_images/docker-compose.exp.yml +++ b/src/Test/Integration/_files/custom_cloud_custom_images/docker-compose.exp.yml @@ -83,6 +83,8 @@ services: - '.docker/mnt:/mnt:rw,delegated' environment: - WITH_XDEBUG=0 + - NGINX_WORKER_PROCESSES=auto + - NGINX_WORKER_CONNECTIONS=4096 networks: magento: aliases: @@ -109,6 +111,8 @@ services: aliases: - magento2.test environment: + - NGINX_WORKER_PROCESSES=auto + - NGINX_WORKER_CONNECTIONS=4096 - UPSTREAM_HOST=varnish - UPSTREAM_PORT=80 ports: diff --git a/src/Test/Integration/_files/custom_cloud_no_tls_service/.docker/.gitignore b/src/Test/Integration/_files/custom_cloud_no_tls_service/.docker/.gitignore new file mode 100644 index 00000000..e69de29b diff --git a/src/Test/Integration/_files/custom_cloud_no_tls_service/.docker/config.php.dist b/src/Test/Integration/_files/custom_cloud_no_tls_service/.docker/config.php.dist new file mode 100644 index 00000000..f39acf1e --- /dev/null +++ b/src/Test/Integration/_files/custom_cloud_no_tls_service/.docker/config.php.dist @@ -0,0 +1,35 @@ + base64_encode(json_encode([ + 'database' => [ + [ + 'host' => 'db', + 'path' => 'magento2', + 'password' => 'magento2', + 'username' => 'magento2', + 'port' => '3306' + ] + ] + ])), + 'MAGENTO_CLOUD_ROUTES' => base64_encode(json_encode([ + 'http://magento2.docker/' => [ + 'type' => 'upstream', + 'original_url' => 'http://{default}' + ], + 'https://magento2.docker/' => [ + 'type' => 'upstream', + 'original_url' => 'https://{default}' + ] + ])), + 'MAGENTO_CLOUD_VARIABLES' => base64_encode(json_encode([ + 'ADMIN_EMAIL' => 'admin@example.com', + 'ADMIN_PASSWORD' => '123123q', + 'ADMIN_URL' => 'admin' + ])), + 'MAGENTO_CLOUD_APPLICATION' => base64_encode(json_encode([ + 'hooks' => [ + + ] + ])), +]; diff --git a/src/Test/Integration/_files/custom_cloud_no_tls_service/composer.json b/src/Test/Integration/_files/custom_cloud_no_tls_service/composer.json new file mode 100644 index 00000000..6ed415ed --- /dev/null +++ b/src/Test/Integration/_files/custom_cloud_no_tls_service/composer.json @@ -0,0 +1,6 @@ +{ + "name": "magento/project-enterprise-edition", + "description": "Composer file for integration tests", + "type": "project", + "version": "2.2.0" +} diff --git a/src/Test/Integration/_files/custom_cloud_no_tls_service/docker-compose.exp.yml b/src/Test/Integration/_files/custom_cloud_no_tls_service/docker-compose.exp.yml new file mode 100644 index 00000000..fd79d881 --- /dev/null +++ b/src/Test/Integration/_files/custom_cloud_no_tls_service/docker-compose.exp.yml @@ -0,0 +1,119 @@ +version: '2.1' +services: + db: + hostname: db.magento2.docker + image: 'mariadb:10.0' + environment: + - MYSQL_ROOT_PASSWORD=magento2 + - MYSQL_DATABASE=magento2 + - MYSQL_USER=magento2 + - MYSQL_PASSWORD=magento2 + ports: + - '3306' + volumes: + - '.docker/mnt:/mnt:rw,delegated' + - 'magento-magento-db:/var/lib/mysql' + healthcheck: + test: 'mysqladmin ping -h localhost -pmagento2' + interval: 30s + timeout: 30s + retries: 3 + networks: + magento: + aliases: + - db.magento2.docker + fpm: + hostname: fpm.magento2.docker + image: 'magento/magento-cloud-docker-php:7.2-fpm-1.2.0' + extends: generic + volumes: + - '.:/app:ro,delegated' + - 'magento-vendor:/app/vendor:ro,delegated' + - 'magento-generated:/app/generated:ro,delegated' + - '.docker/mnt:/mnt:rw,delegated' + networks: + magento: + aliases: + - fpm.magento2.docker + depends_on: + db: + condition: service_healthy + web: + hostname: web.magento2.docker + image: 'magento/magento-cloud-docker-nginx:1.19-1.2.0' + extends: generic + volumes: + - '.:/app:ro,delegated' + - 'magento-vendor:/app/vendor:ro,delegated' + - 'magento-generated:/app/generated:ro,delegated' + - '.docker/mnt:/mnt:rw,delegated' + environment: + - WITH_XDEBUG=0 + - NGINX_WORKER_PROCESSES=4 + - NGINX_WORKER_CONNECTIONS=2048 + networks: + magento: + aliases: + - web.magento2.docker + depends_on: + fpm: + condition: service_started + varnish: + hostname: varnish.magento2.docker + image: 'magento/magento-cloud-docker-varnish:6.2-1.2.0' + ports: + - '80:80' + networks: + magento: + aliases: + - magento2.docker + depends_on: + web: + condition: service_started + generic: + hostname: generic.magento2.docker + image: 'magento/magento-cloud-docker-php:7.2-cli-1.2.0' + env_file: ./.docker/config.env + environment: + - 'PHP_EXTENSIONS=bcmath bz2 calendar exif gd gettext intl mysqli pcntl pdo_mysql soap sockets sysvmsg sysvsem sysvshm opcache zip' + build: + hostname: build.magento2.docker + image: 'magento/magento-cloud-docker-php:7.2-cli-1.2.0' + extends: generic + volumes: + - '.:/app:rw,delegated' + - 'magento-vendor:/app/vendor:rw,delegated' + - 'magento-generated:/app/generated:rw,delegated' + - '~/.composer/cache:/root/.composer/cache:rw,delegated' + networks: + magento-build: + aliases: + - build.magento2.docker + depends_on: + db: + condition: service_healthy + deploy: + hostname: deploy.magento2.docker + image: 'magento/magento-cloud-docker-php:7.2-cli-1.2.0' + extends: generic + volumes: + - '.:/app:ro,delegated' + - 'magento-vendor:/app/vendor:ro,delegated' + - 'magento-generated:/app/generated:ro,delegated' + - '.docker/mnt:/mnt:rw,delegated' + networks: + magento: + aliases: + - deploy.magento2.docker + depends_on: + db: + condition: service_healthy +volumes: + magento-vendor: { } + magento-generated: { } + magento-magento-db: { } +networks: + magento: + driver: bridge + magento-build: + driver: bridge diff --git a/src/Test/Integration/_files/custom_cloud_no_varnish_and_tls_services/.docker/.gitignore b/src/Test/Integration/_files/custom_cloud_no_varnish_and_tls_services/.docker/.gitignore new file mode 100644 index 00000000..e69de29b diff --git a/src/Test/Integration/_files/custom_cloud_no_varnish_and_tls_services/.docker/config.php.dist b/src/Test/Integration/_files/custom_cloud_no_varnish_and_tls_services/.docker/config.php.dist new file mode 100644 index 00000000..f39acf1e --- /dev/null +++ b/src/Test/Integration/_files/custom_cloud_no_varnish_and_tls_services/.docker/config.php.dist @@ -0,0 +1,35 @@ + base64_encode(json_encode([ + 'database' => [ + [ + 'host' => 'db', + 'path' => 'magento2', + 'password' => 'magento2', + 'username' => 'magento2', + 'port' => '3306' + ] + ] + ])), + 'MAGENTO_CLOUD_ROUTES' => base64_encode(json_encode([ + 'http://magento2.docker/' => [ + 'type' => 'upstream', + 'original_url' => 'http://{default}' + ], + 'https://magento2.docker/' => [ + 'type' => 'upstream', + 'original_url' => 'https://{default}' + ] + ])), + 'MAGENTO_CLOUD_VARIABLES' => base64_encode(json_encode([ + 'ADMIN_EMAIL' => 'admin@example.com', + 'ADMIN_PASSWORD' => '123123q', + 'ADMIN_URL' => 'admin' + ])), + 'MAGENTO_CLOUD_APPLICATION' => base64_encode(json_encode([ + 'hooks' => [ + + ] + ])), +]; diff --git a/src/Test/Integration/_files/custom_cloud_no_varnish_and_tls_services/composer.json b/src/Test/Integration/_files/custom_cloud_no_varnish_and_tls_services/composer.json new file mode 100644 index 00000000..6ed415ed --- /dev/null +++ b/src/Test/Integration/_files/custom_cloud_no_varnish_and_tls_services/composer.json @@ -0,0 +1,6 @@ +{ + "name": "magento/project-enterprise-edition", + "description": "Composer file for integration tests", + "type": "project", + "version": "2.2.0" +} diff --git a/src/Test/Integration/_files/custom_cloud_no_varnish_and_tls_services/docker-compose.exp.yml b/src/Test/Integration/_files/custom_cloud_no_varnish_and_tls_services/docker-compose.exp.yml new file mode 100644 index 00000000..624058f5 --- /dev/null +++ b/src/Test/Integration/_files/custom_cloud_no_varnish_and_tls_services/docker-compose.exp.yml @@ -0,0 +1,109 @@ +version: '2.1' +services: + db: + hostname: db.magento2.docker + image: 'mariadb:10.0' + environment: + - MYSQL_ROOT_PASSWORD=magento2 + - MYSQL_DATABASE=magento2 + - MYSQL_USER=magento2 + - MYSQL_PASSWORD=magento2 + ports: + - '3306' + volumes: + - '.docker/mnt:/mnt:rw,delegated' + - 'magento-magento-db:/var/lib/mysql' + healthcheck: + test: 'mysqladmin ping -h localhost -pmagento2' + interval: 30s + timeout: 30s + retries: 3 + networks: + magento: + aliases: + - db.magento2.docker + fpm: + hostname: fpm.magento2.docker + image: 'magento/magento-cloud-docker-php:7.2-fpm-1.2.0' + extends: generic + volumes: + - '.:/app:ro,delegated' + - 'magento-vendor:/app/vendor:ro,delegated' + - 'magento-generated:/app/generated:ro,delegated' + - '.docker/mnt:/mnt:rw,delegated' + networks: + magento: + aliases: + - fpm.magento2.docker + depends_on: + db: + condition: service_healthy + web: + hostname: web.magento2.docker + image: 'magento/magento-cloud-docker-nginx:1.19-1.2.0' + extends: generic + volumes: + - '.:/app:ro,delegated' + - 'magento-vendor:/app/vendor:ro,delegated' + - 'magento-generated:/app/generated:ro,delegated' + - '.docker/mnt:/mnt:rw,delegated' + environment: + - WITH_XDEBUG=0 + - NGINX_WORKER_PROCESSES=1 + - NGINX_WORKER_CONNECTIONS=1024 + ports: + - '80:8080' + networks: + magento: + aliases: + - magento2.docker + depends_on: + fpm: + condition: service_started + generic: + hostname: generic.magento2.docker + image: 'magento/magento-cloud-docker-php:7.2-cli-1.2.0' + env_file: ./.docker/config.env + environment: + - 'PHP_EXTENSIONS=bcmath bz2 calendar exif gd gettext intl mysqli pcntl pdo_mysql soap sockets sysvmsg sysvsem sysvshm opcache zip' + build: + hostname: build.magento2.docker + image: 'magento/magento-cloud-docker-php:7.2-cli-1.2.0' + extends: generic + volumes: + - '.:/app:rw,delegated' + - 'magento-vendor:/app/vendor:rw,delegated' + - 'magento-generated:/app/generated:rw,delegated' + - '~/.composer/cache:/root/.composer/cache:rw,delegated' + networks: + magento-build: + aliases: + - build.magento2.docker + depends_on: + db: + condition: service_healthy + deploy: + hostname: deploy.magento2.docker + image: 'magento/magento-cloud-docker-php:7.2-cli-1.2.0' + extends: generic + volumes: + - '.:/app:ro,delegated' + - 'magento-vendor:/app/vendor:ro,delegated' + - 'magento-generated:/app/generated:ro,delegated' + - '.docker/mnt:/mnt:rw,delegated' + networks: + magento: + aliases: + - deploy.magento2.docker + depends_on: + db: + condition: service_healthy +volumes: + magento-vendor: { } + magento-generated: { } + magento-magento-db: { } +networks: + magento: + driver: bridge + magento-build: + driver: bridge diff --git a/src/Test/Integration/_files/custom_cloud_no_varnish_service/.docker/.gitignore b/src/Test/Integration/_files/custom_cloud_no_varnish_service/.docker/.gitignore new file mode 100644 index 00000000..e69de29b diff --git a/src/Test/Integration/_files/custom_cloud_no_varnish_service/.docker/config.php.dist b/src/Test/Integration/_files/custom_cloud_no_varnish_service/.docker/config.php.dist new file mode 100644 index 00000000..f39acf1e --- /dev/null +++ b/src/Test/Integration/_files/custom_cloud_no_varnish_service/.docker/config.php.dist @@ -0,0 +1,35 @@ + base64_encode(json_encode([ + 'database' => [ + [ + 'host' => 'db', + 'path' => 'magento2', + 'password' => 'magento2', + 'username' => 'magento2', + 'port' => '3306' + ] + ] + ])), + 'MAGENTO_CLOUD_ROUTES' => base64_encode(json_encode([ + 'http://magento2.docker/' => [ + 'type' => 'upstream', + 'original_url' => 'http://{default}' + ], + 'https://magento2.docker/' => [ + 'type' => 'upstream', + 'original_url' => 'https://{default}' + ] + ])), + 'MAGENTO_CLOUD_VARIABLES' => base64_encode(json_encode([ + 'ADMIN_EMAIL' => 'admin@example.com', + 'ADMIN_PASSWORD' => '123123q', + 'ADMIN_URL' => 'admin' + ])), + 'MAGENTO_CLOUD_APPLICATION' => base64_encode(json_encode([ + 'hooks' => [ + + ] + ])), +]; diff --git a/src/Test/Integration/_files/custom_cloud_no_varnish_service/composer.json b/src/Test/Integration/_files/custom_cloud_no_varnish_service/composer.json new file mode 100644 index 00000000..6ed415ed --- /dev/null +++ b/src/Test/Integration/_files/custom_cloud_no_varnish_service/composer.json @@ -0,0 +1,6 @@ +{ + "name": "magento/project-enterprise-edition", + "description": "Composer file for integration tests", + "type": "project", + "version": "2.2.0" +} diff --git a/src/Test/Integration/_files/custom_cloud_no_varnish_service/docker-compose.exp.yml b/src/Test/Integration/_files/custom_cloud_no_varnish_service/docker-compose.exp.yml new file mode 100644 index 00000000..51499d68 --- /dev/null +++ b/src/Test/Integration/_files/custom_cloud_no_varnish_service/docker-compose.exp.yml @@ -0,0 +1,126 @@ +version: '2.1' +services: + db: + hostname: db.magento2.docker + image: 'mariadb:10.0' + environment: + - MYSQL_ROOT_PASSWORD=magento2 + - MYSQL_DATABASE=magento2 + - MYSQL_USER=magento2 + - MYSQL_PASSWORD=magento2 + ports: + - '3306' + volumes: + - '.docker/mnt:/mnt:rw,delegated' + - 'magento-magento-db:/var/lib/mysql' + healthcheck: + test: 'mysqladmin ping -h localhost -pmagento2' + interval: 30s + timeout: 30s + retries: 3 + networks: + magento: + aliases: + - db.magento2.docker + fpm: + hostname: fpm.magento2.docker + image: 'magento/magento-cloud-docker-php:7.2-fpm-1.2.0' + extends: generic + volumes: + - '.:/app:ro,delegated' + - 'magento-vendor:/app/vendor:ro,delegated' + - 'magento-generated:/app/generated:ro,delegated' + - '.docker/mnt:/mnt:rw,delegated' + networks: + magento: + aliases: + - fpm.magento2.docker + depends_on: + db: + condition: service_healthy + web: + hostname: web.magento2.docker + image: 'magento/magento-cloud-docker-nginx:1.19-1.2.0' + extends: generic + volumes: + - '.:/app:ro,delegated' + - 'magento-vendor:/app/vendor:ro,delegated' + - 'magento-generated:/app/generated:ro,delegated' + - '.docker/mnt:/mnt:rw,delegated' + environment: + - WITH_XDEBUG=0 + - NGINX_WORKER_PROCESSES=1 + - NGINX_WORKER_CONNECTIONS=1024 + networks: + magento: + aliases: + - web.magento2.docker + depends_on: + fpm: + condition: service_started + tls: + hostname: tls.magento2.docker + image: 'magento/magento-cloud-docker-nginx:1.19-1.2.0' + extends: generic + networks: + magento: + aliases: + - magento2.docker + environment: + - NGINX_WORKER_PROCESSES=1 + - NGINX_WORKER_CONNECTIONS=1024 + - UPSTREAM_HOST=web + - UPSTREAM_PORT=8080 + ports: + - '80:80' + - '443:443' + depends_on: + web: + condition: service_started + generic: + hostname: generic.magento2.docker + image: 'magento/magento-cloud-docker-php:7.2-cli-1.2.0' + env_file: ./.docker/config.env + environment: + - 'PHP_EXTENSIONS=bcmath bz2 calendar exif gd gettext intl mysqli pcntl pdo_mysql soap sockets sysvmsg sysvsem sysvshm opcache zip' + build: + hostname: build.magento2.docker + image: 'magento/magento-cloud-docker-php:7.2-cli-1.2.0' + extends: generic + volumes: + - '.:/app:rw,delegated' + - 'magento-vendor:/app/vendor:rw,delegated' + - 'magento-generated:/app/generated:rw,delegated' + - '~/.composer/cache:/root/.composer/cache:rw,delegated' + networks: + magento-build: + aliases: + - build.magento2.docker + depends_on: + db: + condition: service_healthy + deploy: + hostname: deploy.magento2.docker + image: 'magento/magento-cloud-docker-php:7.2-cli-1.2.0' + extends: generic + volumes: + - '.:/app:ro,delegated' + - 'magento-vendor:/app/vendor:ro,delegated' + - 'magento-generated:/app/generated:ro,delegated' + - '.docker/mnt:/mnt:rw,delegated' + networks: + magento: + aliases: + - deploy.magento2.docker + depends_on: + db: + condition: service_healthy +volumes: + magento-vendor: { } + magento-generated: { } + magento-magento-db: { } +networks: + magento: + driver: bridge + magento-build: + driver: bridge From e5f35e031fd1cc63ee463d03c55e2c098ff5ea69 Mon Sep 17 00:00:00 2001 From: Bohdan Korablov Date: Wed, 16 Dec 2020 15:47:58 -0600 Subject: [PATCH 15/17] MCLOUD-6907: Added generated_images_namespace configuration (#20) --- codeception.dist.yml | 1 + tests/functional/Codeception/TestInfrastructure.php | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/codeception.dist.yml b/codeception.dist.yml index bd0c532c..36321360 100644 --- a/codeception.dist.yml +++ b/codeception.dist.yml @@ -26,6 +26,7 @@ modules: composer_magento_password: "%REPO_PASSWORD%" composer_github_token: "%GITHUB_TOKEN%" use_generated_images: false + generated_images_namespace: "cloudft" use_cached_workdir: true version_generated_images: "%TRAVIS_BUILD_NUMBER%" printOutput: false diff --git a/tests/functional/Codeception/TestInfrastructure.php b/tests/functional/Codeception/TestInfrastructure.php index 430141ce..ed6c2bf1 100644 --- a/tests/functional/Codeception/TestInfrastructure.php +++ b/tests/functional/Codeception/TestInfrastructure.php @@ -495,7 +495,11 @@ public function replaceImagesWithGenerated(): bool $path, preg_replace( '/(magento\/magento-cloud-docker-(\w+)):((\d+\.\d+|latest)(-fpm|-cli)?(-\d+\.\d+\.\d+))/i', - 'cloudft/$2:$4$5-' . $this->_getConfig('version_generated_images'), + sprintf( + '%s/$2:$4$5-%s', + $this->_getConfig('generated_images_namespace'), + $this->_getConfig('version_generated_images') + ), file_get_contents($path) ) ); From 5b29286d88fa53176c35f5e9bfd3ab34c87bbb2d Mon Sep 17 00:00:00 2001 From: Igor Vitol Date: Thu, 17 Dec 2020 01:40:42 +0200 Subject: [PATCH 16/17] Disabling blackfire by default. Will be enabled automatically in compose when added to .magento.app.yaml config --- src/Command/BuildCompose.php | 5 ----- src/Compose/Php/ExtensionResolver.php | 3 +-- src/Config/Source/CliSource.php | 7 ------- src/Test/Integration/BuildComposeTest.php | 2 -- .../Integration/_files/cloud_base/docker-compose.exp.yml | 2 +- .../_files/custom_cloud_base/docker-compose.exp.yml | 2 +- .../custom_cloud_custom_images/docker-compose.exp.yml | 2 +- 7 files changed, 4 insertions(+), 19 deletions(-) diff --git a/src/Command/BuildCompose.php b/src/Command/BuildCompose.php index cf58b648..79e2d849 100644 --- a/src/Command/BuildCompose.php +++ b/src/Command/BuildCompose.php @@ -252,11 +252,6 @@ protected function configure(): void null, InputOption::VALUE_NONE, 'Enables XDebug' - )->addOption( - Source\CliSource::OPTION_WITHOUT_BLACKFIRE, - null, - InputOption::VALUE_NONE, - 'Do not load blackfire php extension by default' )->addOption( Source\CliSource::OPTION_ENV_VARIABLES, null, diff --git a/src/Compose/Php/ExtensionResolver.php b/src/Compose/Php/ExtensionResolver.php index 7dd587d5..dcdfd5fb 100644 --- a/src/Compose/Php/ExtensionResolver.php +++ b/src/Compose/Php/ExtensionResolver.php @@ -46,8 +46,7 @@ class ExtensionResolver 'sysvsem', 'sysvshm', 'opcache', - 'zip', - 'blackfire' + 'zip' ]; /** diff --git a/src/Config/Source/CliSource.php b/src/Config/Source/CliSource.php index 9aad2998..09dfbfba 100644 --- a/src/Config/Source/CliSource.php +++ b/src/Config/Source/CliSource.php @@ -53,7 +53,6 @@ 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_WITHOUT_BLACKFIRE = 'without-blackfire'; 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'; @@ -145,7 +144,6 @@ public function __construct(InputInterface $input) public function read(): Repository { $repository = new Repository(); - $disabledExtensions = []; if ($mode = $this->input->getOption(self::OPTION_MODE)) { $repository->set([ @@ -240,10 +238,6 @@ public function read(): Repository ]); } - if ($this->input->getOption(self::OPTION_WITHOUT_BLACKFIRE)) { - $disabledExtensions['blackfire'] = 'blackfire'; - } - if ($this->input->getOption(self::OPTION_SET_DOCKER_HOST_XDEBUG)) { $repository->set(self::SYSTEM_SET_DOCKER_HOST, true); } @@ -316,7 +310,6 @@ public function read(): Repository $repository->set(self::SYSTEM_NGINX_WORKER_CONNECTIONS, $nginxWorkerConnections); } - $repository->set(self::PHP_DISABLED_EXTENSIONS, $disabledExtensions); return $repository; } } diff --git a/src/Test/Integration/BuildComposeTest.php b/src/Test/Integration/BuildComposeTest.php index 562dde85..eafed492 100644 --- a/src/Test/Integration/BuildComposeTest.php +++ b/src/Test/Integration/BuildComposeTest.php @@ -87,7 +87,6 @@ public function buildDataProvider(): array [CliSource::OPTION_WITH_TEST, true], [CliSource::OPTION_WITH_CRON, true], [CliSource::OPTION_WITH_XDEBUG, true], - [CliSource::OPTION_WITHOUT_BLACKFIRE, true], [CliSource::OPTION_ES, '5.2'], [CliSource::OPTION_NO_ES, true], [CliSource::OPTION_DB_INCREMENT_INCREMENT, 3], @@ -107,7 +106,6 @@ public function buildDataProvider(): array [CliSource::OPTION_WITH_TEST, true], [CliSource::OPTION_WITH_CRON, true], [CliSource::OPTION_WITH_XDEBUG, true], - [CliSource::OPTION_WITHOUT_BLACKFIRE, true], [CliSource::OPTION_ES, '5.2'], [CliSource::OPTION_NO_ES, true], [CliSource::OPTION_DB_INCREMENT_INCREMENT, 3], diff --git a/src/Test/Integration/_files/cloud_base/docker-compose.exp.yml b/src/Test/Integration/_files/cloud_base/docker-compose.exp.yml index 9b998519..746a88b7 100644 --- a/src/Test/Integration/_files/cloud_base/docker-compose.exp.yml +++ b/src/Test/Integration/_files/cloud_base/docker-compose.exp.yml @@ -127,7 +127,7 @@ services: image: 'magento/magento-cloud-docker-php:7.3-cli-1.2.0' env_file: ./.docker/config.env environment: - - 'PHP_EXTENSIONS=bcmath bz2 calendar exif gd gettext intl mysqli pcntl pdo_mysql soap sockets sysvmsg sysvsem sysvshm opcache zip blackfire 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' build: hostname: build.magento2.docker image: 'magento/magento-cloud-docker-php:7.3-cli-1.2.0' diff --git a/src/Test/Integration/_files/custom_cloud_base/docker-compose.exp.yml b/src/Test/Integration/_files/custom_cloud_base/docker-compose.exp.yml index ca58ae01..fcc5ca72 100644 --- a/src/Test/Integration/_files/custom_cloud_base/docker-compose.exp.yml +++ b/src/Test/Integration/_files/custom_cloud_base/docker-compose.exp.yml @@ -101,7 +101,7 @@ services: image: 'magento/magento-cloud-docker-php:7.2-cli-1.2.0' env_file: ./.docker/config.env environment: - - 'PHP_EXTENSIONS=bcmath bz2 calendar exif gd gettext intl mysqli pcntl pdo_mysql soap sockets sysvmsg sysvsem sysvshm opcache zip blackfire xsl' + - 'PHP_EXTENSIONS=bcmath bz2 calendar exif gd gettext intl mysqli pcntl pdo_mysql soap sockets sysvmsg sysvsem sysvshm opcache zip xsl' build: hostname: build.magento2.test image: 'magento/magento-cloud-docker-php:7.2-cli-1.2.0' diff --git a/src/Test/Integration/_files/custom_cloud_custom_images/docker-compose.exp.yml b/src/Test/Integration/_files/custom_cloud_custom_images/docker-compose.exp.yml index e83be9d2..f6857432 100644 --- a/src/Test/Integration/_files/custom_cloud_custom_images/docker-compose.exp.yml +++ b/src/Test/Integration/_files/custom_cloud_custom_images/docker-compose.exp.yml @@ -152,7 +152,7 @@ services: image: 'php-v1:7.4-cli' env_file: ./.docker/config.env environment: - - 'PHP_EXTENSIONS=bcmath bz2 calendar exif gd gettext intl mysqli pcntl pdo_mysql soap sockets sysvmsg sysvsem sysvshm opcache zip blackfire xsl' + - 'PHP_EXTENSIONS=bcmath bz2 calendar exif gd gettext intl mysqli pcntl pdo_mysql soap sockets sysvmsg sysvsem sysvshm opcache zip xsl' build: hostname: build.magento2.test image: 'php-v1:7.4-cli' From 22fcd623dd4609eabc929df213d69472fbde3681 Mon Sep 17 00:00:00 2001 From: Oleksandr Shmyheliuk Date: Thu, 17 Dec 2020 11:29:33 -0600 Subject: [PATCH 17/17] MCLOUD-7442: Invalid volume name (#19) --- src/Compose/BuilderInterface.php | 6 +- src/Compose/DeveloperBuilder.php | 13 +- .../ProductionBuilder/Service/Database/Db.php | 2 +- .../Service/Database/DbQuote.php | 2 +- .../Service/Database/DbSales.php | 2 +- src/Test/Integration/BuildComposeTest.php | 8 + .../cloud_base_developer/.docker/.gitignore | 0 .../.docker/config.php.dist | 47 +++++ .../cloud_base_developer/.magento.app.yaml | 29 +++ .../.magento/services.yaml | 14 ++ .../_files/cloud_base_developer/composer.json | 6 + .../docker-compose.exp.yml | 168 ++++++++++++++++++ 12 files changed, 280 insertions(+), 17 deletions(-) create mode 100644 src/Test/Integration/_files/cloud_base_developer/.docker/.gitignore create mode 100644 src/Test/Integration/_files/cloud_base_developer/.docker/config.php.dist create mode 100644 src/Test/Integration/_files/cloud_base_developer/.magento.app.yaml create mode 100644 src/Test/Integration/_files/cloud_base_developer/.magento/services.yaml create mode 100644 src/Test/Integration/_files/cloud_base_developer/composer.json create mode 100644 src/Test/Integration/_files/cloud_base_developer/docker-compose.exp.yml diff --git a/src/Compose/BuilderInterface.php b/src/Compose/BuilderInterface.php index ff8218ad..cd62b189 100644 --- a/src/Compose/BuilderInterface.php +++ b/src/Compose/BuilderInterface.php @@ -48,9 +48,9 @@ interface BuilderInterface public const VOLUME_MAGENTO_DB_QUOTE = 'magento-db-quote'; public const VOLUME_MAGENTO_DB_SALES = 'magento-db-sales'; public const VOLUME_MAGENTO_DEV = './dev'; - public const VOLUME_DOCKER_ETRYPOINT = '.docker/mysql/docker-entrypoint-initdb.d'; - public const VOLUME_DOCKER_ETRYPOINT_QUOTE = '.docker/mysql-quote/docker-entrypoint-initdb.d'; - public const VOLUME_DOCKER_ETRYPOINT_SALES = '.docker/mysql-sales/docker-entrypoint-initdb.d'; + public const VOLUME_DOCKER_ENTRYPOINT = '.docker/mysql/docker-entrypoint-initdb.d'; + public const VOLUME_DOCKER_ENTRYPOINT_QUOTE = '.docker/mysql-quote/docker-entrypoint-initdb.d'; + public const VOLUME_DOCKER_ENTRYPOINT_SALES = '.docker/mysql-sales/docker-entrypoint-initdb.d'; public const SYNC_ENGINE_NATIVE = 'native'; diff --git a/src/Compose/DeveloperBuilder.php b/src/Compose/DeveloperBuilder.php index 678a57d5..32b773ec 100644 --- a/src/Compose/DeveloperBuilder.php +++ b/src/Compose/DeveloperBuilder.php @@ -7,7 +7,6 @@ namespace Magento\CloudDocker\Compose; -use Magento\CloudDocker\App\ConfigurationMismatchException; use Magento\CloudDocker\Compose\Php\ExtensionResolver; use Magento\CloudDocker\Config\Config; use Magento\CloudDocker\Config\Environment\Converter; @@ -97,14 +96,6 @@ public function build(Config $config): Manager $volumes = [$volumePrefix . self::VOLUME_MAGENTO_SYNC . ':' . self::DIR_MAGENTO . ':nocopy']; } - if ($config->hasMariaDbConf()) { - $volumesList[$volumePrefix . self::VOLUME_MARIADB_CONF] = []; - } - - if ($config->hasDbEntrypoint()) { - $volumesList[self::VOLUME_DOCKER_ETRYPOINT] = []; - } - $manager->setVolumes($volumesList); /** @@ -129,11 +120,11 @@ public function build(Config $config): Manager ]; if ($config->hasMariaDbConf()) { - $dbVolumes[] = $volumePrefix . self::VOLUME_MARIADB_CONF . ':/etc/mysql/mariadb.conf.d'; + $dbVolumes[] = self::VOLUME_MARIADB_CONF . ':/etc/mysql/mariadb.conf.d'; } if ($config->hasDbEntrypoint()) { - $dbVolumes[] = self::VOLUME_DOCKER_ETRYPOINT . ':/docker-entrypoint-initdb.d'; + $dbVolumes[] = self::VOLUME_DOCKER_ENTRYPOINT . ':/docker-entrypoint-initdb.d'; } $manager->updateService(self::SERVICE_DB, [ diff --git a/src/Compose/ProductionBuilder/Service/Database/Db.php b/src/Compose/ProductionBuilder/Service/Database/Db.php index 9a06cf18..30e9c8bc 100644 --- a/src/Compose/ProductionBuilder/Service/Database/Db.php +++ b/src/Compose/ProductionBuilder/Service/Database/Db.php @@ -118,7 +118,7 @@ private function getMounts(Config $config): array $mounts[] = $config->getNameWithPrefix() . BuilderInterface::VOLUME_MAGENTO_DB . ':/var/lib/mysql'; if ($config->hasDbEntrypoint()) { - $mounts[] = BuilderInterface::VOLUME_DOCKER_ETRYPOINT . ':/docker-entrypoint-initdb.d'; + $mounts[] = BuilderInterface::VOLUME_DOCKER_ENTRYPOINT . ':/docker-entrypoint-initdb.d'; } return $mounts; diff --git a/src/Compose/ProductionBuilder/Service/Database/DbQuote.php b/src/Compose/ProductionBuilder/Service/Database/DbQuote.php index 71269b9e..2fd77965 100644 --- a/src/Compose/ProductionBuilder/Service/Database/DbQuote.php +++ b/src/Compose/ProductionBuilder/Service/Database/DbQuote.php @@ -113,7 +113,7 @@ private function getMounts(Config $config): array } $mounts[] = BuilderInterface::VOLUME_MAGENTO_DB_QUOTE . ':/var/lib/mysql'; - $mounts[] = BuilderInterface::VOLUME_DOCKER_ETRYPOINT_QUOTE . ':/docker-entrypoint-initdb.d'; + $mounts[] = BuilderInterface::VOLUME_DOCKER_ENTRYPOINT_QUOTE . ':/docker-entrypoint-initdb.d'; return $mounts; } diff --git a/src/Compose/ProductionBuilder/Service/Database/DbSales.php b/src/Compose/ProductionBuilder/Service/Database/DbSales.php index f99fbc67..addee21a 100644 --- a/src/Compose/ProductionBuilder/Service/Database/DbSales.php +++ b/src/Compose/ProductionBuilder/Service/Database/DbSales.php @@ -113,7 +113,7 @@ private function getMounts(Config $config): array } $mounts[] = BuilderInterface::VOLUME_MAGENTO_DB_SALES . ':/var/lib/mysql'; - $mounts[] = BuilderInterface::VOLUME_DOCKER_ETRYPOINT_SALES . ':/docker-entrypoint-initdb.d'; + $mounts[] = BuilderInterface::VOLUME_DOCKER_ENTRYPOINT_SALES . ':/docker-entrypoint-initdb.d'; return $mounts; } diff --git a/src/Test/Integration/BuildComposeTest.php b/src/Test/Integration/BuildComposeTest.php index eafed492..f2f6bc34 100644 --- a/src/Test/Integration/BuildComposeTest.php +++ b/src/Test/Integration/BuildComposeTest.php @@ -79,6 +79,14 @@ public function buildDataProvider(): array [CliSource::OPTION_WITH_MARIADB_CONF, true] ] ], + 'cloud-base-developer' => [ + __DIR__ . '/_files/cloud_base_developer', + [ + [CliSource::OPTION_MODE, BuilderFactory::BUILDER_DEVELOPER], + [CliSource::OPTION_WITH_ENTRYPOINT, true], + [CliSource::OPTION_WITH_MARIADB_CONF, true] + ] + ], 'cloud-base-mftf' => [ __DIR__ . '/_files/cloud_base_mftf', [ diff --git a/src/Test/Integration/_files/cloud_base_developer/.docker/.gitignore b/src/Test/Integration/_files/cloud_base_developer/.docker/.gitignore new file mode 100644 index 00000000..e69de29b diff --git a/src/Test/Integration/_files/cloud_base_developer/.docker/config.php.dist b/src/Test/Integration/_files/cloud_base_developer/.docker/config.php.dist new file mode 100644 index 00000000..f7b4e9c7 --- /dev/null +++ b/src/Test/Integration/_files/cloud_base_developer/.docker/config.php.dist @@ -0,0 +1,47 @@ + base64_encode(json_encode([ + 'database' => [ + [ + 'host' => 'db', + 'path' => 'magento2', + 'password' => 'magento2', + 'username' => 'magento2', + 'port' => '3306' + ] + ], + 'redis' => [ + [ + 'host' => 'redis', + 'port' => '6379' + ] + ], + 'elasticsearch' => [ + [ + 'host' => 'elasticsearch', + 'port' => '9200' + ] + ] + ])), + 'MAGENTO_CLOUD_ROUTES' => base64_encode(json_encode([ + 'http://magento2.docker/' => [ + 'type' => 'upstream', + 'original_url' => 'http://{default}' + ], + 'https://magento2.docker/' => [ + 'type' => 'upstream', + 'original_url' => 'https://{default}' + ] + ])), + 'MAGENTO_CLOUD_VARIABLES' => base64_encode(json_encode([ + 'ADMIN_EMAIL' => 'admin@example.com', + 'ADMIN_PASSWORD' => '123123q', + 'ADMIN_URL' => 'admin' + ])), + 'MAGENTO_CLOUD_APPLICATION' => base64_encode(json_encode([ + 'hooks' => [ + + ] + ])), +]; diff --git a/src/Test/Integration/_files/cloud_base_developer/.magento.app.yaml b/src/Test/Integration/_files/cloud_base_developer/.magento.app.yaml new file mode 100644 index 00000000..aeaadbd0 --- /dev/null +++ b/src/Test/Integration/_files/cloud_base_developer/.magento.app.yaml @@ -0,0 +1,29 @@ +name: mymagento + +type: php:7.3 +build: + flavor: composer + +runtime: + extensions: + - redis + - xsl + - json + - newrelic + - sodium + +relationships: + database: "mysql:mysql" + redis: "redis:redis" + elasticsearch: "elasticsearch:elasticsearch" + +mounts: + "var": "shared:files/var" + "app/etc": "shared:files/etc" + "pub/media": "shared:files/media" + "pub/static": "shared:files/static" + +crons: + cronrun: + spec: "* * * * *" + cmd: "php bin/magento cron:run" diff --git a/src/Test/Integration/_files/cloud_base_developer/.magento/services.yaml b/src/Test/Integration/_files/cloud_base_developer/.magento/services.yaml new file mode 100644 index 00000000..9ddbe2c1 --- /dev/null +++ b/src/Test/Integration/_files/cloud_base_developer/.magento/services.yaml @@ -0,0 +1,14 @@ +mysql: + type: mysql:10.2 + disk: 2048 + +redis: + type: redis:5.0 + +elasticsearch: + type: elasticsearch:6.5 + disk: 1024 + configuration: + plugins: + - plugin_1 + - plugin_2 diff --git a/src/Test/Integration/_files/cloud_base_developer/composer.json b/src/Test/Integration/_files/cloud_base_developer/composer.json new file mode 100644 index 00000000..6ed415ed --- /dev/null +++ b/src/Test/Integration/_files/cloud_base_developer/composer.json @@ -0,0 +1,6 @@ +{ + "name": "magento/project-enterprise-edition", + "description": "Composer file for integration tests", + "type": "project", + "version": "2.2.0" +} diff --git a/src/Test/Integration/_files/cloud_base_developer/docker-compose.exp.yml b/src/Test/Integration/_files/cloud_base_developer/docker-compose.exp.yml new file mode 100644 index 00000000..0db6201c --- /dev/null +++ b/src/Test/Integration/_files/cloud_base_developer/docker-compose.exp.yml @@ -0,0 +1,168 @@ +version: '2.1' +services: + db: + hostname: db.magento2.docker + image: 'mariadb:10.2' + environment: + - MYSQL_ROOT_PASSWORD=magento2 + - MYSQL_DATABASE=magento2 + - MYSQL_USER=magento2 + - MYSQL_PASSWORD=magento2 + ports: + - '3306' + volumes: + - '.:/app:delegated' + - 'mymagento-magento-db:/var/lib/mysql' + - '.docker/mysql/mariadb.conf.d:/etc/mysql/mariadb.conf.d' + - '.docker/mysql/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d' + healthcheck: + test: 'mysqladmin ping -h localhost -pmagento2' + interval: 30s + timeout: 30s + retries: 3 + networks: + magento: + aliases: + - db.magento2.docker + redis: + hostname: redis.magento2.docker + image: 'redis:5.0' + volumes: + - '.:/app:delegated' + ports: + - 6379 + healthcheck: + test: 'redis-cli ping || exit 1' + interval: 30s + timeout: 30s + retries: 3 + networks: + magento: + aliases: + - redis.magento2.docker + elasticsearch: + hostname: elasticsearch.magento2.docker + image: 'magento/magento-cloud-docker-elasticsearch:6.5-1.2.0' + environment: + - 'ES_PLUGINS=plugin_1 plugin_2' + networks: + magento: + aliases: + - elasticsearch.magento2.docker + fpm: + hostname: fpm.magento2.docker + image: 'magento/magento-cloud-docker-php:7.3-fpm-1.2.0' + extends: generic + volumes: + - '.:/app:delegated' + networks: + magento: + aliases: + - fpm.magento2.docker + depends_on: + db: + condition: service_healthy + web: + hostname: web.magento2.docker + image: 'magento/magento-cloud-docker-nginx:1.19-1.2.0' + extends: generic + volumes: + - '.:/app:delegated' + environment: + - WITH_XDEBUG=0 + - NGINX_WORKER_PROCESSES=1 + - NGINX_WORKER_CONNECTIONS=1024 + networks: + magento: + aliases: + - web.magento2.docker + depends_on: + fpm: + condition: service_started + varnish: + hostname: varnish.magento2.docker + image: 'magento/magento-cloud-docker-varnish:6.2-1.2.0' + networks: + magento: + aliases: + - varnish.magento2.docker + depends_on: + web: + condition: service_started + tls: + hostname: tls.magento2.docker + image: 'magento/magento-cloud-docker-nginx:1.19-1.2.0' + extends: generic + networks: + magento: + aliases: + - magento2.docker + environment: + - NGINX_WORKER_PROCESSES=1 + - NGINX_WORKER_CONNECTIONS=1024 + - UPSTREAM_HOST=varnish + - UPSTREAM_PORT=80 + ports: + - '80:80' + - '443:443' + depends_on: + varnish: + condition: service_started + generic: + hostname: generic.magento2.docker + image: 'magento/magento-cloud-docker-php:7.3-cli-1.2.0' + env_file: ./.docker/config.env + environment: + - MAGENTO_RUN_MODE=developer + - 'PHP_EXTENSIONS=bcmath bz2 calendar exif gd gettext intl mysqli pcntl pdo_mysql soap sockets sysvmsg sysvsem sysvshm opcache zip redis xsl sodium' + build: + hostname: build.magento2.docker + image: 'magento/magento-cloud-docker-php:7.3-cli-1.2.0' + extends: generic + volumes: + - '.:/app:delegated' + networks: + magento-build: + aliases: + - build.magento2.docker + depends_on: + db: + condition: service_healthy + redis: + condition: service_healthy + elasticsearch: + condition: service_healthy + deploy: + hostname: deploy.magento2.docker + image: 'magento/magento-cloud-docker-php:7.3-cli-1.2.0' + extends: generic + volumes: + - '.:/app:delegated' + networks: + magento: + aliases: + - deploy.magento2.docker + depends_on: + db: + condition: service_healthy + redis: + condition: service_healthy + elasticsearch: + condition: service_healthy + mailhog: + hostname: mailhog.magento2.docker + image: 'mailhog/mailhog:latest' + ports: + - '1025:1025' + - '8025:8025' + networks: + magento: + aliases: + - mailhog.magento2.docker +volumes: + mymagento-magento-db: { } +networks: + magento: + driver: bridge + magento-build: + driver: bridge