From cc990aded5af683b52de8c63d9c6ef1efa526041 Mon Sep 17 00:00:00 2001 From: Bohdan Korablov Date: Thu, 11 Nov 2021 14:41:40 -0600 Subject: [PATCH 01/13] ACDOG-53: Add repo metadata --- .github/.metadata.json | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/.metadata.json diff --git a/.github/.metadata.json b/.github/.metadata.json new file mode 100644 index 00000000..4f52d256 --- /dev/null +++ b/.github/.metadata.json @@ -0,0 +1,26 @@ +{ + "templateVersion": "0.1", + "product": { + "name": "Magento Cloud Docker", + "description": "The Magento Cloud Docker implementation deploys Cloud projects to a local workstation so that you can develop and test your code in a simulated Cloud environment" + }, + "contacts": { + "team": { + "name": "Magic Mountain", + "DL": "Grp-magento-cloud-all", + "slackChannel": "magic_mountain" + } + }, + "ticketTracker": { + "functionalJiraQueue": { + "projectKey": "MCLOUD" + }, + "securityJiraQueue": { + "projectKey": "MAGREQ", + "component": "Magento Cloud Engineering" + } + }, + "staticScan": { + "enable": false + } +} From 4c4195ef41368fb2a7e06b5919af1c6f21edd22c Mon Sep 17 00:00:00 2001 From: Bohdan Korablov Date: Tue, 7 Dec 2021 10:57:33 -0600 Subject: [PATCH 02/13] MCLOUD-8321: Added OpenSearch service (#76) --- config/services.xml | 1 + images/elasticsearch/6.5/docker-entrypoint.sh | 2 +- images/elasticsearch/6.8/docker-entrypoint.sh | 2 +- .../elasticsearch/7.11/docker-entrypoint.sh | 2 +- images/elasticsearch/7.5/docker-entrypoint.sh | 2 +- images/elasticsearch/7.6/docker-entrypoint.sh | 2 +- images/elasticsearch/7.7/docker-entrypoint.sh | 2 +- images/elasticsearch/7.9/docker-entrypoint.sh | 2 +- images/elasticsearch/es/docker-entrypoint.sh | 2 +- images/opensearch/1.1/Dockerfile | 13 +++ images/opensearch/1.1/docker-entrypoint.sh | 12 ++ images/opensearch/1.1/docker-healthcheck.sh | 12 ++ images/opensearch/os/Dockerfile | 13 +++ images/opensearch/os/docker-entrypoint.sh | 12 ++ images/opensearch/os/docker-healthcheck.sh | 12 ++ src/Application.php | 3 +- src/Command/BuildCompose.php | 15 +++ src/Command/Image/GenerateOs.php | 103 ++++++++++++++++++ src/Compose/BuilderInterface.php | 1 + src/Compose/ProductionBuilder/CliDepend.php | 3 + .../ProductionBuilder/Service/OpenSearch.php | 101 +++++++++++++++++ src/Config/Relationship.php | 6 + src/Config/Source/CliSource.php | 15 +++ src/Config/Source/CloudSource.php | 1 + src/Config/Source/SourceInterface.php | 15 +++ src/Service/ServiceFactory.php | 12 ++ src/Service/ServiceInterface.php | 1 + src/Test/Integration/BuildComposeTest.php | 4 + .../_files/cloud_base/.docker/config.php.dist | 7 ++ .../_files/cloud_base/.magento.app.yaml | 1 + .../_files/cloud_base/.magento/services.yaml | 8 ++ .../_files/cloud_base/docker-compose.exp.yml | 22 ++++ .../.docker/config.php.dist | 7 ++ .../cloud_base_developer/.magento.app.yaml | 1 + .../.magento/services.yaml | 8 ++ .../docker-compose.exp.yml | 22 ++++ .../_files/cloud_base_mftf/.magento.app.yaml | 1 + .../cloud_base_mftf/.magento/services.yaml | 8 ++ .../_files/cloud_base_test/.magento.app.yaml | 1 + .../cloud_base_test/.magento/services.yaml | 8 ++ src/Test/Unit/Config/RelationshipTest.php | 17 ++- 41 files changed, 470 insertions(+), 12 deletions(-) create mode 100644 images/opensearch/1.1/Dockerfile create mode 100755 images/opensearch/1.1/docker-entrypoint.sh create mode 100644 images/opensearch/1.1/docker-healthcheck.sh create mode 100755 images/opensearch/os/Dockerfile create mode 100755 images/opensearch/os/docker-entrypoint.sh create mode 100755 images/opensearch/os/docker-healthcheck.sh create mode 100644 src/Command/Image/GenerateOs.php create mode 100644 src/Compose/ProductionBuilder/Service/OpenSearch.php diff --git a/config/services.xml b/config/services.xml index ec12d2e0..3e08211f 100644 --- a/config/services.xml +++ b/config/services.xml @@ -24,6 +24,7 @@ + diff --git a/images/elasticsearch/6.5/docker-entrypoint.sh b/images/elasticsearch/6.5/docker-entrypoint.sh index c0d5d82e..e2c63c4c 100755 --- a/images/elasticsearch/6.5/docker-entrypoint.sh +++ b/images/elasticsearch/6.5/docker-entrypoint.sh @@ -2,7 +2,7 @@ set -eo pipefail if [[ -n "$ES_PLUGINS" ]]; then - echo "Intalling plugins: $ES_PLUGNS" + echo "Installing plugins: $ES_PLUGNS" for PLUGIN in $ES_PLUGINS do ./bin/elasticsearch-plugin install -b "$PLUGIN" diff --git a/images/elasticsearch/6.8/docker-entrypoint.sh b/images/elasticsearch/6.8/docker-entrypoint.sh index c0d5d82e..e2c63c4c 100755 --- a/images/elasticsearch/6.8/docker-entrypoint.sh +++ b/images/elasticsearch/6.8/docker-entrypoint.sh @@ -2,7 +2,7 @@ set -eo pipefail if [[ -n "$ES_PLUGINS" ]]; then - echo "Intalling plugins: $ES_PLUGNS" + echo "Installing plugins: $ES_PLUGNS" for PLUGIN in $ES_PLUGINS do ./bin/elasticsearch-plugin install -b "$PLUGIN" diff --git a/images/elasticsearch/7.11/docker-entrypoint.sh b/images/elasticsearch/7.11/docker-entrypoint.sh index c0d5d82e..e2c63c4c 100755 --- a/images/elasticsearch/7.11/docker-entrypoint.sh +++ b/images/elasticsearch/7.11/docker-entrypoint.sh @@ -2,7 +2,7 @@ set -eo pipefail if [[ -n "$ES_PLUGINS" ]]; then - echo "Intalling plugins: $ES_PLUGNS" + echo "Installing plugins: $ES_PLUGNS" for PLUGIN in $ES_PLUGINS do ./bin/elasticsearch-plugin install -b "$PLUGIN" diff --git a/images/elasticsearch/7.5/docker-entrypoint.sh b/images/elasticsearch/7.5/docker-entrypoint.sh index c0d5d82e..e2c63c4c 100755 --- a/images/elasticsearch/7.5/docker-entrypoint.sh +++ b/images/elasticsearch/7.5/docker-entrypoint.sh @@ -2,7 +2,7 @@ set -eo pipefail if [[ -n "$ES_PLUGINS" ]]; then - echo "Intalling plugins: $ES_PLUGNS" + echo "Installing plugins: $ES_PLUGNS" for PLUGIN in $ES_PLUGINS do ./bin/elasticsearch-plugin install -b "$PLUGIN" diff --git a/images/elasticsearch/7.6/docker-entrypoint.sh b/images/elasticsearch/7.6/docker-entrypoint.sh index c0d5d82e..e2c63c4c 100755 --- a/images/elasticsearch/7.6/docker-entrypoint.sh +++ b/images/elasticsearch/7.6/docker-entrypoint.sh @@ -2,7 +2,7 @@ set -eo pipefail if [[ -n "$ES_PLUGINS" ]]; then - echo "Intalling plugins: $ES_PLUGNS" + echo "Installing plugins: $ES_PLUGNS" for PLUGIN in $ES_PLUGINS do ./bin/elasticsearch-plugin install -b "$PLUGIN" diff --git a/images/elasticsearch/7.7/docker-entrypoint.sh b/images/elasticsearch/7.7/docker-entrypoint.sh index c0d5d82e..e2c63c4c 100755 --- a/images/elasticsearch/7.7/docker-entrypoint.sh +++ b/images/elasticsearch/7.7/docker-entrypoint.sh @@ -2,7 +2,7 @@ set -eo pipefail if [[ -n "$ES_PLUGINS" ]]; then - echo "Intalling plugins: $ES_PLUGNS" + echo "Installing plugins: $ES_PLUGNS" for PLUGIN in $ES_PLUGINS do ./bin/elasticsearch-plugin install -b "$PLUGIN" diff --git a/images/elasticsearch/7.9/docker-entrypoint.sh b/images/elasticsearch/7.9/docker-entrypoint.sh index c0d5d82e..e2c63c4c 100755 --- a/images/elasticsearch/7.9/docker-entrypoint.sh +++ b/images/elasticsearch/7.9/docker-entrypoint.sh @@ -2,7 +2,7 @@ set -eo pipefail if [[ -n "$ES_PLUGINS" ]]; then - echo "Intalling plugins: $ES_PLUGNS" + echo "Installing plugins: $ES_PLUGNS" for PLUGIN in $ES_PLUGINS do ./bin/elasticsearch-plugin install -b "$PLUGIN" diff --git a/images/elasticsearch/es/docker-entrypoint.sh b/images/elasticsearch/es/docker-entrypoint.sh index c0d5d82e..e2c63c4c 100755 --- a/images/elasticsearch/es/docker-entrypoint.sh +++ b/images/elasticsearch/es/docker-entrypoint.sh @@ -2,7 +2,7 @@ set -eo pipefail if [[ -n "$ES_PLUGINS" ]]; then - echo "Intalling plugins: $ES_PLUGNS" + echo "Installing plugins: $ES_PLUGNS" for PLUGIN in $ES_PLUGINS do ./bin/elasticsearch-plugin install -b "$PLUGIN" diff --git a/images/opensearch/1.1/Dockerfile b/images/opensearch/1.1/Dockerfile new file mode 100644 index 00000000..8d51cc6a --- /dev/null +++ b/images/opensearch/1.1/Dockerfile @@ -0,0 +1,13 @@ +FROM opensearchproject/opensearch:1.1.0 + +RUN bin/opensearch-plugin install -b analysis-icu && \ + bin/opensearch-plugin install -b analysis-phonetic + +ADD docker-healthcheck.sh /docker-healthcheck.sh +ADD docker-entrypoint.sh /docker-entrypoint.sh + +HEALTHCHECK --retries=3 CMD ["bash", "/docker-healthcheck.sh"] + +ENTRYPOINT ["/docker-entrypoint.sh"] + +EXPOSE 9200 9300 diff --git a/images/opensearch/1.1/docker-entrypoint.sh b/images/opensearch/1.1/docker-entrypoint.sh new file mode 100755 index 00000000..ad80b15a --- /dev/null +++ b/images/opensearch/1.1/docker-entrypoint.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -eo pipefail + +if [[ -n "$OS_PLUGINS" ]]; then + echo "Installing plugins: $OS_PLUGINS" + for PLUGIN in $OS_PLUGINS + do + ./bin/opensearch-plugin install -b "$PLUGIN" + done +fi + +/bin/bash /usr/share/opensearch/opensearch-docker-entrypoint.sh diff --git a/images/opensearch/1.1/docker-healthcheck.sh b/images/opensearch/1.1/docker-healthcheck.sh new file mode 100644 index 00000000..4081bbb2 --- /dev/null +++ b/images/opensearch/1.1/docker-healthcheck.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -eo pipefail + +if health="$(curl -fsSL "http://${OS_HOST:-opensearch}:${OS_HOST:-9200}/_cat/health?h=status")"; then + health="$(echo "$health" | sed -r 's/^[[:space:]]+|[[:space:]]+$//g')" # trim whitespace (otherwise we'll have "green ") + if [ "$health" = 'green' ] || [ "$health" = 'yellow' ]; then + exit 0 + fi + echo >&2 "Unexpected health status: $health" +fi + +exit 1 diff --git a/images/opensearch/os/Dockerfile b/images/opensearch/os/Dockerfile new file mode 100755 index 00000000..8d51cc6a --- /dev/null +++ b/images/opensearch/os/Dockerfile @@ -0,0 +1,13 @@ +FROM opensearchproject/opensearch:1.1.0 + +RUN bin/opensearch-plugin install -b analysis-icu && \ + bin/opensearch-plugin install -b analysis-phonetic + +ADD docker-healthcheck.sh /docker-healthcheck.sh +ADD docker-entrypoint.sh /docker-entrypoint.sh + +HEALTHCHECK --retries=3 CMD ["bash", "/docker-healthcheck.sh"] + +ENTRYPOINT ["/docker-entrypoint.sh"] + +EXPOSE 9200 9300 diff --git a/images/opensearch/os/docker-entrypoint.sh b/images/opensearch/os/docker-entrypoint.sh new file mode 100755 index 00000000..ad80b15a --- /dev/null +++ b/images/opensearch/os/docker-entrypoint.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -eo pipefail + +if [[ -n "$OS_PLUGINS" ]]; then + echo "Installing plugins: $OS_PLUGINS" + for PLUGIN in $OS_PLUGINS + do + ./bin/opensearch-plugin install -b "$PLUGIN" + done +fi + +/bin/bash /usr/share/opensearch/opensearch-docker-entrypoint.sh diff --git a/images/opensearch/os/docker-healthcheck.sh b/images/opensearch/os/docker-healthcheck.sh new file mode 100755 index 00000000..4081bbb2 --- /dev/null +++ b/images/opensearch/os/docker-healthcheck.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -eo pipefail + +if health="$(curl -fsSL "http://${OS_HOST:-opensearch}:${OS_HOST:-9200}/_cat/health?h=status")"; then + health="$(echo "$health" | sed -r 's/^[[:space:]]+|[[:space:]]+$//g')" # trim whitespace (otherwise we'll have "green ") + if [ "$health" = 'green' ] || [ "$health" = 'yellow' ]; then + exit 0 + fi + echo >&2 "Unexpected health status: $health" +fi + +exit 1 diff --git a/src/Application.php b/src/Application.php index 80af25e6..2aca8022 100644 --- a/src/Application.php +++ b/src/Application.php @@ -42,7 +42,8 @@ protected function getDefaultCommands() $this->container->get(Command\BuildCustomCompose::class), $this->container->get(Command\BuildDist::class), $this->container->get(Command\Image\GeneratePhp::class), - $this->container->get(Command\Image\GenerateEs::class) + $this->container->get(Command\Image\GenerateEs::class), + $this->container->get(Command\Image\GenerateOs::class) ]); } } diff --git a/src/Command/BuildCompose.php b/src/Command/BuildCompose.php index 8f28281a..bbb6f2e9 100644 --- a/src/Command/BuildCompose.php +++ b/src/Command/BuildCompose.php @@ -143,6 +143,11 @@ protected function configure(): void null, InputOption::VALUE_REQUIRED, 'Elasticsearch version' + )->addOption( + Source\CliSource::OPTION_OS, + null, + InputOption::VALUE_REQUIRED, + 'Opensearch version' )->addOption( Source\CliSource::OPTION_RABBIT_MQ, null, @@ -178,6 +183,11 @@ protected function configure(): void null, InputOption::VALUE_NONE, 'Disable Elasticsearch' + )->addOption( + Source\CliSource::OPTION_NO_OS, + null, + InputOption::VALUE_NONE, + 'Disable Opensearch' )->addOption( Source\CliSource::OPTION_NO_MAILHOG, null, @@ -310,6 +320,11 @@ protected function configure(): void null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Environment variable for elasticsearch service' + )->addOption( + Source\CliSource::OPTION_OS_ENVIRONMENT_VARIABLE, + null, + InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, + 'Environment variable for opensearch service' )->addOption( Source\CliSource::OPTION_DB_INCREMENT_INCREMENT, null, diff --git a/src/Command/Image/GenerateOs.php b/src/Command/Image/GenerateOs.php new file mode 100644 index 00000000..9fbb599f --- /dev/null +++ b/src/Command/Image/GenerateOs.php @@ -0,0 +1,103 @@ + [ + 'real-version' => '1.1.0', + ], + ]; + + /** + * @var Filesystem + */ + private $filesystem; + + /** + * @var DirectoryList + */ + private $directoryList; + + /** + * @param Filesystem $filesystem + * @param DirectoryList $directoryList + */ + public function __construct(Filesystem $filesystem, DirectoryList $directoryList) + { + $this->filesystem = $filesystem; + $this->directoryList = $directoryList; + + parent::__construct(); + } + + /** + * @inheritDoc + */ + protected function configure(): void + { + $this->setName(self::NAME) + ->setDescription('Generates opensearch configs'); + + parent::configure(); + } + + /** + * Generates data for opensearch images. + * + * {@inheritDoc} + * @throws FileNotFoundException + * @throws \Magento\CloudDocker\Filesystem\FileSystemException + */ + public function execute(InputInterface $input, OutputInterface $output): int + { + foreach ($this->versionMap as $version => $versionData) { + $destination = $this->directoryList->getImagesRoot() . '/opensearch/' . $version; + $dataDir = $this->directoryList->getImagesRoot() . '/opensearch/os/'; + $dockerfile = $destination . '/Dockerfile'; + + $this->filesystem->deleteDirectory($destination); + $this->filesystem->makeDirectory($destination); + $this->filesystem->copyDirectory($dataDir, $destination); + $this->filesystem->chmod($destination . '/docker-entrypoint.sh', 0755); + + $this->filesystem->put( + $dockerfile, + strtr( + $this->filesystem->get($dockerfile), + [ + '{%version%}' => $versionData['real-version'], + ] + ) + ); + } + + $output->writeln('Done'); + + return Cli::SUCCESS; + } +} diff --git a/src/Compose/BuilderInterface.php b/src/Compose/BuilderInterface.php index 8a03ee67..ecfba36e 100644 --- a/src/Compose/BuilderInterface.php +++ b/src/Compose/BuilderInterface.php @@ -30,6 +30,7 @@ interface BuilderInterface public const SERVICE_RABBITMQ = ServiceInterface::SERVICE_RABBITMQ; public const SERVICE_REDIS = ServiceInterface::SERVICE_REDIS; public const SERVICE_ELASTICSEARCH = ServiceInterface::SERVICE_ELASTICSEARCH; + public const SERVICE_OPENSEARCH = ServiceInterface::SERVICE_OPENSEARCH; public const SERVICE_NODE = ServiceInterface::SERVICE_NODE; public const SERVICE_CRON = 'cron'; public const SERVICE_TEST = ServiceInterface::SERVICE_TEST; diff --git a/src/Compose/ProductionBuilder/CliDepend.php b/src/Compose/ProductionBuilder/CliDepend.php index 826f1d17..46abe017 100644 --- a/src/Compose/ProductionBuilder/CliDepend.php +++ b/src/Compose/ProductionBuilder/CliDepend.php @@ -30,6 +30,9 @@ class CliDepend BuilderInterface::SERVICE_ELASTICSEARCH => [ 'condition' => 'service_healthy' ], + BuilderInterface::SERVICE_OPENSEARCH => [ + 'condition' => 'service_healthy' + ], BuilderInterface::SERVICE_NODE => [ 'condition' => 'service_started' ], diff --git a/src/Compose/ProductionBuilder/Service/OpenSearch.php b/src/Compose/ProductionBuilder/Service/OpenSearch.php new file mode 100644 index 00000000..79056fc0 --- /dev/null +++ b/src/Compose/ProductionBuilder/Service/OpenSearch.php @@ -0,0 +1,101 @@ +serviceFactory = $serviceFactory; + } + + /** + * @inheritDoc + */ + public function getName(): string + { + return BuilderInterface::SERVICE_OPENSEARCH; + } + + /** + * @inheritDoc + */ + public function getServiceName(): string + { + return $this->getName(); + } + + /** + * @inheritDoc + */ + public function getConfig(Config $config): array + { + $osEnvVars = [ + 'cluster.name=docker-cluster', + 'discovery.type=single-node', + 'discovery.seed_hosts=opensearch', + 'bootstrap.memory_lock=true', + 'DISABLE_SECURITY_PLUGIN=true', + ]; + + if (!empty($config->get(SourceInterface::SERVICES_OS_VARS))) { + $osEnvVars = array_merge($osEnvVars, $config->get(SourceInterface::SERVICES_OS_VARS)); + } + + if (!empty($plugins = $config->get(SourceInterface::SERVICES_OS_PLUGINS)) && is_array($plugins)) { + $plugins = array_diff($plugins, self::INSTALLED_PLUGINS); + if (!empty($plugins)) { + $osEnvVars[] = 'OS_PLUGINS=' . implode(' ', $plugins); + } + } + + return $this->serviceFactory->create( + $this->getServiceName(), + $config->getServiceVersion($this->getServiceName()), + !empty($osEnvVars) ? ['environment' => $osEnvVars] : [], + $config->getServiceImage($this->getServiceName()), + $config->getCustomRegistry(), + $config->getServiceImagePattern($this->getServiceName()) + ); + } + + /** + * @inheritDoc + */ + public function getNetworks(): array + { + return [BuilderInterface::NETWORK_MAGENTO]; + } + + /** + * @inheritDoc + */ + public function getDependsOn(Config $config): array + { + return []; + } +} diff --git a/src/Config/Relationship.php b/src/Config/Relationship.php index 2ee34949..c98edcf9 100644 --- a/src/Config/Relationship.php +++ b/src/Config/Relationship.php @@ -61,6 +61,12 @@ class Relationship 'port' => '9200', ], ], + 'opensearch' => [ + [ + 'host' => 'opensearch', + 'port' => '9200', + ], + ], 'rabbitmq' => [ [ 'host' => 'rabbitmq', diff --git a/src/Config/Source/CliSource.php b/src/Config/Source/CliSource.php index dc44812f..30cdd328 100644 --- a/src/Config/Source/CliSource.php +++ b/src/Config/Source/CliSource.php @@ -28,6 +28,7 @@ class CliSource implements SourceInterface public const OPTION_EXPOSE_DB_SALES_PORT = 'expose-db-sales-port'; public const OPTION_REDIS = 'redis'; public const OPTION_ES = 'es'; + public const OPTION_OS = 'os'; public const OPTION_RABBIT_MQ = 'rmq'; public const OPTION_SELENIUM_VERSION = 'selenium-version'; public const OPTION_SELENIUM_IMAGE = 'selenium-image'; @@ -35,6 +36,7 @@ class CliSource implements SourceInterface public const OPTION_ZOOKEEPER_IMAGE = 'zookeeper-image'; public const OPTION_INSTALLATION_TYPE = 'installation-type'; public const OPTION_NO_ES = 'no-es'; + public const OPTION_NO_OS = 'no-os'; public const OPTION_NO_MAILHOG = 'no-mailhog'; public const OPTION_NO_TLS = 'no-tls'; @@ -92,6 +94,11 @@ class CliSource implements SourceInterface */ public const OPTION_ES_ENVIRONMENT_VARIABLE = 'es-env-var'; + /** + * Environment variable for opensearch service. + */ + public const OPTION_OS_ENVIRONMENT_VARIABLE = 'os-env-var'; + /** * Root directory */ @@ -120,6 +127,9 @@ class CliSource implements SourceInterface self::OPTION_ES => [ self::SERVICES_ES => true ], + self::OPTION_OS => [ + self::SERVICES_OS => true + ], self::OPTION_NODE => [ self::SERVICES_NODE => true ], @@ -135,6 +145,7 @@ class CliSource implements SourceInterface */ private static $disableOptionsMap = [ self::OPTION_NO_ES => self::SERVICES_ES, + self::OPTION_NO_OS => self::SERVICES_OS, self::OPTION_NO_MAILHOG => self::SERVICES_MAILHOG, self::OPTION_NO_TLS => self::SERVICES_TLS, ]; @@ -298,6 +309,10 @@ public function read(): Repository $repository->set(self::SERVICES_ES_VARS, $esEnvVars); } + if ($osEnvVars = $this->input->getOption(self::OPTION_OS_ENVIRONMENT_VARIABLE)) { + $repository->set(self::SERVICES_OS_VARS, $osEnvVars); + } + if ($incrementIncrement = $this->input->getOption(self::OPTION_DB_INCREMENT_INCREMENT)) { $repository->set(SourceInterface::SYSTEM_DB_INCREMENT_INCREMENT, $incrementIncrement); } diff --git a/src/Config/Source/CloudSource.php b/src/Config/Source/CloudSource.php index ad777027..4cbe421e 100644 --- a/src/Config/Source/CloudSource.php +++ b/src/Config/Source/CloudSource.php @@ -45,6 +45,7 @@ class CloudSource implements SourceInterface ServiceInterface::SERVICE_DB_QUOTE => ['mysql-quote'], ServiceInterface::SERVICE_DB_SALES => ['mysql-sales'], ServiceInterface::SERVICE_ELASTICSEARCH => ['elasticsearch', 'es'], + ServiceInterface::SERVICE_OPENSEARCH => ['opensearch', 'os'], ServiceInterface::SERVICE_REDIS => ['redis'], ServiceInterface::SERVICE_RABBITMQ => ['rmq', 'rabbitmq'] ]; diff --git a/src/Config/Source/SourceInterface.php b/src/Config/Source/SourceInterface.php index 4e3c34c3..9456293d 100644 --- a/src/Config/Source/SourceInterface.php +++ b/src/Config/Source/SourceInterface.php @@ -78,6 +78,11 @@ interface SourceInterface */ public const SERVICES_ES = self::SERVICES . '.' . ServiceInterface::SERVICE_ELASTICSEARCH; + /** + * OS + */ + public const SERVICES_OS = self::SERVICES . '.' . ServiceInterface::SERVICE_OPENSEARCH; + /** * Mailhog */ @@ -88,11 +93,21 @@ interface SourceInterface */ public const SERVICES_ES_VARS = self::SERVICES_ES . '.' . 'env-vars'; + /** + * OS environment variables + */ + public const SERVICES_OS_VARS = self::SERVICES_OS . '.' . 'env-vars'; + /** * ES plugins */ public const SERVICES_ES_PLUGINS = self::SERVICES_ES . '.configuration.plugins'; + /** + * OS plugins + */ + public const SERVICES_OS_PLUGINS = self::SERVICES_OS . '.configuration.plugins'; + /** * Node */ diff --git a/src/Service/ServiceFactory.php b/src/Service/ServiceFactory.php index 74c0ef37..99f3dc5b 100644 --- a/src/Service/ServiceFactory.php +++ b/src/Service/ServiceFactory.php @@ -117,6 +117,18 @@ class ServiceFactory ] ] ], + ServiceInterface::SERVICE_OPENSEARCH => [ + 'image' => 'magento/magento-cloud-docker-opensearch', + 'pattern' => self::PATTERN_VERSIONED, + 'config' => [ + 'ulimits' => [ + 'memlock' => [ + 'soft' => -1, + 'hard' => -1 + ] + ] + ] + ], ServiceInterface::SERVICE_RABBITMQ => [ 'image' => 'rabbitmq', 'pattern' => self::PATTERN_STD, diff --git a/src/Service/ServiceInterface.php b/src/Service/ServiceInterface.php index feef9905..4ee3be2b 100644 --- a/src/Service/ServiceInterface.php +++ b/src/Service/ServiceInterface.php @@ -24,6 +24,7 @@ interface ServiceInterface public const SERVICE_NGINX = 'nginx'; public const SERVICE_REDIS = 'redis'; public const SERVICE_ELASTICSEARCH = 'elasticsearch'; + public const SERVICE_OPENSEARCH = 'opensearch'; public const SERVICE_RABBITMQ = 'rabbitmq'; public const SERVICE_NODE = 'node'; public const SERVICE_VARNISH = 'varnish'; diff --git a/src/Test/Integration/BuildComposeTest.php b/src/Test/Integration/BuildComposeTest.php index 3d5027ba..bc1d294c 100644 --- a/src/Test/Integration/BuildComposeTest.php +++ b/src/Test/Integration/BuildComposeTest.php @@ -115,7 +115,9 @@ public function buildDataProvider(): array [CliSource::OPTION_WITH_CRON, true], [CliSource::OPTION_WITH_XDEBUG, true], [CliSource::OPTION_ES, '5.2'], + [CliSource::OPTION_OS, '1.2'], [CliSource::OPTION_NO_ES, true], + [CliSource::OPTION_NO_OS, true], [CliSource::OPTION_DB_INCREMENT_INCREMENT, 3], [CliSource::OPTION_DB_INCREMENT_OFFSET, 2], [CliSource::OPTION_WITH_ENTRYPOINT, true], @@ -136,7 +138,9 @@ public function buildDataProvider(): array [CliSource::OPTION_WITH_ZOOKEEPER, true], [CliSource::OPTION_WITH_XDEBUG, true], [CliSource::OPTION_ES, '5.2'], + [CliSource::OPTION_OS, '1.2'], [CliSource::OPTION_NO_ES, true], + [CliSource::OPTION_NO_OS, true], [CliSource::OPTION_DB_INCREMENT_INCREMENT, 3], [CliSource::OPTION_DB_INCREMENT_OFFSET, 2], [CliSource::OPTION_WITH_ENTRYPOINT, true], diff --git a/src/Test/Integration/_files/cloud_base/.docker/config.php.dist b/src/Test/Integration/_files/cloud_base/.docker/config.php.dist index be57fadb..73c31674 100644 --- a/src/Test/Integration/_files/cloud_base/.docker/config.php.dist +++ b/src/Test/Integration/_files/cloud_base/.docker/config.php.dist @@ -25,6 +25,13 @@ return [ 'port' => '9200', 'type' => 'elasticsearch:6.5' ] + ], + 'opensearch' => [ + [ + 'host' => 'opensearch', + 'port' => '9200', + 'type' => 'opensearch:1.1' + ] ] ])), 'MAGENTO_CLOUD_ROUTES' => base64_encode(json_encode([ diff --git a/src/Test/Integration/_files/cloud_base/.magento.app.yaml b/src/Test/Integration/_files/cloud_base/.magento.app.yaml index 0fae6f4b..03f4f7b2 100644 --- a/src/Test/Integration/_files/cloud_base/.magento.app.yaml +++ b/src/Test/Integration/_files/cloud_base/.magento.app.yaml @@ -16,6 +16,7 @@ relationships: database: "mysql:mysql" redis: "redis:redis" elasticsearch: "elasticsearch:elasticsearch" + opensearch: "opensearch:opensearch" mounts: "var": "shared:files/var" diff --git a/src/Test/Integration/_files/cloud_base/.magento/services.yaml b/src/Test/Integration/_files/cloud_base/.magento/services.yaml index 9ddbe2c1..cad17cb8 100644 --- a/src/Test/Integration/_files/cloud_base/.magento/services.yaml +++ b/src/Test/Integration/_files/cloud_base/.magento/services.yaml @@ -12,3 +12,11 @@ elasticsearch: plugins: - plugin_1 - plugin_2 + +opensearch: + type: opensearchsearch:1.1 + disk: 512 + configuration: + plugins: + - plugin_3 + - plugin_4 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 f89b052e..437f091b 100644 --- a/src/Test/Integration/_files/cloud_base/docker-compose.exp.yml +++ b/src/Test/Integration/_files/cloud_base/docker-compose.exp.yml @@ -63,6 +63,24 @@ services: magento: aliases: - elasticsearch.magento2.docker + opensearch: + hostname: opensearch.magento2.docker + image: 'magento/magento-cloud-docker-opensearch:1.1-1.2.0' + ulimits: + memlock: + soft: -1 + hard: -1 + environment: + - cluster.name=docker-cluster + - discovery.type=single-node + - discovery.seed_hosts=opensearch + - bootstrap.memory_lock=true + - DISABLE_SECURITY_PLUGIN=true + - 'OS_PLUGINS=plugin_3 plugin_4' + networks: + magento: + aliases: + - opensearch.magento2.docker fpm: hostname: fpm.magento2.docker image: 'magento/magento-cloud-docker-php:7.3-fpm-1.2.0' @@ -163,6 +181,8 @@ services: condition: service_healthy elasticsearch: condition: service_healthy + opensearch: + condition: service_healthy deploy: hostname: deploy.magento2.docker image: 'magento/magento-cloud-docker-php:7.3-cli-1.2.0' @@ -187,6 +207,8 @@ services: condition: service_healthy elasticsearch: condition: service_healthy + opensearch: + condition: service_healthy mailhog: hostname: mailhog.magento2.docker image: 'mailhog/mailhog:latest' 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 index be57fadb..73c31674 100644 --- a/src/Test/Integration/_files/cloud_base_developer/.docker/config.php.dist +++ b/src/Test/Integration/_files/cloud_base_developer/.docker/config.php.dist @@ -25,6 +25,13 @@ return [ 'port' => '9200', 'type' => 'elasticsearch:6.5' ] + ], + 'opensearch' => [ + [ + 'host' => 'opensearch', + 'port' => '9200', + 'type' => 'opensearch:1.1' + ] ] ])), 'MAGENTO_CLOUD_ROUTES' => base64_encode(json_encode([ diff --git a/src/Test/Integration/_files/cloud_base_developer/.magento.app.yaml b/src/Test/Integration/_files/cloud_base_developer/.magento.app.yaml index 0fae6f4b..03f4f7b2 100644 --- a/src/Test/Integration/_files/cloud_base_developer/.magento.app.yaml +++ b/src/Test/Integration/_files/cloud_base_developer/.magento.app.yaml @@ -16,6 +16,7 @@ relationships: database: "mysql:mysql" redis: "redis:redis" elasticsearch: "elasticsearch:elasticsearch" + opensearch: "opensearch:opensearch" mounts: "var": "shared:files/var" diff --git a/src/Test/Integration/_files/cloud_base_developer/.magento/services.yaml b/src/Test/Integration/_files/cloud_base_developer/.magento/services.yaml index 9ddbe2c1..cad17cb8 100644 --- a/src/Test/Integration/_files/cloud_base_developer/.magento/services.yaml +++ b/src/Test/Integration/_files/cloud_base_developer/.magento/services.yaml @@ -12,3 +12,11 @@ elasticsearch: plugins: - plugin_1 - plugin_2 + +opensearch: + type: opensearchsearch:1.1 + disk: 512 + configuration: + plugins: + - plugin_3 + - plugin_4 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 index 4b9e55b7..9265d881 100644 --- a/src/Test/Integration/_files/cloud_base_developer/docker-compose.exp.yml +++ b/src/Test/Integration/_files/cloud_base_developer/docker-compose.exp.yml @@ -63,6 +63,24 @@ services: magento: aliases: - elasticsearch.magento2.docker + opensearch: + hostname: opensearch.magento2.docker + image: 'magento/magento-cloud-docker-opensearch:1.1-1.2.0' + ulimits: + memlock: + soft: -1 + hard: -1 + environment: + - cluster.name=docker-cluster + - discovery.type=single-node + - discovery.seed_hosts=opensearch + - bootstrap.memory_lock=true + - DISABLE_SECURITY_PLUGIN=true + - 'OS_PLUGINS=plugin_3 plugin_4' + networks: + magento: + aliases: + - opensearch.magento2.docker fpm: hostname: fpm.magento2.docker image: 'magento/magento-cloud-docker-php:7.3-fpm-1.2.0' @@ -146,6 +164,8 @@ services: condition: service_healthy elasticsearch: condition: service_healthy + opensearch: + condition: service_healthy deploy: hostname: deploy.magento2.docker image: 'magento/magento-cloud-docker-php:7.3-cli-1.2.0' @@ -163,6 +183,8 @@ services: condition: service_healthy elasticsearch: condition: service_healthy + opensearch: + condition: service_healthy mailhog: hostname: mailhog.magento2.docker image: 'mailhog/mailhog:latest' diff --git a/src/Test/Integration/_files/cloud_base_mftf/.magento.app.yaml b/src/Test/Integration/_files/cloud_base_mftf/.magento.app.yaml index 0fae6f4b..03f4f7b2 100644 --- a/src/Test/Integration/_files/cloud_base_mftf/.magento.app.yaml +++ b/src/Test/Integration/_files/cloud_base_mftf/.magento.app.yaml @@ -16,6 +16,7 @@ relationships: database: "mysql:mysql" redis: "redis:redis" elasticsearch: "elasticsearch:elasticsearch" + opensearch: "opensearch:opensearch" mounts: "var": "shared:files/var" diff --git a/src/Test/Integration/_files/cloud_base_mftf/.magento/services.yaml b/src/Test/Integration/_files/cloud_base_mftf/.magento/services.yaml index 62bc6b64..038f780f 100644 --- a/src/Test/Integration/_files/cloud_base_mftf/.magento/services.yaml +++ b/src/Test/Integration/_files/cloud_base_mftf/.magento/services.yaml @@ -8,3 +8,11 @@ redis: elasticsearch: type: elasticsearch:6.5 disk: 1024 + +opensearch: + type: opensearchsearch:1.1 + disk: 512 + configuration: + plugins: + - plugin_3 + - plugin_4 diff --git a/src/Test/Integration/_files/cloud_base_test/.magento.app.yaml b/src/Test/Integration/_files/cloud_base_test/.magento.app.yaml index aeaadbd0..13ccc132 100644 --- a/src/Test/Integration/_files/cloud_base_test/.magento.app.yaml +++ b/src/Test/Integration/_files/cloud_base_test/.magento.app.yaml @@ -16,6 +16,7 @@ relationships: database: "mysql:mysql" redis: "redis:redis" elasticsearch: "elasticsearch:elasticsearch" + opensearch: "opensearch:opensearch" mounts: "var": "shared:files/var" diff --git a/src/Test/Integration/_files/cloud_base_test/.magento/services.yaml b/src/Test/Integration/_files/cloud_base_test/.magento/services.yaml index 62bc6b64..038f780f 100644 --- a/src/Test/Integration/_files/cloud_base_test/.magento/services.yaml +++ b/src/Test/Integration/_files/cloud_base_test/.magento/services.yaml @@ -8,3 +8,11 @@ redis: elasticsearch: type: elasticsearch:6.5 disk: 1024 + +opensearch: + type: opensearchsearch:1.1 + disk: 512 + configuration: + plugins: + - plugin_3 + - plugin_4 diff --git a/src/Test/Unit/Config/RelationshipTest.php b/src/Test/Unit/Config/RelationshipTest.php index 891ce184..9c359d98 100644 --- a/src/Test/Unit/Config/RelationshipTest.php +++ b/src/Test/Unit/Config/RelationshipTest.php @@ -52,6 +52,12 @@ class RelationshipTest extends TestCase 'port' => '9200', ], ], + 'opensearch' => [ + [ + 'host' => 'opensearch', + 'port' => '9200', + ], + ], 'rabbitmq' => [ [ 'host' => 'rabbitmq', @@ -85,16 +91,18 @@ public function testGet() $mysqlVersion = '10.4'; $redisVersion = '5.2'; $esVersion = '7.7'; + $osVersion = '1.1'; $rmqVersion = '3.5'; $zookeeperVersion = 'latest'; $configWithType = $this->defaultConfigs; $configWithType['database'][0]['type'] = "mysql:$mysqlVersion"; $configWithType['redis'][0]['type'] = "redis:$redisVersion"; $configWithType['elasticsearch'][0]['type'] = "elasticsearch:$esVersion"; + $configWithType['opensearch'][0]['type'] = "opensearch:$osVersion"; $configWithType['rabbitmq'][0]['type'] = "rabbitmq:$rmqVersion"; $configWithType['zookeeper'][0]['type'] = "zookeeper:$zookeeperVersion"; - $this->configMock->expects($this->exactly(7)) + $this->configMock->expects($this->exactly(8)) ->method('hasServiceEnabled') ->withConsecutive( [ServiceInterface::SERVICE_DB], @@ -102,16 +110,18 @@ public function testGet() [ServiceInterface::SERVICE_DB_SALES], ['redis'], ['elasticsearch'], + ['opensearch'], ['rabbitmq'], ['zookeeper'] ) - ->willReturnOnConsecutiveCalls(true, false, false, true, true, true, true); - $this->configMock->expects($this->exactly(5)) + ->willReturnOnConsecutiveCalls(true, false, false, true, true, true, true, true); + $this->configMock->expects($this->exactly(6)) ->method('getServiceVersion') ->withConsecutive( [ServiceInterface::SERVICE_DB], ['redis'], ['elasticsearch'], + ['opensearch'], ['rabbitmq'], ['zookeeper'] ) @@ -119,6 +129,7 @@ public function testGet() $mysqlVersion, $redisVersion, $esVersion, + $osVersion, $rmqVersion, $zookeeperVersion ); From e28b376f4682f5c1b29c22ec322b2e09a7cee902 Mon Sep 17 00:00:00 2001 From: Bohdan Korablov Date: Mon, 13 Dec 2021 22:58:49 -0600 Subject: [PATCH 03/13] MACI-1446: Remove JndiLookup (#77) (#78) --- images/elasticsearch/5.2/Dockerfile | 8 +++- images/elasticsearch/5.2/docker-entrypoint.sh | 42 +++++++++++++++++++ images/elasticsearch/6.5/Dockerfile | 3 ++ images/elasticsearch/6.8/Dockerfile | 3 ++ images/elasticsearch/7.11/Dockerfile | 3 ++ images/elasticsearch/7.5/Dockerfile | 3 ++ images/elasticsearch/7.6/Dockerfile | 3 ++ images/elasticsearch/7.7/Dockerfile | 3 ++ images/elasticsearch/7.9/Dockerfile | 3 ++ images/elasticsearch/es/Dockerfile | 3 ++ 10 files changed, 72 insertions(+), 2 deletions(-) create mode 100755 images/elasticsearch/5.2/docker-entrypoint.sh diff --git a/images/elasticsearch/5.2/Dockerfile b/images/elasticsearch/5.2/Dockerfile index e513f24f..4353ae18 100644 --- a/images/elasticsearch/5.2/Dockerfile +++ b/images/elasticsearch/5.2/Dockerfile @@ -1,12 +1,16 @@ -FROM docker.elastic.co/elasticsearch/elasticsearch:5.2.2 +FROM elasticsearch:5.2.2 -RUN echo "xpack.security.enabled: false" >> /usr/share/elasticsearch/config/elasticsearch.yml +RUN apt update || true \ + && apt install zip +RUN zip -q -d /usr/share/elasticsearch/lib/log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class RUN bin/elasticsearch-plugin install analysis-icu && \ bin/elasticsearch-plugin install analysis-phonetic ADD docker-healthcheck.sh /docker-healthcheck.sh +ADD docker-entrypoint.sh /docker-entrypoint.sh + HEALTHCHECK --retries=3 CMD ["bash", "/docker-healthcheck.sh"] EXPOSE 9200 9300 diff --git a/images/elasticsearch/5.2/docker-entrypoint.sh b/images/elasticsearch/5.2/docker-entrypoint.sh new file mode 100755 index 00000000..19fce400 --- /dev/null +++ b/images/elasticsearch/5.2/docker-entrypoint.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +set -e + +# Add elasticsearch as command if needed +if [ "${1:0:1}" = '-' ]; then + set -- elasticsearch "$@" +fi + +# Drop root privileges if we are running elasticsearch +# allow the container to be started with `--user` +if [ "$1" = 'elasticsearch' -a "$(id -u)" = '0' ]; then + # Change the ownership of user-mutable directories to elasticsearch + for path in \ + /usr/share/elasticsearch/data \ + /usr/share/elasticsearch/logs \ + ; do + chown -R elasticsearch:elasticsearch "$path" + done + + es_opts='' + + while IFS='=' read -r envvar_key envvar_value + do + # Elasticsearch env vars need to have at least two dot separated lowercase words, e.g. `cluster.name` + if [[ "$envvar_key" =~ ^[a-z]+\.[a-z]+ ]] + then + if [[ ! -z $envvar_value ]]; then + es_opt="-E${envvar_key}=${envvar_value}" + es_opts+=" ${es_opt}" + fi + fi + done < <(env) + + set -- gosu elasticsearch "$@" ${es_opts} + #exec gosu elasticsearch "$BASH_SOURCE" "$@" +fi + +# As argument is not related to elasticsearch, +# then assume that user wants to run his own process, +# for example a `bash` shell to explore this image +exec "$@" diff --git a/images/elasticsearch/6.5/Dockerfile b/images/elasticsearch/6.5/Dockerfile index cc2ec054..5b7c0a7a 100644 --- a/images/elasticsearch/6.5/Dockerfile +++ b/images/elasticsearch/6.5/Dockerfile @@ -1,5 +1,8 @@ FROM docker.elastic.co/elasticsearch/elasticsearch:6.5.4 +RUN yum -y install zip +RUN zip -q -d /usr/share/elasticsearch/lib/log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class + RUN echo "xpack.security.enabled: false" >> /usr/share/elasticsearch/config/elasticsearch.yml RUN bin/elasticsearch-plugin install -b analysis-icu && \ diff --git a/images/elasticsearch/6.8/Dockerfile b/images/elasticsearch/6.8/Dockerfile index 24818946..aa131c97 100644 --- a/images/elasticsearch/6.8/Dockerfile +++ b/images/elasticsearch/6.8/Dockerfile @@ -1,5 +1,8 @@ FROM docker.elastic.co/elasticsearch/elasticsearch:6.8.15 +RUN yum -y install zip +RUN zip -q -d /usr/share/elasticsearch/lib/log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class + RUN echo "xpack.security.enabled: false" >> /usr/share/elasticsearch/config/elasticsearch.yml RUN echo "discovery.type: single-node" >> /usr/share/elasticsearch/config/elasticsearch.yml RUN bin/elasticsearch-plugin install -b analysis-icu && \ diff --git a/images/elasticsearch/7.11/Dockerfile b/images/elasticsearch/7.11/Dockerfile index fced5aaa..a25c50c2 100644 --- a/images/elasticsearch/7.11/Dockerfile +++ b/images/elasticsearch/7.11/Dockerfile @@ -1,5 +1,8 @@ FROM docker.elastic.co/elasticsearch/elasticsearch:7.11.2 +RUN yum -y install zip +RUN zip -q -d /usr/share/elasticsearch/lib/log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class + RUN echo "xpack.security.enabled: false" >> /usr/share/elasticsearch/config/elasticsearch.yml RUN echo "discovery.type: single-node" >> /usr/share/elasticsearch/config/elasticsearch.yml RUN bin/elasticsearch-plugin install -b analysis-icu && \ diff --git a/images/elasticsearch/7.5/Dockerfile b/images/elasticsearch/7.5/Dockerfile index e80fa5fd..8717d31e 100644 --- a/images/elasticsearch/7.5/Dockerfile +++ b/images/elasticsearch/7.5/Dockerfile @@ -1,5 +1,8 @@ FROM docker.elastic.co/elasticsearch/elasticsearch:7.5.2 +RUN yum -y install zip +RUN zip -q -d /usr/share/elasticsearch/lib/log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class + RUN echo "xpack.security.enabled: false" >> /usr/share/elasticsearch/config/elasticsearch.yml RUN echo "discovery.type: single-node" >> /usr/share/elasticsearch/config/elasticsearch.yml RUN bin/elasticsearch-plugin install -b analysis-icu && \ diff --git a/images/elasticsearch/7.6/Dockerfile b/images/elasticsearch/7.6/Dockerfile index b995359a..3e2ab137 100644 --- a/images/elasticsearch/7.6/Dockerfile +++ b/images/elasticsearch/7.6/Dockerfile @@ -1,5 +1,8 @@ FROM docker.elastic.co/elasticsearch/elasticsearch:7.6.2 +RUN yum -y install zip +RUN zip -q -d /usr/share/elasticsearch/lib/log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class + RUN echo "xpack.security.enabled: false" >> /usr/share/elasticsearch/config/elasticsearch.yml RUN echo "discovery.type: single-node" >> /usr/share/elasticsearch/config/elasticsearch.yml RUN bin/elasticsearch-plugin install -b analysis-icu && \ diff --git a/images/elasticsearch/7.7/Dockerfile b/images/elasticsearch/7.7/Dockerfile index c7764b51..8f41ffcd 100644 --- a/images/elasticsearch/7.7/Dockerfile +++ b/images/elasticsearch/7.7/Dockerfile @@ -1,5 +1,8 @@ FROM docker.elastic.co/elasticsearch/elasticsearch:7.7.1 +RUN yum -y install zip +RUN zip -q -d /usr/share/elasticsearch/lib/log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class + RUN echo "xpack.security.enabled: false" >> /usr/share/elasticsearch/config/elasticsearch.yml RUN echo "discovery.type: single-node" >> /usr/share/elasticsearch/config/elasticsearch.yml RUN bin/elasticsearch-plugin install -b analysis-icu && \ diff --git a/images/elasticsearch/7.9/Dockerfile b/images/elasticsearch/7.9/Dockerfile index ee279cf4..8b531a87 100644 --- a/images/elasticsearch/7.9/Dockerfile +++ b/images/elasticsearch/7.9/Dockerfile @@ -1,5 +1,8 @@ FROM docker.elastic.co/elasticsearch/elasticsearch:7.9.3 +RUN yum -y install zip +RUN zip -q -d /usr/share/elasticsearch/lib/log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class + RUN echo "xpack.security.enabled: false" >> /usr/share/elasticsearch/config/elasticsearch.yml RUN echo "discovery.type: single-node" >> /usr/share/elasticsearch/config/elasticsearch.yml RUN bin/elasticsearch-plugin install -b analysis-icu && \ diff --git a/images/elasticsearch/es/Dockerfile b/images/elasticsearch/es/Dockerfile index 3a2d34ec..3bdd5de1 100755 --- a/images/elasticsearch/es/Dockerfile +++ b/images/elasticsearch/es/Dockerfile @@ -1,5 +1,8 @@ FROM docker.elastic.co/elasticsearch/elasticsearch:{%version%} +RUN yum -y install zip +RUN zip -q -d /usr/share/elasticsearch/lib/log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class + RUN echo "xpack.security.enabled: false" >> /usr/share/elasticsearch/config/elasticsearch.yml {%single_node%} RUN bin/elasticsearch-plugin install -b analysis-icu && \ From ca59d434e1a3c62ad6e59187790270859b753c83 Mon Sep 17 00:00:00 2001 From: Bohdan Korablov Date: Tue, 21 Dec 2021 22:26:24 -0600 Subject: [PATCH 04/13] MCLOUD-8344: Add PHP 8.1 images, upgrade xDebug and xmlrpc (#80) --- dist/bin/magento-docker | 1 + images/php/7.2-cli/Dockerfile | 2 +- images/php/7.2-fpm/Dockerfile | 2 +- images/php/7.3-cli/Dockerfile | 2 +- images/php/7.3-fpm/Dockerfile | 2 +- images/php/7.4-cli/Dockerfile | 2 +- images/php/7.4-fpm/Dockerfile | 2 +- images/php/8.0-cli/Dockerfile | 4 +- images/php/8.0-fpm/Dockerfile | 4 +- images/php/8.1-cli/Dockerfile | 194 +++++++++++++++++++++++ images/php/8.1-cli/bin/cloud-build | 44 +++++ images/php/8.1-cli/bin/cloud-deploy | 37 +++++ images/php/8.1-cli/bin/cloud-post-deploy | 11 ++ images/php/8.1-cli/bin/ece-command | 7 + images/php/8.1-cli/bin/magento-command | 7 + images/php/8.1-cli/bin/magento-installer | 11 ++ images/php/8.1-cli/bin/mftf-command | 7 + images/php/8.1-cli/bin/run-cron | 3 + images/php/8.1-cli/bin/run-hooks | 61 +++++++ images/php/8.1-cli/docker-entrypoint.sh | 31 ++++ images/php/8.1-cli/etc/mail.ini | 2 + images/php/8.1-cli/etc/php-cli.ini | 10 ++ images/php/8.1-cli/etc/php-gnupg.ini | 1 + images/php/8.1-cli/etc/php-pcov.ini | 2 + images/php/8.1-cli/etc/php-xdebug.ini | 8 + images/php/8.1-fpm/Dockerfile | 154 ++++++++++++++++++ images/php/8.1-fpm/docker-entrypoint.sh | 24 +++ images/php/8.1-fpm/etc/mail.ini | 2 + images/php/8.1-fpm/etc/php-fpm.conf | 25 +++ images/php/8.1-fpm/etc/php-fpm.ini | 3 + images/php/8.1-fpm/etc/php-gnupg.ini | 1 + images/php/8.1-fpm/etc/php-pcov.ini | 2 + images/php/8.1-fpm/etc/php-xdebug.ini | 8 + src/Command/Image/GeneratePhp.php | 2 +- src/Compose/Php/ExtensionResolver.php | 4 +- src/Config/Source/CliSource.php | 11 -- src/Config/Source/CloudBaseSource.php | 2 +- src/Config/Source/CloudSource.php | 8 - 38 files changed, 670 insertions(+), 33 deletions(-) create mode 100644 images/php/8.1-cli/Dockerfile create mode 100644 images/php/8.1-cli/bin/cloud-build create mode 100644 images/php/8.1-cli/bin/cloud-deploy create mode 100644 images/php/8.1-cli/bin/cloud-post-deploy create mode 100644 images/php/8.1-cli/bin/ece-command create mode 100644 images/php/8.1-cli/bin/magento-command create mode 100644 images/php/8.1-cli/bin/magento-installer create mode 100644 images/php/8.1-cli/bin/mftf-command create mode 100644 images/php/8.1-cli/bin/run-cron create mode 100644 images/php/8.1-cli/bin/run-hooks create mode 100644 images/php/8.1-cli/docker-entrypoint.sh create mode 100644 images/php/8.1-cli/etc/mail.ini create mode 100644 images/php/8.1-cli/etc/php-cli.ini create mode 100644 images/php/8.1-cli/etc/php-gnupg.ini create mode 100644 images/php/8.1-cli/etc/php-pcov.ini create mode 100644 images/php/8.1-cli/etc/php-xdebug.ini create mode 100644 images/php/8.1-fpm/Dockerfile create mode 100644 images/php/8.1-fpm/docker-entrypoint.sh create mode 100644 images/php/8.1-fpm/etc/mail.ini create mode 100644 images/php/8.1-fpm/etc/php-fpm.conf create mode 100644 images/php/8.1-fpm/etc/php-fpm.ini create mode 100644 images/php/8.1-fpm/etc/php-gnupg.ini create mode 100644 images/php/8.1-fpm/etc/php-pcov.ini create mode 100644 images/php/8.1-fpm/etc/php-xdebug.ini diff --git a/dist/bin/magento-docker b/dist/bin/magento-docker index 3eb6c643..73ebe38f 100644 --- a/dist/bin/magento-docker +++ b/dist/bin/magento-docker @@ -25,6 +25,7 @@ USAGE="Magento Cloud Docker php 7.3 run a command in a PHP 7.3 container php 7.4 run a command in a PHP 7.4 container php 8.0 run a command in a PHP 8.0 container + php 8.1 run a command in a PHP 8.1 container copy-to copy to container (use --all or specific file/directory) copy-from copy from container (use --all or specific file/directory) fix-owns fix ownership to www:www diff --git a/images/php/7.2-cli/Dockerfile b/images/php/7.2-cli/Dockerfile index 47a9a6de..15ac4f63 100644 --- a/images/php/7.2-cli/Dockerfile +++ b/images/php/7.2-cli/Dockerfile @@ -131,7 +131,7 @@ RUN pecl install -o -f \ raphf \ redis \ ssh2-1.1.2 \ - xdebug-3.0.4 \ + xdebug-3.1.2 \ yaml RUN curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \ diff --git a/images/php/7.2-fpm/Dockerfile b/images/php/7.2-fpm/Dockerfile index a39b561a..c1ea502a 100644 --- a/images/php/7.2-fpm/Dockerfile +++ b/images/php/7.2-fpm/Dockerfile @@ -108,7 +108,7 @@ RUN pecl install -o -f \ raphf \ redis \ ssh2-1.1.2 \ - xdebug-3.0.4 \ + xdebug-3.1.2 \ yaml RUN curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \ diff --git a/images/php/7.3-cli/Dockerfile b/images/php/7.3-cli/Dockerfile index fe6cd9bf..071d19f5 100644 --- a/images/php/7.3-cli/Dockerfile +++ b/images/php/7.3-cli/Dockerfile @@ -128,7 +128,7 @@ RUN pecl install -o -f \ propro \ raphf \ redis \ - xdebug-3.0.4 \ + xdebug-3.1.2 \ yaml RUN curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \ diff --git a/images/php/7.3-fpm/Dockerfile b/images/php/7.3-fpm/Dockerfile index fc039d1b..df66d6e2 100644 --- a/images/php/7.3-fpm/Dockerfile +++ b/images/php/7.3-fpm/Dockerfile @@ -105,7 +105,7 @@ RUN pecl install -o -f \ propro \ raphf \ redis \ - xdebug-3.0.4 \ + xdebug-3.1.2 \ yaml RUN curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \ diff --git a/images/php/7.4-cli/Dockerfile b/images/php/7.4-cli/Dockerfile index 23d0e18f..b682e84a 100644 --- a/images/php/7.4-cli/Dockerfile +++ b/images/php/7.4-cli/Dockerfile @@ -118,7 +118,7 @@ RUN pecl install -o -f \ propro \ raphf \ redis \ - xdebug-3.0.4 \ + xdebug-3.1.2 \ yaml RUN curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \ diff --git a/images/php/7.4-fpm/Dockerfile b/images/php/7.4-fpm/Dockerfile index dceddd5c..5265740e 100644 --- a/images/php/7.4-fpm/Dockerfile +++ b/images/php/7.4-fpm/Dockerfile @@ -95,7 +95,7 @@ RUN pecl install -o -f \ propro \ raphf \ redis \ - xdebug-3.0.4 \ + xdebug-3.1.2 \ yaml RUN curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \ diff --git a/images/php/8.0-cli/Dockerfile b/images/php/8.0-cli/Dockerfile index d6fe9b5b..6688c3cc 100644 --- a/images/php/8.0-cli/Dockerfile +++ b/images/php/8.0-cli/Dockerfile @@ -110,8 +110,8 @@ RUN pecl install -o -f \ pcov \ raphf \ redis \ - xdebug-3.0.4 \ - xmlrpc-1.0.0RC2 \ + xdebug-3.1.2 \ + xmlrpc-1.0.0RC3 \ yaml RUN curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \ diff --git a/images/php/8.0-fpm/Dockerfile b/images/php/8.0-fpm/Dockerfile index d2c03887..de6f374d 100644 --- a/images/php/8.0-fpm/Dockerfile +++ b/images/php/8.0-fpm/Dockerfile @@ -87,8 +87,8 @@ RUN pecl install -o -f \ pcov \ raphf \ redis \ - xdebug-3.0.4 \ - xmlrpc-1.0.0RC2 \ + xdebug-3.1.2 \ + xmlrpc-1.0.0RC3 \ yaml RUN curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \ diff --git a/images/php/8.1-cli/Dockerfile b/images/php/8.1-cli/Dockerfile new file mode 100644 index 00000000..7e07449d --- /dev/null +++ b/images/php/8.1-cli/Dockerfile @@ -0,0 +1,194 @@ +# This file is automatically generated. Do not edit directly. # +FROM php:8.1-cli + +ARG COMPOSER_VERSION=1.10.22 +ARG MAGENTO_ROOT=/app +ARG COMPOSER_ALLOW_SUPERUSER=1 +ARG COMPOSER_HOME=/composer +ARG CRONTAB="" + +ENV COMPOSER_MEMORY_LIMIT -1 +ENV PHP_MEMORY_LIMIT -1 +ENV PHP_VALIDATE_TIMESTAMPS 1 +ENV DEBUG false +ENV MAGENTO_RUN_MODE production +ENV SENDMAIL_PATH /dev/null +ENV PHPRC ${MAGENTO_ROOT}/php.ini + +ENV PHP_EXTENSIONS bcmath bz2 calendar exif gd gettext intl mysqli opcache pdo_mysql redis soap sockets sysvmsg sysvsem sysvshm xsl zip pcntl + +# Configure Node.js version +RUN curl -sL https://deb.nodesource.com/setup_lts.x | bash + +# Install dependencies +RUN apt-get update \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends \ + apt-utils \ + cron \ + git \ + mariadb-client \ + nano \ + nodejs \ + python3 \ + python3-pip \ + redis-tools \ + sendmail-bin \ + sendmail \ + sudo \ + unzip \ + vim \ + openssh-client \ + libbz2-dev \ + libjpeg62-turbo-dev \ + libpng-dev \ + libfreetype6-dev \ + libgmp-dev \ + libgpgme11-dev \ + libicu-dev \ + libldap2-dev \ + libpcre3-dev \ + libpspell-dev \ + libtidy-dev \ + libxslt1-dev \ + libyaml-dev \ + libzip-dev \ + zip \ + && rm -rf /var/lib/apt/lists/* + +# Install PyYAML +RUN pip3 install --upgrade setuptools \ + && pip3 install pyyaml + +# Install Grunt +RUN npm install -g grunt-cli + +# Install MailHog +RUN curl -L -O https://github.com/mailhog/mhsendmail/releases/download/v0.2.0/mhsendmail_linux_amd64 \ + && sudo chmod +x mhsendmail_linux_amd64 \ + && sudo mv mhsendmail_linux_amd64 /usr/local/bin/mhsendmail + +# Configure the gd library +RUN docker-php-ext-configure \ + gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ +RUN docker-php-ext-configure \ + ldap --with-libdir=lib/x86_64-linux-gnu +RUN docker-php-ext-configure \ + opcache --enable-opcache + +# Install required PHP extensions +RUN docker-php-ext-install -j$(nproc) \ + bcmath \ + bz2 \ + calendar \ + exif \ + gd \ + gettext \ + gmp \ + intl \ + ldap \ + mysqli \ + opcache \ + pdo_mysql \ + pspell \ + shmop \ + soap \ + sockets \ + sysvmsg \ + sysvsem \ + sysvshm \ + tidy \ + xsl \ + zip \ + pcntl + +RUN pecl install -o -f \ + gnupg \ + mailparse \ + msgpack \ + oauth \ + pcov \ + raphf \ + redis \ + xdebug-3.1.2 \ + xmlrpc-1.0.0RC3 \ + yaml + +RUN curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \ + && 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 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 mkdir -p /tmp/zoo \ + && cd /tmp/zoo \ + && git clone https://github.com/php-zookeeper/php-zookeeper.git \ + && curl -LO https://archive.apache.org/dist/zookeeper/zookeeper-3.4.14/zookeeper-3.4.14.tar.gz \ + && tar -xf zookeeper-3.4.14.tar.gz \ + && cp zookeeper-3.4.14/zookeeper-client/zookeeper-client-c/generated/zookeeper.jute.h zookeeper-3.4.14/zookeeper-client/zookeeper-client-c/include \ + && cd zookeeper-3.4.14/zookeeper-client/zookeeper-client-c \ + && ./configure \ + && sed -i 's/CFLAGS = -g -O2 -D_GNU_SOURCE/CFLAGS = -g -O2 -D_GNU_SOURCE -Wno-error=format-overflow -Wno-error=stringop-truncation/g' Makefile \ + && make \ + && make install \ + && ldconfig \ + && cd /tmp/zoo/php-zookeeper \ + && phpize \ + && ./configure --with-libzookeeper-dir=../zookeeper-3.4.14/zookeeper-client/zookeeper-client-c \ + && make \ + && make install +RUN rm -f /usr/local/etc/php/conf.d/*sodium.ini \ + && rm -f /usr/local/lib/php/extensions/*/*sodium.so \ + && apt-get remove libsodium* -y \ + && mkdir -p /tmp/libsodium \ + && curl -sL https://github.com/jedisct1/libsodium/archive/1.0.18-RELEASE.tar.gz | tar xzf - -C /tmp/libsodium \ + && cd /tmp/libsodium/libsodium-1.0.18-RELEASE/ \ + && ./configure \ + && make && make check \ + && make install \ + && cd / \ + && rm -rf /tmp/libsodium \ + && pecl install -o -f libsodium + +ADD etc/php-cli.ini /usr/local/etc/php/conf.d/zz-magento.ini +ADD etc/php-xdebug.ini /usr/local/etc/php/conf.d/zz-xdebug-settings.ini +ADD etc/php-pcov.ini /usr/local/etc/php/conf.d/zz-pcov-settings.ini +ADD etc/mail.ini /usr/local/etc/php/conf.d/zz-mail.ini +ADD etc/php-gnupg.ini /usr/local/etc/php/conf.d/gnupg.ini + +# Get composer installed to /usr/local/bin/composer +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --version=${COMPOSER_VERSION} --filename=composer + +ADD bin/* /usr/local/bin/ + +RUN groupadd -g 1000 www && useradd -g 1000 -u 1000 -d ${MAGENTO_ROOT} -s /bin/bash www + +ADD docker-entrypoint.sh /docker-entrypoint.sh + +RUN ["chmod", "+x", \ + "/docker-entrypoint.sh", \ + "/usr/local/bin/magento-installer", \ + "/usr/local/bin/magento-command", \ + "/usr/local/bin/mftf-command", \ + "/usr/local/bin/ece-command", \ + "/usr/local/bin/cloud-build", \ + "/usr/local/bin/cloud-deploy", \ + "/usr/local/bin/cloud-post-deploy", \ + "/usr/local/bin/run-cron", \ + "/usr/local/bin/run-hooks" \ +] + +RUN mkdir -p ${MAGENTO_ROOT} + +VOLUME ${MAGENTO_ROOT} + +RUN chown -R www:www /usr/local /var/www /var/log /usr/local/etc/php/conf.d /etc/cron.d ${MAGENTO_ROOT} ${COMPOSER_HOME} +RUN if [[ ! -z "${CRONTAB}" ]]; then echo "${CRONTAB}" > /etc/cron.d/magento && touch /var/log/cron.log ; fi + +ENTRYPOINT ["/docker-entrypoint.sh"] + +WORKDIR ${MAGENTO_ROOT} + +USER root + +CMD ["bash"] diff --git a/images/php/8.1-cli/bin/cloud-build b/images/php/8.1-cli/bin/cloud-build new file mode 100644 index 00000000..bbd584c9 --- /dev/null +++ b/images/php/8.1-cli/bin/cloud-build @@ -0,0 +1,44 @@ +#!/bin/bash + +set -e + +[ "$DEBUG" = "true" ] && set -x + +RUN_HOOKS="run-hooks" + +if [ "$MAGENTO_RUN_MODE" == "production" ]; then + echo "Cleaning directories:" + + if [ "$INSTALLATION_TYPE" == "composer" ]; then + echo "Cleaning setup directory." + rm -rf $MAGENTO_ROOT/setup/* + fi + + echo "Cleaning vendor directory." + rm -rf $MAGENTO_ROOT/vendor/* + + echo "Cleaning generated directory." + rm -rf $MAGENTO_ROOT/generated/* + + echo "Removing app/etc/env.php file" + rm -f $MAGENTO_ROOT/app/etc/env.php +fi + +echo "Installing dependencies." + +composer --working-dir=$MAGENTO_ROOT install --no-suggest --no-ansi --no-interaction --no-progress --prefer-dist + +echo "Running \"build\" hook." + +$RUN_HOOKS build + +if [ "$MAGENTO_RUN_MODE" == "production" ]; then + echo "Setting file permissions." + + chown -R www:www $MAGENTO_ROOT + + find $MAGENTO_ROOT/pub -type f -exec chmod 664 {} \; + find $MAGENTO_ROOT/pub -type d -exec chmod 775 {} \; +fi + +echo "Building complete." diff --git a/images/php/8.1-cli/bin/cloud-deploy b/images/php/8.1-cli/bin/cloud-deploy new file mode 100644 index 00000000..f6b891bf --- /dev/null +++ b/images/php/8.1-cli/bin/cloud-deploy @@ -0,0 +1,37 @@ +#!/bin/bash + +set -e + +[ "$DEBUG" = "true" ] && set -x + +echo "Running \"deploy\" hook." + +run-hooks deploy + +# check that Varnish exists +if ( varnish=$(curl -I varnish 2>&1 | grep -i "magento2") ); then + minor_magento_version=$(magento-command --version | sed "s/Magento CLI version \([0-9]*\.[0-9]*\).*/\1/") + if [[ "$minor_magento_version" != "2.1" ]]; then + output=$(magento-command config:set system/full_page_cache/caching_application 2) + # as config:set does not return error code, we check output text to continue set varnish settings + if [[ $output == *"Value was saved"* ]]; then + echo "Setting Varnish for Magento FPC." + magento-command setup:config:set --http-cache-hosts=varnish -n + else + echo $output + fi + fi +fi + +# set developer mode if it is configured in $MAGENTO_RUN_MODE +if [ "$MAGENTO_RUN_MODE" == "developer" ]; then + output=$(magento-command deploy:mode:set developer) + if [[ $output == *"Enabled developer mode."* ]]; then + echo "Enabled developer mode." + else + echo $output + fi +fi + + +echo "Deployment finished." diff --git a/images/php/8.1-cli/bin/cloud-post-deploy b/images/php/8.1-cli/bin/cloud-post-deploy new file mode 100644 index 00000000..f5bb3956 --- /dev/null +++ b/images/php/8.1-cli/bin/cloud-post-deploy @@ -0,0 +1,11 @@ +#!/bin/bash + +set -e + +[ "$DEBUG" = "true" ] && set -x + +echo "Running \"post-deploy\" hook." + +run-hooks post_deploy + +echo "Post deployment finished." diff --git a/images/php/8.1-cli/bin/ece-command b/images/php/8.1-cli/bin/ece-command new file mode 100644 index 00000000..36d896c5 --- /dev/null +++ b/images/php/8.1-cli/bin/ece-command @@ -0,0 +1,7 @@ +#!/bin/bash + +[ "$DEBUG" = "true" ] && set -x + +ECE_COMMAND="$MAGENTO_ROOT/vendor/bin/ece-tools" + +exec $ECE_COMMAND "$@" diff --git a/images/php/8.1-cli/bin/magento-command b/images/php/8.1-cli/bin/magento-command new file mode 100644 index 00000000..8d439f7d --- /dev/null +++ b/images/php/8.1-cli/bin/magento-command @@ -0,0 +1,7 @@ +#!/bin/bash + +[ "$DEBUG" = "true" ] && set -x + +MAGENTO_COMMAND="php $MAGENTO_ROOT/bin/magento" + +exec $MAGENTO_COMMAND "$@" diff --git a/images/php/8.1-cli/bin/magento-installer b/images/php/8.1-cli/bin/magento-installer new file mode 100644 index 00000000..73645ab7 --- /dev/null +++ b/images/php/8.1-cli/bin/magento-installer @@ -0,0 +1,11 @@ +#!/bin/bash + +set -e + +[ "$DEBUG" = "true" ] && set -x + +BUILD_COMMAND="cloud-build" +DEPLOY_COMMAND="cloud-deploy" + +$BUILD_COMMAND +$DEPLOY_COMMAND diff --git a/images/php/8.1-cli/bin/mftf-command b/images/php/8.1-cli/bin/mftf-command new file mode 100644 index 00000000..88eaa1df --- /dev/null +++ b/images/php/8.1-cli/bin/mftf-command @@ -0,0 +1,7 @@ +#!/bin/bash + +[ "$DEBUG" = "true" ] && set -x + +MFTF_COMMAND="$MAGENTO_ROOT/vendor/bin/mftf" + +exec $MFTF_COMMAND "$@" diff --git a/images/php/8.1-cli/bin/run-cron b/images/php/8.1-cli/bin/run-cron new file mode 100644 index 00000000..f6554a5c --- /dev/null +++ b/images/php/8.1-cli/bin/run-cron @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +cron && tail -f -n0 /var/log/cron.log diff --git a/images/php/8.1-cli/bin/run-hooks b/images/php/8.1-cli/bin/run-hooks new file mode 100644 index 00000000..8ac215c9 --- /dev/null +++ b/images/php/8.1-cli/bin/run-hooks @@ -0,0 +1,61 @@ +#!/usr/bin/env python3 + +import os +import sys +import subprocess +import json +import base64 + +# Disable output buffering. +os.environ['PYTHONUNBUFFERED'] = "1" + +# The list of available hooks. +available_hooks = ["build", "deploy", "post_deploy"] + + +# Prints a message and returns an exit code. +def error_exit(msg, code=1): + print(msg) + sys.exit(code) + + +# Gets Magento root path. +def get_magento_root(): + try: + return str(os.environ['MAGENTO_ROOT']) + except KeyError: + error_exit('Environment variable MAGENTO_ROOT is not available') + + +# Gets set hooks by hook name. +def get_hooks(hook_name): + try: + application = str(os.environ['MAGENTO_CLOUD_APPLICATION']) + content = json.loads(base64.b64decode(application).decode("utf-8")) + + return content['hooks'][hook_name] + except Exception as exc: + error_exit("Cannot decode string: " + str(exc)) + + +# Main function. +def main(): + if len(sys.argv) != 2: + error_exit("Usage: run-hooks ") + + hook_name = str(sys.argv[1]) + if hook_name not in available_hooks: + error_exit("The hook \"" + hook_name + "\" is not available. The list of available hooks: " + ", ".join(available_hooks)) + + try: + subprocess.check_call( + get_hooks(hook_name), + shell=True, + cwd=get_magento_root() + ) + except subprocess.CalledProcessError as exc: + error_exit("returned non-zero exit status " + str(exc.returncode)) + + +if __name__ == '__main__': + main() diff --git a/images/php/8.1-cli/docker-entrypoint.sh b/images/php/8.1-cli/docker-entrypoint.sh new file mode 100644 index 00000000..1e025ca7 --- /dev/null +++ b/images/php/8.1-cli/docker-entrypoint.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +[ "$DEBUG" = "true" ] && set -x + +if [ ! -z "${CRONTAB}" ]; then + echo "${CRONTAB}" > /etc/cron.d/magento && touch /var/log/cron.log +fi + +PHP_EXT_DIR=/usr/local/etc/php/conf.d + +# Enable PHP extensions +PHP_EXT_COM_ON=docker-php-ext-enable + +[ -d ${PHP_EXT_DIR} ] && rm -f ${PHP_EXT_DIR}/docker-php-ext-*.ini + +if [ -x "$(command -v ${PHP_EXT_COM_ON})" ] && [ ! -z "${PHP_EXTENSIONS}" ]; then + ${PHP_EXT_COM_ON} ${PHP_EXTENSIONS} +fi + +# Configure composer +[ ! -z "${COMPOSER_VERSION}" ] && \ + composer self-update $COMPOSER_VERSION + +[ ! -z "${COMPOSER_GITHUB_TOKEN}" ] && \ + composer config --global github-oauth.github.com $COMPOSER_GITHUB_TOKEN + +[ ! -z "${COMPOSER_MAGENTO_USERNAME}" ] && \ + composer config --global http-basic.repo.magento.com \ + $COMPOSER_MAGENTO_USERNAME $COMPOSER_MAGENTO_PASSWORD + +exec "$@" diff --git a/images/php/8.1-cli/etc/mail.ini b/images/php/8.1-cli/etc/mail.ini new file mode 100644 index 00000000..c1620288 --- /dev/null +++ b/images/php/8.1-cli/etc/mail.ini @@ -0,0 +1,2 @@ +; Sendmail +sendmail_path = ${SENDMAIL_PATH} diff --git a/images/php/8.1-cli/etc/php-cli.ini b/images/php/8.1-cli/etc/php-cli.ini new file mode 100644 index 00000000..dfaf04e4 --- /dev/null +++ b/images/php/8.1-cli/etc/php-cli.ini @@ -0,0 +1,10 @@ +; php.ini +memory_limit = ${PHP_MEMORY_LIMIT} +zlib.output_compression = on +realpath_cache_size = 32k +realpath_cache_ttl = 7200 +always_populate_raw_post_data = -1 +max_input_vars = 10000 +session.gc_probability = 1 +opcache.enable = 1 +opcache.validate_timestamps = ${PHP_VALIDATE_TIMESTAMPS} diff --git a/images/php/8.1-cli/etc/php-gnupg.ini b/images/php/8.1-cli/etc/php-gnupg.ini new file mode 100644 index 00000000..f0f7e9a7 --- /dev/null +++ b/images/php/8.1-cli/etc/php-gnupg.ini @@ -0,0 +1 @@ +extension = gnupg.so diff --git a/images/php/8.1-cli/etc/php-pcov.ini b/images/php/8.1-cli/etc/php-pcov.ini new file mode 100644 index 00000000..a9f0145a --- /dev/null +++ b/images/php/8.1-cli/etc/php-pcov.ini @@ -0,0 +1,2 @@ +pcov.enabled = 1 +pcov.directory = ${MAGENTO_ROOT} diff --git a/images/php/8.1-cli/etc/php-xdebug.ini b/images/php/8.1-cli/etc/php-xdebug.ini new file mode 100644 index 00000000..57b1bd9f --- /dev/null +++ b/images/php/8.1-cli/etc/php-xdebug.ini @@ -0,0 +1,8 @@ +; Xdebug settings will only kick in if the Xdebug module is loaded +xdebug.mode = debug +xdebug.client_port = 9001 +xdebug.start_with_request = trigger +xdebug.discover_client_host = false +xdebug.scream = false +xdebug.show_local_vars = 1 +xdebug.idekey = PHPSTORM diff --git a/images/php/8.1-fpm/Dockerfile b/images/php/8.1-fpm/Dockerfile new file mode 100644 index 00000000..0d86943a --- /dev/null +++ b/images/php/8.1-fpm/Dockerfile @@ -0,0 +1,154 @@ +# This file is automatically generated. Do not edit directly. # +FROM php:8.1-fpm + +ARG MAGENTO_ROOT=/app + +ENV PHP_MEMORY_LIMIT 2G +ENV PHP_VALIDATE_TIMESTAMPS 1 +ENV DEBUG false +ENV MAGENTO_RUN_MODE production +ENV UPLOAD_MAX_FILESIZE 64M +ENV SENDMAIL_PATH /dev/null +ENV PHPRC ${MAGENTO_ROOT}/php.ini + +ENV PHP_EXTENSIONS bcmath bz2 calendar exif gd gettext intl mysqli opcache pdo_mysql redis soap sockets sysvmsg sysvsem sysvshm xsl zip pcntl + +# Install dependencies +RUN apt-get update \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends \ + apt-utils \ + sendmail-bin \ + sendmail \ + sudo \ + iproute2 \ + git \ + libbz2-dev \ + libjpeg62-turbo-dev \ + libpng-dev \ + libfreetype6-dev \ + libgmp-dev \ + libgpgme11-dev \ + libicu-dev \ + libldap2-dev \ + libpcre3-dev \ + libpspell-dev \ + libtidy-dev \ + libxslt1-dev \ + libyaml-dev \ + libzip-dev \ + zip \ + && rm -rf /var/lib/apt/lists/* + +# Install MailHog +RUN curl -L -O https://github.com/mailhog/mhsendmail/releases/download/v0.2.0/mhsendmail_linux_amd64 \ + && sudo chmod +x mhsendmail_linux_amd64 \ + && sudo mv mhsendmail_linux_amd64 /usr/local/bin/mhsendmail + +# Configure the gd library +RUN docker-php-ext-configure \ + gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ +RUN docker-php-ext-configure \ + ldap --with-libdir=lib/x86_64-linux-gnu +RUN docker-php-ext-configure \ + opcache --enable-opcache + +# Install required PHP extensions +RUN docker-php-ext-install -j$(nproc) \ + bcmath \ + bz2 \ + calendar \ + exif \ + gd \ + gettext \ + gmp \ + intl \ + ldap \ + mysqli \ + opcache \ + pdo_mysql \ + pspell \ + shmop \ + soap \ + sockets \ + sysvmsg \ + sysvsem \ + sysvshm \ + tidy \ + xsl \ + zip \ + pcntl + +RUN pecl install -o -f \ + gnupg \ + mailparse \ + msgpack \ + oauth \ + pcov \ + raphf \ + redis \ + xdebug-3.1.2 \ + xmlrpc-1.0.0RC3 \ + yaml + +RUN curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \ + && 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 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 mkdir -p /tmp/zoo \ + && cd /tmp/zoo \ + && git clone https://github.com/php-zookeeper/php-zookeeper.git \ + && curl -LO https://archive.apache.org/dist/zookeeper/zookeeper-3.4.14/zookeeper-3.4.14.tar.gz \ + && tar -xf zookeeper-3.4.14.tar.gz \ + && cp zookeeper-3.4.14/zookeeper-client/zookeeper-client-c/generated/zookeeper.jute.h zookeeper-3.4.14/zookeeper-client/zookeeper-client-c/include \ + && cd zookeeper-3.4.14/zookeeper-client/zookeeper-client-c \ + && ./configure \ + && sed -i 's/CFLAGS = -g -O2 -D_GNU_SOURCE/CFLAGS = -g -O2 -D_GNU_SOURCE -Wno-error=format-overflow -Wno-error=stringop-truncation/g' Makefile \ + && make \ + && make install \ + && ldconfig \ + && cd /tmp/zoo/php-zookeeper \ + && phpize \ + && ./configure --with-libzookeeper-dir=../zookeeper-3.4.14/zookeeper-client/zookeeper-client-c \ + && make \ + && make install +RUN rm -f /usr/local/etc/php/conf.d/*sodium.ini \ + && rm -f /usr/local/lib/php/extensions/*/*sodium.so \ + && apt-get remove libsodium* -y \ + && mkdir -p /tmp/libsodium \ + && curl -sL https://github.com/jedisct1/libsodium/archive/1.0.18-RELEASE.tar.gz | tar xzf - -C /tmp/libsodium \ + && cd /tmp/libsodium/libsodium-1.0.18-RELEASE/ \ + && ./configure \ + && make && make check \ + && make install \ + && cd / \ + && rm -rf /tmp/libsodium \ + && pecl install -o -f libsodium + +COPY etc/php-fpm.ini /usr/local/etc/php/conf.d/zz-magento.ini +COPY etc/php-xdebug.ini /usr/local/etc/php/conf.d/zz-xdebug-settings.ini +COPY etc/php-pcov.ini /usr/local/etc/php/conf.d/zz-pcov-settings.ini +COPY etc/mail.ini /usr/local/etc/php/conf.d/zz-mail.ini +COPY etc/php-fpm.conf /usr/local/etc/ +COPY etc/php-gnupg.ini /usr/local/etc/php/conf.d/gnupg.ini + +RUN groupadd -g 1000 www && useradd -g 1000 -u 1000 -d ${MAGENTO_ROOT} -s /bin/bash www + +COPY docker-entrypoint.sh /docker-entrypoint.sh +RUN ["chmod", "+x", "/docker-entrypoint.sh"] + +RUN mkdir -p ${MAGENTO_ROOT} + +VOLUME ${MAGENTO_ROOT} + +RUN chown -R www:www /usr/local /var/www /var/log /usr/local/etc/php/conf.d ${MAGENTO_ROOT} + +ENTRYPOINT ["/docker-entrypoint.sh"] + +WORKDIR ${MAGENTO_ROOT} + +USER root + +CMD ["php-fpm", "-R"] diff --git a/images/php/8.1-fpm/docker-entrypoint.sh b/images/php/8.1-fpm/docker-entrypoint.sh new file mode 100644 index 00000000..0c8c5c9c --- /dev/null +++ b/images/php/8.1-fpm/docker-entrypoint.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +[ "$DEBUG" = "true" ] && set -x + +PHP_EXT_DIR=/usr/local/etc/php/conf.d + +# Enable PHP extensions +PHP_EXT_COM_ON=docker-php-ext-enable + +[ -d ${PHP_EXT_DIR} ] && rm -f ${PHP_EXT_DIR}/docker-php-ext-*.ini + +if [ -x "$(command -v ${PHP_EXT_COM_ON})" ] && [ ! -z "${PHP_EXTENSIONS}" ]; then + ${PHP_EXT_COM_ON} ${PHP_EXTENSIONS} +fi + +# Set host.docker.internal if not available +HOST_NAME="host.docker.internal" +HOST_IP=$(php -r "putenv('RES_OPTIONS=retrans:1 retry:1 timeout:1 attempts:1'); echo gethostbyname('$HOST_NAME');") +if [[ "$HOST_IP" == "$HOST_NAME" ]]; then + HOST_IP=$(/sbin/ip route|awk '/default/ { print $3 }') + printf "\n%s %s\n" "$HOST_IP" "$HOST_NAME" >> /etc/hosts +fi + +exec "$@" diff --git a/images/php/8.1-fpm/etc/mail.ini b/images/php/8.1-fpm/etc/mail.ini new file mode 100644 index 00000000..c1620288 --- /dev/null +++ b/images/php/8.1-fpm/etc/mail.ini @@ -0,0 +1,2 @@ +; Sendmail +sendmail_path = ${SENDMAIL_PATH} diff --git a/images/php/8.1-fpm/etc/php-fpm.conf b/images/php/8.1-fpm/etc/php-fpm.conf new file mode 100644 index 00000000..d988b314 --- /dev/null +++ b/images/php/8.1-fpm/etc/php-fpm.conf @@ -0,0 +1,25 @@ +[global] + +error_log = /proc/self/fd/2 +daemonize = no + +[www] + +; if we send this to /proc/self/fd/1, it never appears +access.log = /proc/self/fd/2 + +listen = [::]:9000 + +pm = dynamic +pm.max_children = 10 +pm.start_servers = 4 +pm.min_spare_servers = 2 +pm.max_spare_servers = 6 +pm.status_path = /status + +clear_env = no + +env[MAGE_MODE] = $MAGENTO_RUN_MODE + +; Ensure worker stdout and stderr are sent to the main error log. +catch_workers_output = yes diff --git a/images/php/8.1-fpm/etc/php-fpm.ini b/images/php/8.1-fpm/etc/php-fpm.ini new file mode 100644 index 00000000..93a85129 --- /dev/null +++ b/images/php/8.1-fpm/etc/php-fpm.ini @@ -0,0 +1,3 @@ +memory_limit = ${PHP_MEMORY_LIMIT} +opcache.enable = 1 +opcache.validate_timestamps = ${PHP_VALIDATE_TIMESTAMPS} diff --git a/images/php/8.1-fpm/etc/php-gnupg.ini b/images/php/8.1-fpm/etc/php-gnupg.ini new file mode 100644 index 00000000..f0f7e9a7 --- /dev/null +++ b/images/php/8.1-fpm/etc/php-gnupg.ini @@ -0,0 +1 @@ +extension = gnupg.so diff --git a/images/php/8.1-fpm/etc/php-pcov.ini b/images/php/8.1-fpm/etc/php-pcov.ini new file mode 100644 index 00000000..a9f0145a --- /dev/null +++ b/images/php/8.1-fpm/etc/php-pcov.ini @@ -0,0 +1,2 @@ +pcov.enabled = 1 +pcov.directory = ${MAGENTO_ROOT} diff --git a/images/php/8.1-fpm/etc/php-xdebug.ini b/images/php/8.1-fpm/etc/php-xdebug.ini new file mode 100644 index 00000000..57b1bd9f --- /dev/null +++ b/images/php/8.1-fpm/etc/php-xdebug.ini @@ -0,0 +1,8 @@ +; Xdebug settings will only kick in if the Xdebug module is loaded +xdebug.mode = debug +xdebug.client_port = 9001 +xdebug.start_with_request = trigger +xdebug.discover_client_host = false +xdebug.scream = false +xdebug.show_local_vars = 1 +xdebug.idekey = PHPSTORM diff --git a/src/Command/Image/GeneratePhp.php b/src/Command/Image/GeneratePhp.php index c58c2652..5fb9e41c 100644 --- a/src/Command/Image/GeneratePhp.php +++ b/src/Command/Image/GeneratePhp.php @@ -26,7 +26,7 @@ class GeneratePhp extends Command { private const NAME = 'image:generate:php'; - private const SUPPORTED_VERSIONS = ['7.2', '7.3', '7.4', '8.0']; + private const SUPPORTED_VERSIONS = ['7.2', '7.3', '7.4', '8.0', '8.1']; private const EDITION_CLI = 'cli'; private const EDITION_FPM = 'fpm'; diff --git a/src/Compose/Php/ExtensionResolver.php b/src/Compose/Php/ExtensionResolver.php index 0757b4ed..d9d25788 100644 --- a/src/Compose/Php/ExtensionResolver.php +++ b/src/Compose/Php/ExtensionResolver.php @@ -412,14 +412,14 @@ public static function getConfig(): array 'xdebug' => [ '>=7.2' => [ self::EXTENSION_TYPE => self::EXTENSION_TYPE_PECL, - self::EXTENSION_PACKAGE_NAME => 'xdebug-3.0.4', + self::EXTENSION_PACKAGE_NAME => 'xdebug-3.1.2', ], ], 'xmlrpc' => [ '>=7.0 <8.0' => [self::EXTENSION_TYPE => self::EXTENSION_TYPE_CORE], '>=8.0' => [ self::EXTENSION_TYPE => self::EXTENSION_TYPE_PECL, - self::EXTENSION_PACKAGE_NAME => 'xmlrpc-1.0.0RC2', + self::EXTENSION_PACKAGE_NAME => 'xmlrpc-1.0.0RC3', ], ], 'xsl' => [ diff --git a/src/Config/Source/CliSource.php b/src/Config/Source/CliSource.php index 30cdd328..e57db64c 100644 --- a/src/Config/Source/CliSource.php +++ b/src/Config/Source/CliSource.php @@ -372,17 +372,6 @@ public function read(): Repository ]); } - $phpVersion = $this->input->getOption(self::OPTION_PHP); - if ($phpVersion) { - $variableName = Semver::satisfies($phpVersion, '<8.0') ? 'remote_host' : 'client_host'; - $repository->set([ - self::VARIABLES => [ - # Docker host for developer environments, can be different for your OS - 'XDEBUG_CONFIG' => $variableName.'=host.docker.internal', - ] - ]); - } - return $repository; } } diff --git a/src/Config/Source/CloudBaseSource.php b/src/Config/Source/CloudBaseSource.php index 98c7860d..4887f9f9 100644 --- a/src/Config/Source/CloudBaseSource.php +++ b/src/Config/Source/CloudBaseSource.php @@ -58,7 +58,7 @@ public function read(): Repository # Name of your server in IDE 'PHP_IDE_CONFIG' => 'serverName=magento_cloud_docker', # Docker host for developer environments, can be different for your OS - 'XDEBUG_CONFIG' => 'remote_host=host.docker.internal', + 'XDEBUG_CONFIG' => 'client_host=host.docker.internal', ] ]); diff --git a/src/Config/Source/CloudSource.php b/src/Config/Source/CloudSource.php index 4cbe421e..2d2ddc8d 100644 --- a/src/Config/Source/CloudSource.php +++ b/src/Config/Source/CloudSource.php @@ -141,14 +141,6 @@ public function read(): Repository ); $repository->set(self::HOOKS, $appConfig['hooks'] ?? []); - $variableName = Semver::satisfies($version, '<8.0') ? 'remote_host' : 'client_host'; - $repository->set([ - self::VARIABLES => [ - # Docker host for developer environments, can be different for your OS - 'XDEBUG_CONFIG' => $variableName.'=host.docker.internal', - ] - ]); - return $repository; } From fea4624dbda23a44d94d5e29cc9ead30ff0cedf4 Mon Sep 17 00:00:00 2001 From: Bohdan Korablov Date: Wed, 22 Dec 2021 11:43:26 -0600 Subject: [PATCH 05/13] MCLOUD-8350: ES & OS improvements (#79) --- images/elasticsearch/5.2/Dockerfile | 16 ------- images/elasticsearch/5.2/docker-entrypoint.sh | 42 ------------------- images/elasticsearch/6.5/Dockerfile | 7 +++- images/elasticsearch/6.8/Dockerfile | 7 +++- images/elasticsearch/7.11/Dockerfile | 7 +++- images/elasticsearch/7.5/Dockerfile | 7 +++- images/elasticsearch/7.6/Dockerfile | 7 +++- images/elasticsearch/7.7/Dockerfile | 7 +++- images/elasticsearch/7.9/Dockerfile | 7 +++- images/elasticsearch/es/Dockerfile | 7 +++- images/opensearch/1.1/Dockerfile | 8 ++++ images/opensearch/1.2/Dockerfile | 21 ++++++++++ images/opensearch/1.2/docker-entrypoint.sh | 12 ++++++ .../1.2}/docker-healthcheck.sh | 2 +- images/opensearch/os/Dockerfile | 10 ++++- src/Command/Image/GenerateOs.php | 3 ++ .../Acceptance/Elasticsearch72Cest.php | 2 +- .../Functional/Acceptance/Services72Cest.php | 10 ++--- src/Test/Integration/BuildComposeTest.php | 2 +- 19 files changed, 101 insertions(+), 83 deletions(-) delete mode 100644 images/elasticsearch/5.2/Dockerfile delete mode 100755 images/elasticsearch/5.2/docker-entrypoint.sh create mode 100644 images/opensearch/1.2/Dockerfile create mode 100755 images/opensearch/1.2/docker-entrypoint.sh rename images/{elasticsearch/5.2 => opensearch/1.2}/docker-healthcheck.sh (73%) diff --git a/images/elasticsearch/5.2/Dockerfile b/images/elasticsearch/5.2/Dockerfile deleted file mode 100644 index 4353ae18..00000000 --- a/images/elasticsearch/5.2/Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM elasticsearch:5.2.2 - -RUN apt update || true \ - && apt install zip -RUN zip -q -d /usr/share/elasticsearch/lib/log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class - -RUN bin/elasticsearch-plugin install analysis-icu && \ - bin/elasticsearch-plugin install analysis-phonetic - -ADD docker-healthcheck.sh /docker-healthcheck.sh - -ADD docker-entrypoint.sh /docker-entrypoint.sh - -HEALTHCHECK --retries=3 CMD ["bash", "/docker-healthcheck.sh"] - -EXPOSE 9200 9300 diff --git a/images/elasticsearch/5.2/docker-entrypoint.sh b/images/elasticsearch/5.2/docker-entrypoint.sh deleted file mode 100755 index 19fce400..00000000 --- a/images/elasticsearch/5.2/docker-entrypoint.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -set -e - -# Add elasticsearch as command if needed -if [ "${1:0:1}" = '-' ]; then - set -- elasticsearch "$@" -fi - -# Drop root privileges if we are running elasticsearch -# allow the container to be started with `--user` -if [ "$1" = 'elasticsearch' -a "$(id -u)" = '0' ]; then - # Change the ownership of user-mutable directories to elasticsearch - for path in \ - /usr/share/elasticsearch/data \ - /usr/share/elasticsearch/logs \ - ; do - chown -R elasticsearch:elasticsearch "$path" - done - - es_opts='' - - while IFS='=' read -r envvar_key envvar_value - do - # Elasticsearch env vars need to have at least two dot separated lowercase words, e.g. `cluster.name` - if [[ "$envvar_key" =~ ^[a-z]+\.[a-z]+ ]] - then - if [[ ! -z $envvar_value ]]; then - es_opt="-E${envvar_key}=${envvar_value}" - es_opts+=" ${es_opt}" - fi - fi - done < <(env) - - set -- gosu elasticsearch "$@" ${es_opts} - #exec gosu elasticsearch "$BASH_SOURCE" "$@" -fi - -# As argument is not related to elasticsearch, -# then assume that user wants to run his own process, -# for example a `bash` shell to explore this image -exec "$@" diff --git a/images/elasticsearch/6.5/Dockerfile b/images/elasticsearch/6.5/Dockerfile index 5b7c0a7a..26b9f815 100644 --- a/images/elasticsearch/6.5/Dockerfile +++ b/images/elasticsearch/6.5/Dockerfile @@ -1,7 +1,10 @@ FROM docker.elastic.co/elasticsearch/elasticsearch:6.5.4 -RUN yum -y install zip -RUN zip -q -d /usr/share/elasticsearch/lib/log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class +RUN yum -y install zip && \ + zip -q -d /usr/share/elasticsearch/lib/log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class && \ + yum remove -y zip && \ + yum -y clean all && \ + rm -rf /var/cache RUN echo "xpack.security.enabled: false" >> /usr/share/elasticsearch/config/elasticsearch.yml diff --git a/images/elasticsearch/6.8/Dockerfile b/images/elasticsearch/6.8/Dockerfile index aa131c97..64f973a6 100644 --- a/images/elasticsearch/6.8/Dockerfile +++ b/images/elasticsearch/6.8/Dockerfile @@ -1,7 +1,10 @@ FROM docker.elastic.co/elasticsearch/elasticsearch:6.8.15 -RUN yum -y install zip -RUN zip -q -d /usr/share/elasticsearch/lib/log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class +RUN yum -y install zip && \ + zip -q -d /usr/share/elasticsearch/lib/log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class && \ + yum remove -y zip && \ + yum -y clean all && \ + rm -rf /var/cache RUN echo "xpack.security.enabled: false" >> /usr/share/elasticsearch/config/elasticsearch.yml RUN echo "discovery.type: single-node" >> /usr/share/elasticsearch/config/elasticsearch.yml diff --git a/images/elasticsearch/7.11/Dockerfile b/images/elasticsearch/7.11/Dockerfile index a25c50c2..1be2a941 100644 --- a/images/elasticsearch/7.11/Dockerfile +++ b/images/elasticsearch/7.11/Dockerfile @@ -1,7 +1,10 @@ FROM docker.elastic.co/elasticsearch/elasticsearch:7.11.2 -RUN yum -y install zip -RUN zip -q -d /usr/share/elasticsearch/lib/log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class +RUN yum -y install zip && \ + zip -q -d /usr/share/elasticsearch/lib/log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class && \ + yum remove -y zip && \ + yum -y clean all && \ + rm -rf /var/cache RUN echo "xpack.security.enabled: false" >> /usr/share/elasticsearch/config/elasticsearch.yml RUN echo "discovery.type: single-node" >> /usr/share/elasticsearch/config/elasticsearch.yml diff --git a/images/elasticsearch/7.5/Dockerfile b/images/elasticsearch/7.5/Dockerfile index 8717d31e..a4d9a188 100644 --- a/images/elasticsearch/7.5/Dockerfile +++ b/images/elasticsearch/7.5/Dockerfile @@ -1,7 +1,10 @@ FROM docker.elastic.co/elasticsearch/elasticsearch:7.5.2 -RUN yum -y install zip -RUN zip -q -d /usr/share/elasticsearch/lib/log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class +RUN yum -y install zip && \ + zip -q -d /usr/share/elasticsearch/lib/log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class && \ + yum remove -y zip && \ + yum -y clean all && \ + rm -rf /var/cache RUN echo "xpack.security.enabled: false" >> /usr/share/elasticsearch/config/elasticsearch.yml RUN echo "discovery.type: single-node" >> /usr/share/elasticsearch/config/elasticsearch.yml diff --git a/images/elasticsearch/7.6/Dockerfile b/images/elasticsearch/7.6/Dockerfile index 3e2ab137..1f009db6 100644 --- a/images/elasticsearch/7.6/Dockerfile +++ b/images/elasticsearch/7.6/Dockerfile @@ -1,7 +1,10 @@ FROM docker.elastic.co/elasticsearch/elasticsearch:7.6.2 -RUN yum -y install zip -RUN zip -q -d /usr/share/elasticsearch/lib/log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class +RUN yum -y install zip && \ + zip -q -d /usr/share/elasticsearch/lib/log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class && \ + yum remove -y zip && \ + yum -y clean all && \ + rm -rf /var/cache RUN echo "xpack.security.enabled: false" >> /usr/share/elasticsearch/config/elasticsearch.yml RUN echo "discovery.type: single-node" >> /usr/share/elasticsearch/config/elasticsearch.yml diff --git a/images/elasticsearch/7.7/Dockerfile b/images/elasticsearch/7.7/Dockerfile index 8f41ffcd..4a848b83 100644 --- a/images/elasticsearch/7.7/Dockerfile +++ b/images/elasticsearch/7.7/Dockerfile @@ -1,7 +1,10 @@ FROM docker.elastic.co/elasticsearch/elasticsearch:7.7.1 -RUN yum -y install zip -RUN zip -q -d /usr/share/elasticsearch/lib/log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class +RUN yum -y install zip && \ + zip -q -d /usr/share/elasticsearch/lib/log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class && \ + yum remove -y zip && \ + yum -y clean all && \ + rm -rf /var/cache RUN echo "xpack.security.enabled: false" >> /usr/share/elasticsearch/config/elasticsearch.yml RUN echo "discovery.type: single-node" >> /usr/share/elasticsearch/config/elasticsearch.yml diff --git a/images/elasticsearch/7.9/Dockerfile b/images/elasticsearch/7.9/Dockerfile index 8b531a87..ffbc60b0 100644 --- a/images/elasticsearch/7.9/Dockerfile +++ b/images/elasticsearch/7.9/Dockerfile @@ -1,7 +1,10 @@ FROM docker.elastic.co/elasticsearch/elasticsearch:7.9.3 -RUN yum -y install zip -RUN zip -q -d /usr/share/elasticsearch/lib/log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class +RUN yum -y install zip && \ + zip -q -d /usr/share/elasticsearch/lib/log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class && \ + yum remove -y zip && \ + yum -y clean all && \ + rm -rf /var/cache RUN echo "xpack.security.enabled: false" >> /usr/share/elasticsearch/config/elasticsearch.yml RUN echo "discovery.type: single-node" >> /usr/share/elasticsearch/config/elasticsearch.yml diff --git a/images/elasticsearch/es/Dockerfile b/images/elasticsearch/es/Dockerfile index 3bdd5de1..9d87e3f4 100755 --- a/images/elasticsearch/es/Dockerfile +++ b/images/elasticsearch/es/Dockerfile @@ -1,7 +1,10 @@ FROM docker.elastic.co/elasticsearch/elasticsearch:{%version%} -RUN yum -y install zip -RUN zip -q -d /usr/share/elasticsearch/lib/log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class +RUN yum -y install zip && \ + zip -q -d /usr/share/elasticsearch/lib/log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class && \ + yum remove -y zip && \ + yum -y clean all && \ + rm -rf /var/cache RUN echo "xpack.security.enabled: false" >> /usr/share/elasticsearch/config/elasticsearch.yml {%single_node%} diff --git a/images/opensearch/1.1/Dockerfile b/images/opensearch/1.1/Dockerfile index 8d51cc6a..10c00c79 100644 --- a/images/opensearch/1.1/Dockerfile +++ b/images/opensearch/1.1/Dockerfile @@ -1,5 +1,13 @@ FROM opensearchproject/opensearch:1.1.0 +USER root +RUN yum -y install zip && \ + zip -q -d /usr/share/opensearch/lib/log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class && \ + yum remove -y zip && \ + yum -y clean all && \ + rm -rf /var/cache +USER opensearch + RUN bin/opensearch-plugin install -b analysis-icu && \ bin/opensearch-plugin install -b analysis-phonetic diff --git a/images/opensearch/1.2/Dockerfile b/images/opensearch/1.2/Dockerfile new file mode 100644 index 00000000..57f343e5 --- /dev/null +++ b/images/opensearch/1.2/Dockerfile @@ -0,0 +1,21 @@ +FROM opensearchproject/opensearch:1.2.1 + +USER root +RUN yum -y install zip && \ + zip -q -d /usr/share/opensearch/lib/log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class && \ + yum remove -y zip && \ + yum -y clean all && \ + rm -rf /var/cache +USER opensearch + +RUN bin/opensearch-plugin install -b analysis-icu && \ + bin/opensearch-plugin install -b analysis-phonetic + +ADD docker-healthcheck.sh /docker-healthcheck.sh +ADD docker-entrypoint.sh /docker-entrypoint.sh + +HEALTHCHECK --retries=3 CMD ["bash", "/docker-healthcheck.sh"] + +ENTRYPOINT ["/docker-entrypoint.sh"] + +EXPOSE 9200 9300 diff --git a/images/opensearch/1.2/docker-entrypoint.sh b/images/opensearch/1.2/docker-entrypoint.sh new file mode 100755 index 00000000..ad80b15a --- /dev/null +++ b/images/opensearch/1.2/docker-entrypoint.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -eo pipefail + +if [[ -n "$OS_PLUGINS" ]]; then + echo "Installing plugins: $OS_PLUGINS" + for PLUGIN in $OS_PLUGINS + do + ./bin/opensearch-plugin install -b "$PLUGIN" + done +fi + +/bin/bash /usr/share/opensearch/opensearch-docker-entrypoint.sh diff --git a/images/elasticsearch/5.2/docker-healthcheck.sh b/images/opensearch/1.2/docker-healthcheck.sh similarity index 73% rename from images/elasticsearch/5.2/docker-healthcheck.sh rename to images/opensearch/1.2/docker-healthcheck.sh index a6d853cf..4081bbb2 100644 --- a/images/elasticsearch/5.2/docker-healthcheck.sh +++ b/images/opensearch/1.2/docker-healthcheck.sh @@ -1,7 +1,7 @@ #!/bin/bash set -eo pipefail -if health="$(curl -fsSL "http://${ES_HOST:-elasticsearch}:${ES_PORT:-9200}/_cat/health?h=status")"; then +if health="$(curl -fsSL "http://${OS_HOST:-opensearch}:${OS_HOST:-9200}/_cat/health?h=status")"; then health="$(echo "$health" | sed -r 's/^[[:space:]]+|[[:space:]]+$//g')" # trim whitespace (otherwise we'll have "green ") if [ "$health" = 'green' ] || [ "$health" = 'yellow' ]; then exit 0 diff --git a/images/opensearch/os/Dockerfile b/images/opensearch/os/Dockerfile index 8d51cc6a..c408696e 100755 --- a/images/opensearch/os/Dockerfile +++ b/images/opensearch/os/Dockerfile @@ -1,4 +1,12 @@ -FROM opensearchproject/opensearch:1.1.0 +FROM opensearchproject/opensearch:{%version%} + +USER root +RUN yum -y install zip && \ + zip -q -d /usr/share/opensearch/lib/log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class && \ + yum remove -y zip && \ + yum -y clean all && \ + rm -rf /var/cache +USER opensearch RUN bin/opensearch-plugin install -b analysis-icu && \ bin/opensearch-plugin install -b analysis-phonetic diff --git a/src/Command/Image/GenerateOs.php b/src/Command/Image/GenerateOs.php index 9fbb599f..4b277b02 100644 --- a/src/Command/Image/GenerateOs.php +++ b/src/Command/Image/GenerateOs.php @@ -31,6 +31,9 @@ class GenerateOs extends Command '1.1' => [ 'real-version' => '1.1.0', ], + '1.2' => [ + 'real-version' => '1.2.1', + ], ]; /** diff --git a/src/Test/Functional/Acceptance/Elasticsearch72Cest.php b/src/Test/Functional/Acceptance/Elasticsearch72Cest.php index eb8b6000..77cbccce 100644 --- a/src/Test/Functional/Acceptance/Elasticsearch72Cest.php +++ b/src/Test/Functional/Acceptance/Elasticsearch72Cest.php @@ -24,7 +24,7 @@ protected function dataProvider(): array { return [ [ - 'version' => '5.2', + 'version' => '6.5', 'xms' => '516m', 'xmx' => '516m', 'param' => [ diff --git a/src/Test/Functional/Acceptance/Services72Cest.php b/src/Test/Functional/Acceptance/Services72Cest.php index 379e4466..f6c54b7c 100644 --- a/src/Test/Functional/Acceptance/Services72Cest.php +++ b/src/Test/Functional/Acceptance/Services72Cest.php @@ -15,7 +15,7 @@ class Services72Cest extends ServicesCest /** * Template version for testing */ - protected const TEMPLATE_VERSION = '2.3.0'; + protected const TEMPLATE_VERSION = '2.3.1'; /** * @return array @@ -30,7 +30,7 @@ protected function servicesDataProvider(): array 'magento/magento-cloud-docker-varnish:6.2-1.3', 'magento/magento-cloud-docker-nginx:1.19-1.3', 'magento/magento-cloud-docker-php:7.2-fpm-1.3', - 'magento/magento-cloud-docker-elasticsearch:5.2-1.3', + 'magento/magento-cloud-docker-elasticsearch:6.5-1.3', 'mariadb:10.2' ], 'notExpectedResult' => ['rabbitmq', 'selenium/standalone-chrome:latest', 'cron'], @@ -42,7 +42,7 @@ protected function servicesDataProvider(): array 'magento/magento-cloud-docker-varnish:6.2-1.3', 'magento/magento-cloud-docker-nginx:1.19-1.3', 'magento/magento-cloud-docker-php:7.4-fpm-1.3', - 'magento/magento-cloud-docker-elasticsearch:5.2-1.3', + 'magento/magento-cloud-docker-elasticsearch:6.5-1.3', 'mariadb:10.1', 'rabbitmq:3.5' ], @@ -55,7 +55,7 @@ protected function servicesDataProvider(): array 'magento/magento-cloud-docker-varnish:6.2-1.3', 'magento/magento-cloud-docker-nginx:1.19-1.3', 'magento/magento-cloud-docker-php:7.2-fpm-1.3', - 'magento/magento-cloud-docker-elasticsearch:5.2-1.3', + 'magento/magento-cloud-docker-elasticsearch:6.5-1.3', 'mariadb:10.2', 'rabbitmq:3.6' ], @@ -68,7 +68,7 @@ protected function servicesDataProvider(): array 'magento/magento-cloud-docker-varnish:6.2-1.3', 'magento/magento-cloud-docker-nginx:1.19-1.3', 'magento/magento-cloud-docker-php:7.2-fpm-1.3', - 'magento/magento-cloud-docker-elasticsearch:5.2-1.3', + 'magento/magento-cloud-docker-elasticsearch:6.5-1.3', 'mariadb:10.2', 'cron', 'selenium/standalone-chrome:latest' diff --git a/src/Test/Integration/BuildComposeTest.php b/src/Test/Integration/BuildComposeTest.php index bc1d294c..707c262f 100644 --- a/src/Test/Integration/BuildComposeTest.php +++ b/src/Test/Integration/BuildComposeTest.php @@ -137,7 +137,7 @@ public function buildDataProvider(): array [CliSource::OPTION_WITH_CRON, true], [CliSource::OPTION_WITH_ZOOKEEPER, true], [CliSource::OPTION_WITH_XDEBUG, true], - [CliSource::OPTION_ES, '5.2'], + [CliSource::OPTION_ES, '6.5'], [CliSource::OPTION_OS, '1.2'], [CliSource::OPTION_NO_ES, true], [CliSource::OPTION_NO_OS, true], From ccc53e362df42696525bc7608776be9aea116e64 Mon Sep 17 00:00:00 2001 From: Bohdan Korablov Date: Thu, 23 Dec 2021 12:04:23 -0600 Subject: [PATCH 06/13] MCLOUD-8364: enable sodium by default (#81) --- images/php/7.2-cli/Dockerfile | 2 +- images/php/7.2-fpm/Dockerfile | 2 +- images/php/7.3-cli/Dockerfile | 2 +- images/php/7.3-fpm/Dockerfile | 2 +- images/php/7.4-cli/Dockerfile | 2 +- images/php/7.4-fpm/Dockerfile | 2 +- images/php/8.0-cli/Dockerfile | 2 +- images/php/8.0-fpm/Dockerfile | 2 +- images/php/8.1-cli/Dockerfile | 2 +- images/php/8.1-fpm/Dockerfile | 2 +- src/Command/Image/GeneratePhp.php | 1 + src/Compose/Php/ExtensionResolver.php | 2 +- 12 files changed, 12 insertions(+), 11 deletions(-) diff --git a/images/php/7.2-cli/Dockerfile b/images/php/7.2-cli/Dockerfile index 15ac4f63..46132c4d 100644 --- a/images/php/7.2-cli/Dockerfile +++ b/images/php/7.2-cli/Dockerfile @@ -15,7 +15,7 @@ ENV MAGENTO_RUN_MODE production ENV SENDMAIL_PATH /dev/null ENV PHPRC ${MAGENTO_ROOT}/php.ini -ENV PHP_EXTENSIONS bcmath bz2 calendar exif gd gettext intl mysqli opcache pdo_mysql redis soap sockets sysvmsg sysvsem sysvshm xsl zip pcntl +ENV PHP_EXTENSIONS bcmath bz2 calendar exif gd gettext intl mysqli opcache pdo_mysql redis soap sockets sodium sysvmsg sysvsem sysvshm xsl zip pcntl # Configure Node.js version RUN curl -sL https://deb.nodesource.com/setup_lts.x | bash diff --git a/images/php/7.2-fpm/Dockerfile b/images/php/7.2-fpm/Dockerfile index c1ea502a..d37fb801 100644 --- a/images/php/7.2-fpm/Dockerfile +++ b/images/php/7.2-fpm/Dockerfile @@ -11,7 +11,7 @@ ENV UPLOAD_MAX_FILESIZE 64M ENV SENDMAIL_PATH /dev/null ENV PHPRC ${MAGENTO_ROOT}/php.ini -ENV PHP_EXTENSIONS bcmath bz2 calendar exif gd gettext intl mysqli opcache pdo_mysql redis soap sockets sysvmsg sysvsem sysvshm xsl zip pcntl +ENV PHP_EXTENSIONS bcmath bz2 calendar exif gd gettext intl mysqli opcache pdo_mysql redis soap sockets sodium sysvmsg sysvsem sysvshm xsl zip pcntl # Install dependencies RUN apt-get update \ diff --git a/images/php/7.3-cli/Dockerfile b/images/php/7.3-cli/Dockerfile index 071d19f5..24c73db1 100644 --- a/images/php/7.3-cli/Dockerfile +++ b/images/php/7.3-cli/Dockerfile @@ -15,7 +15,7 @@ ENV MAGENTO_RUN_MODE production ENV SENDMAIL_PATH /dev/null ENV PHPRC ${MAGENTO_ROOT}/php.ini -ENV PHP_EXTENSIONS bcmath bz2 calendar exif gd gettext intl mysqli opcache pdo_mysql redis soap sockets sysvmsg sysvsem sysvshm xsl zip pcntl +ENV PHP_EXTENSIONS bcmath bz2 calendar exif gd gettext intl mysqli opcache pdo_mysql redis soap sockets sodium sysvmsg sysvsem sysvshm xsl zip pcntl # Configure Node.js version RUN curl -sL https://deb.nodesource.com/setup_lts.x | bash diff --git a/images/php/7.3-fpm/Dockerfile b/images/php/7.3-fpm/Dockerfile index df66d6e2..d6a3389b 100644 --- a/images/php/7.3-fpm/Dockerfile +++ b/images/php/7.3-fpm/Dockerfile @@ -11,7 +11,7 @@ ENV UPLOAD_MAX_FILESIZE 64M ENV SENDMAIL_PATH /dev/null ENV PHPRC ${MAGENTO_ROOT}/php.ini -ENV PHP_EXTENSIONS bcmath bz2 calendar exif gd gettext intl mysqli opcache pdo_mysql redis soap sockets sysvmsg sysvsem sysvshm xsl zip pcntl +ENV PHP_EXTENSIONS bcmath bz2 calendar exif gd gettext intl mysqli opcache pdo_mysql redis soap sockets sodium sysvmsg sysvsem sysvshm xsl zip pcntl # Install dependencies RUN apt-get update \ diff --git a/images/php/7.4-cli/Dockerfile b/images/php/7.4-cli/Dockerfile index b682e84a..18d45343 100644 --- a/images/php/7.4-cli/Dockerfile +++ b/images/php/7.4-cli/Dockerfile @@ -15,7 +15,7 @@ ENV MAGENTO_RUN_MODE production ENV SENDMAIL_PATH /dev/null ENV PHPRC ${MAGENTO_ROOT}/php.ini -ENV PHP_EXTENSIONS bcmath bz2 calendar exif gd gettext intl mysqli opcache pdo_mysql redis soap sockets sysvmsg sysvsem sysvshm xsl zip pcntl +ENV PHP_EXTENSIONS bcmath bz2 calendar exif gd gettext intl mysqli opcache pdo_mysql redis soap sockets sodium sysvmsg sysvsem sysvshm xsl zip pcntl # Configure Node.js version RUN curl -sL https://deb.nodesource.com/setup_lts.x | bash diff --git a/images/php/7.4-fpm/Dockerfile b/images/php/7.4-fpm/Dockerfile index 5265740e..23cc3313 100644 --- a/images/php/7.4-fpm/Dockerfile +++ b/images/php/7.4-fpm/Dockerfile @@ -11,7 +11,7 @@ ENV UPLOAD_MAX_FILESIZE 64M ENV SENDMAIL_PATH /dev/null ENV PHPRC ${MAGENTO_ROOT}/php.ini -ENV PHP_EXTENSIONS bcmath bz2 calendar exif gd gettext intl mysqli opcache pdo_mysql redis soap sockets sysvmsg sysvsem sysvshm xsl zip pcntl +ENV PHP_EXTENSIONS bcmath bz2 calendar exif gd gettext intl mysqli opcache pdo_mysql redis soap sockets sodium sysvmsg sysvsem sysvshm xsl zip pcntl # Install dependencies RUN apt-get update \ diff --git a/images/php/8.0-cli/Dockerfile b/images/php/8.0-cli/Dockerfile index 6688c3cc..b2c8a471 100644 --- a/images/php/8.0-cli/Dockerfile +++ b/images/php/8.0-cli/Dockerfile @@ -15,7 +15,7 @@ ENV MAGENTO_RUN_MODE production ENV SENDMAIL_PATH /dev/null ENV PHPRC ${MAGENTO_ROOT}/php.ini -ENV PHP_EXTENSIONS bcmath bz2 calendar exif gd gettext intl mysqli opcache pdo_mysql redis soap sockets sysvmsg sysvsem sysvshm xsl zip pcntl +ENV PHP_EXTENSIONS bcmath bz2 calendar exif gd gettext intl mysqli opcache pdo_mysql redis soap sockets sodium sysvmsg sysvsem sysvshm xsl zip pcntl # Configure Node.js version RUN curl -sL https://deb.nodesource.com/setup_lts.x | bash diff --git a/images/php/8.0-fpm/Dockerfile b/images/php/8.0-fpm/Dockerfile index de6f374d..5bb44dc0 100644 --- a/images/php/8.0-fpm/Dockerfile +++ b/images/php/8.0-fpm/Dockerfile @@ -11,7 +11,7 @@ ENV UPLOAD_MAX_FILESIZE 64M ENV SENDMAIL_PATH /dev/null ENV PHPRC ${MAGENTO_ROOT}/php.ini -ENV PHP_EXTENSIONS bcmath bz2 calendar exif gd gettext intl mysqli opcache pdo_mysql redis soap sockets sysvmsg sysvsem sysvshm xsl zip pcntl +ENV PHP_EXTENSIONS bcmath bz2 calendar exif gd gettext intl mysqli opcache pdo_mysql redis soap sockets sodium sysvmsg sysvsem sysvshm xsl zip pcntl # Install dependencies RUN apt-get update \ diff --git a/images/php/8.1-cli/Dockerfile b/images/php/8.1-cli/Dockerfile index 7e07449d..fd8371f3 100644 --- a/images/php/8.1-cli/Dockerfile +++ b/images/php/8.1-cli/Dockerfile @@ -15,7 +15,7 @@ ENV MAGENTO_RUN_MODE production ENV SENDMAIL_PATH /dev/null ENV PHPRC ${MAGENTO_ROOT}/php.ini -ENV PHP_EXTENSIONS bcmath bz2 calendar exif gd gettext intl mysqli opcache pdo_mysql redis soap sockets sysvmsg sysvsem sysvshm xsl zip pcntl +ENV PHP_EXTENSIONS bcmath bz2 calendar exif gd gettext intl mysqli opcache pdo_mysql redis soap sockets sodium sysvmsg sysvsem sysvshm xsl zip pcntl # Configure Node.js version RUN curl -sL https://deb.nodesource.com/setup_lts.x | bash diff --git a/images/php/8.1-fpm/Dockerfile b/images/php/8.1-fpm/Dockerfile index 0d86943a..64b7d7ad 100644 --- a/images/php/8.1-fpm/Dockerfile +++ b/images/php/8.1-fpm/Dockerfile @@ -11,7 +11,7 @@ ENV UPLOAD_MAX_FILESIZE 64M ENV SENDMAIL_PATH /dev/null ENV PHPRC ${MAGENTO_ROOT}/php.ini -ENV PHP_EXTENSIONS bcmath bz2 calendar exif gd gettext intl mysqli opcache pdo_mysql redis soap sockets sysvmsg sysvsem sysvshm xsl zip pcntl +ENV PHP_EXTENSIONS bcmath bz2 calendar exif gd gettext intl mysqli opcache pdo_mysql redis soap sockets sodium sysvmsg sysvsem sysvshm xsl zip pcntl # Install dependencies RUN apt-get update \ diff --git a/src/Command/Image/GeneratePhp.php b/src/Command/Image/GeneratePhp.php index 5fb9e41c..9e4cb388 100644 --- a/src/Command/Image/GeneratePhp.php +++ b/src/Command/Image/GeneratePhp.php @@ -80,6 +80,7 @@ class GeneratePhp extends Command 'opcache', 'xsl', 'zip', + 'sodium' ]; private const DOCKERFILE = 'Dockerfile'; diff --git a/src/Compose/Php/ExtensionResolver.php b/src/Compose/Php/ExtensionResolver.php index d9d25788..7efedb2a 100644 --- a/src/Compose/Php/ExtensionResolver.php +++ b/src/Compose/Php/ExtensionResolver.php @@ -49,7 +49,7 @@ class ExtensionResolver 'zip', // Required for Magento 2.4.0+ 'xsl', - 'sodium' + 'sodium', ]; /** From e6724b223b0b0f7190ca81ad94965cc45df180bc Mon Sep 17 00:00:00 2001 From: Bohdan Korablov Date: Thu, 6 Jan 2022 15:20:50 -0600 Subject: [PATCH 07/13] MCLOUD-8369: Fix cache volume for composer (#82) --- images/php/7.2-cli/Dockerfile | 2 ++ images/php/7.3-cli/Dockerfile | 2 ++ images/php/7.4-cli/Dockerfile | 2 ++ images/php/8.0-cli/Dockerfile | 2 ++ images/php/8.1-cli/Dockerfile | 2 ++ images/php/cli/Dockerfile | 2 ++ 6 files changed, 12 insertions(+) diff --git a/images/php/7.2-cli/Dockerfile b/images/php/7.2-cli/Dockerfile index 46132c4d..b36cb7dc 100644 --- a/images/php/7.2-cli/Dockerfile +++ b/images/php/7.2-cli/Dockerfile @@ -8,6 +8,8 @@ ARG COMPOSER_HOME=/composer ARG CRONTAB="" ENV COMPOSER_MEMORY_LIMIT -1 +ENV COMPOSER_ALLOW_SUPERUSER ${COMPOSER_ALLOW_SUPERUSER} +ENV COMPOSER_HOME ${COMPOSER_HOME} ENV PHP_MEMORY_LIMIT -1 ENV PHP_VALIDATE_TIMESTAMPS 1 ENV DEBUG false diff --git a/images/php/7.3-cli/Dockerfile b/images/php/7.3-cli/Dockerfile index 24c73db1..47d7e589 100644 --- a/images/php/7.3-cli/Dockerfile +++ b/images/php/7.3-cli/Dockerfile @@ -8,6 +8,8 @@ ARG COMPOSER_HOME=/composer ARG CRONTAB="" ENV COMPOSER_MEMORY_LIMIT -1 +ENV COMPOSER_ALLOW_SUPERUSER ${COMPOSER_ALLOW_SUPERUSER} +ENV COMPOSER_HOME ${COMPOSER_HOME} ENV PHP_MEMORY_LIMIT -1 ENV PHP_VALIDATE_TIMESTAMPS 1 ENV DEBUG false diff --git a/images/php/7.4-cli/Dockerfile b/images/php/7.4-cli/Dockerfile index 18d45343..f70a3f74 100644 --- a/images/php/7.4-cli/Dockerfile +++ b/images/php/7.4-cli/Dockerfile @@ -8,6 +8,8 @@ ARG COMPOSER_HOME=/composer ARG CRONTAB="" ENV COMPOSER_MEMORY_LIMIT -1 +ENV COMPOSER_ALLOW_SUPERUSER ${COMPOSER_ALLOW_SUPERUSER} +ENV COMPOSER_HOME ${COMPOSER_HOME} ENV PHP_MEMORY_LIMIT -1 ENV PHP_VALIDATE_TIMESTAMPS 1 ENV DEBUG false diff --git a/images/php/8.0-cli/Dockerfile b/images/php/8.0-cli/Dockerfile index b2c8a471..22718ff1 100644 --- a/images/php/8.0-cli/Dockerfile +++ b/images/php/8.0-cli/Dockerfile @@ -8,6 +8,8 @@ ARG COMPOSER_HOME=/composer ARG CRONTAB="" ENV COMPOSER_MEMORY_LIMIT -1 +ENV COMPOSER_ALLOW_SUPERUSER ${COMPOSER_ALLOW_SUPERUSER} +ENV COMPOSER_HOME ${COMPOSER_HOME} ENV PHP_MEMORY_LIMIT -1 ENV PHP_VALIDATE_TIMESTAMPS 1 ENV DEBUG false diff --git a/images/php/8.1-cli/Dockerfile b/images/php/8.1-cli/Dockerfile index fd8371f3..ab8e0cbb 100644 --- a/images/php/8.1-cli/Dockerfile +++ b/images/php/8.1-cli/Dockerfile @@ -8,6 +8,8 @@ ARG COMPOSER_HOME=/composer ARG CRONTAB="" ENV COMPOSER_MEMORY_LIMIT -1 +ENV COMPOSER_ALLOW_SUPERUSER ${COMPOSER_ALLOW_SUPERUSER} +ENV COMPOSER_HOME ${COMPOSER_HOME} ENV PHP_MEMORY_LIMIT -1 ENV PHP_VALIDATE_TIMESTAMPS 1 ENV DEBUG false diff --git a/images/php/cli/Dockerfile b/images/php/cli/Dockerfile index e3ee52cf..0dd8da6a 100755 --- a/images/php/cli/Dockerfile +++ b/images/php/cli/Dockerfile @@ -8,6 +8,8 @@ ARG COMPOSER_HOME=/composer ARG CRONTAB="" ENV COMPOSER_MEMORY_LIMIT -1 +ENV COMPOSER_ALLOW_SUPERUSER ${COMPOSER_ALLOW_SUPERUSER} +ENV COMPOSER_HOME ${COMPOSER_HOME} ENV PHP_MEMORY_LIMIT -1 ENV PHP_VALIDATE_TIMESTAMPS 1 ENV DEBUG false From f9bc8576b0328143358d28c0d2d7484ccf3f06a6 Mon Sep 17 00:00:00 2001 From: Bohdan Korablov Date: Wed, 19 Jan 2022 15:18:35 -0600 Subject: [PATCH 08/13] MCLOUD-8404: Set composer 2.1.x by default in PHP 8.x images (#83) --- images/php/8.0-cli/Dockerfile | 2 +- images/php/8.1-cli/Dockerfile | 2 +- images/php/cli/Dockerfile | 2 +- src/Command/Image/GeneratePhp.php | 3 +++ 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/images/php/8.0-cli/Dockerfile b/images/php/8.0-cli/Dockerfile index 22718ff1..a9af0872 100644 --- a/images/php/8.0-cli/Dockerfile +++ b/images/php/8.0-cli/Dockerfile @@ -1,7 +1,7 @@ # This file is automatically generated. Do not edit directly. # FROM php:8.0-cli -ARG COMPOSER_VERSION=1.10.22 +ARG COMPOSER_VERSION=2.1.14 ARG MAGENTO_ROOT=/app ARG COMPOSER_ALLOW_SUPERUSER=1 ARG COMPOSER_HOME=/composer diff --git a/images/php/8.1-cli/Dockerfile b/images/php/8.1-cli/Dockerfile index ab8e0cbb..3f70d9c1 100644 --- a/images/php/8.1-cli/Dockerfile +++ b/images/php/8.1-cli/Dockerfile @@ -1,7 +1,7 @@ # This file is automatically generated. Do not edit directly. # FROM php:8.1-cli -ARG COMPOSER_VERSION=1.10.22 +ARG COMPOSER_VERSION=2.1.14 ARG MAGENTO_ROOT=/app ARG COMPOSER_ALLOW_SUPERUSER=1 ARG COMPOSER_HOME=/composer diff --git a/images/php/cli/Dockerfile b/images/php/cli/Dockerfile index 0dd8da6a..b63855ed 100755 --- a/images/php/cli/Dockerfile +++ b/images/php/cli/Dockerfile @@ -1,7 +1,7 @@ {%note%} FROM php:{%version%}-cli -ARG COMPOSER_VERSION=1.10.22 +ARG COMPOSER_VERSION={%composer_version%} ARG MAGENTO_ROOT=/app ARG COMPOSER_ALLOW_SUPERUSER=1 ARG COMPOSER_HOME=/composer diff --git a/src/Command/Image/GeneratePhp.php b/src/Command/Image/GeneratePhp.php index 9e4cb388..0a5dbd60 100644 --- a/src/Command/Image/GeneratePhp.php +++ b/src/Command/Image/GeneratePhp.php @@ -297,6 +297,9 @@ private function buildDockerfile(string $dockerfile, string $phpVersion, string [ '{%note%}' => '# This file is automatically generated. Do not edit directly. #', '{%version%}' => $phpVersion, + '{%composer_version%}' => $this->semver::satisfies($phpVersion, '<8.0') + ? '1.10.22' + : '2.1.14', '{%packages%}' => implode(" \\\n ", array_unique($packages)), '{%docker-php-ext-configure%}' => implode(PHP_EOL, $phpExtCoreConfigOptions), '{%docker-php-ext-install%}' => $phpExtCore From ce5e3f3f2a7133d77b444de106ffac0e390fa223 Mon Sep 17 00:00:00 2001 From: Bohdan Korablov Date: Thu, 3 Feb 2022 00:07:55 -0600 Subject: [PATCH 09/13] Fix images (#84) --- images/elasticsearch/7.11/Dockerfile | 4 +++- images/elasticsearch/es/Dockerfile | 2 +- images/php/8.0-cli/Dockerfile | 2 +- images/php/8.0-fpm/Dockerfile | 2 +- images/php/8.1-cli/Dockerfile | 2 +- images/php/8.1-fpm/Dockerfile | 2 +- src/Command/Image/GenerateEs.php | 6 ++++++ src/Command/Image/GeneratePhp.php | 10 +++++++++- 8 files changed, 23 insertions(+), 7 deletions(-) diff --git a/images/elasticsearch/7.11/Dockerfile b/images/elasticsearch/7.11/Dockerfile index 1be2a941..26220aa7 100644 --- a/images/elasticsearch/7.11/Dockerfile +++ b/images/elasticsearch/7.11/Dockerfile @@ -1,6 +1,8 @@ FROM docker.elastic.co/elasticsearch/elasticsearch:7.11.2 -RUN yum -y install zip && \ +RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-* && \ + sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-Linux-* && \ + yum -y install zip && \ zip -q -d /usr/share/elasticsearch/lib/log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class && \ yum remove -y zip && \ yum -y clean all && \ diff --git a/images/elasticsearch/es/Dockerfile b/images/elasticsearch/es/Dockerfile index 9d87e3f4..0ecd6e80 100755 --- a/images/elasticsearch/es/Dockerfile +++ b/images/elasticsearch/es/Dockerfile @@ -1,6 +1,6 @@ FROM docker.elastic.co/elasticsearch/elasticsearch:{%version%} -RUN yum -y install zip && \ +RUN {%fix_repos%}yum -y install zip && \ zip -q -d /usr/share/elasticsearch/lib/log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class && \ yum remove -y zip && \ yum -y clean all && \ diff --git a/images/php/8.0-cli/Dockerfile b/images/php/8.0-cli/Dockerfile index a9af0872..54c0367b 100644 --- a/images/php/8.0-cli/Dockerfile +++ b/images/php/8.0-cli/Dockerfile @@ -1,5 +1,5 @@ # This file is automatically generated. Do not edit directly. # -FROM php:8.0-cli +FROM php:8.0.14-cli ARG COMPOSER_VERSION=2.1.14 ARG MAGENTO_ROOT=/app diff --git a/images/php/8.0-fpm/Dockerfile b/images/php/8.0-fpm/Dockerfile index 5bb44dc0..12d2b7a5 100644 --- a/images/php/8.0-fpm/Dockerfile +++ b/images/php/8.0-fpm/Dockerfile @@ -1,5 +1,5 @@ # This file is automatically generated. Do not edit directly. # -FROM php:8.0-fpm +FROM php:8.0.14-fpm ARG MAGENTO_ROOT=/app diff --git a/images/php/8.1-cli/Dockerfile b/images/php/8.1-cli/Dockerfile index 3f70d9c1..05a43dcc 100644 --- a/images/php/8.1-cli/Dockerfile +++ b/images/php/8.1-cli/Dockerfile @@ -1,5 +1,5 @@ # This file is automatically generated. Do not edit directly. # -FROM php:8.1-cli +FROM php:8.1.1-cli ARG COMPOSER_VERSION=2.1.14 ARG MAGENTO_ROOT=/app diff --git a/images/php/8.1-fpm/Dockerfile b/images/php/8.1-fpm/Dockerfile index 64b7d7ad..52926182 100644 --- a/images/php/8.1-fpm/Dockerfile +++ b/images/php/8.1-fpm/Dockerfile @@ -1,5 +1,5 @@ # This file is automatically generated. Do not edit directly. # -FROM php:8.1-fpm +FROM php:8.1.1-fpm ARG MAGENTO_ROOT=/app diff --git a/src/Command/Image/GenerateEs.php b/src/Command/Image/GenerateEs.php index 0d447dc0..234f62fa 100644 --- a/src/Command/Image/GenerateEs.php +++ b/src/Command/Image/GenerateEs.php @@ -103,6 +103,11 @@ protected function configure(): void */ public function execute(InputInterface $input, OutputInterface $output): int { + $fixRepo = <<versionMap as $version => $versionData) { $destination = $this->directoryList->getImagesRoot() . '/elasticsearch/' . $version; $dataDir = $this->directoryList->getImagesRoot() . '/elasticsearch/es/'; @@ -120,6 +125,7 @@ public function execute(InputInterface $input, OutputInterface $output): int [ '{%version%}' => $versionData['real-version'], '{%single_node%}' => $versionData['single-node'] ? self::SINGLE_NODE : '', + '{%fix_repos%}' => ($version === '7.11') ? $fixRepo : '', ] ) ); diff --git a/src/Command/Image/GeneratePhp.php b/src/Command/Image/GeneratePhp.php index 0a5dbd60..8d09fdd5 100644 --- a/src/Command/Image/GeneratePhp.php +++ b/src/Command/Image/GeneratePhp.php @@ -28,6 +28,14 @@ class GeneratePhp extends Command private const NAME = 'image:generate:php'; private const SUPPORTED_VERSIONS = ['7.2', '7.3', '7.4', '8.0', '8.1']; + private const VERSION_MAP = [ + '7.2' => '7.2', + '7.3' => '7.3', + '7.4' => '7.4', + '8.0' => '8.0.14', + '8.1' => '8.1.1' + ]; + private const EDITION_CLI = 'cli'; private const EDITION_FPM = 'fpm'; private const EDITIONS = [self::EDITION_CLI, self::EDITION_FPM]; @@ -296,7 +304,7 @@ private function buildDockerfile(string $dockerfile, string $phpVersion, string $this->filesystem->get($dockerfile), [ '{%note%}' => '# This file is automatically generated. Do not edit directly. #', - '{%version%}' => $phpVersion, + '{%version%}' => self::VERSION_MAP[$phpVersion], '{%composer_version%}' => $this->semver::satisfies($phpVersion, '<8.0') ? '1.10.22' : '2.1.14', From a72b56725b035c2ef81de2b52140cba4ab597dc9 Mon Sep 17 00:00:00 2001 From: Bohdan Korablov Date: Wed, 23 Feb 2022 08:22:34 -0600 Subject: [PATCH 10/13] ACMP-1459: Make ece-tools compatible with php 8.0/8.1 (#74) --- composer.json | 20 ++-- images/elasticsearch/7.11/Dockerfile | 2 +- src/Command/Image/GenerateEs.php | 2 +- .../Functional/Acceptance/AbstractCest.php | 25 ++++- .../Acceptance/Acceptance72Cest.php | 3 + .../Acceptance/Acceptance73Cest.php | 3 + .../Acceptance/Acceptance74Cest.php | 19 ++++ .../Functional/Acceptance/AcceptanceCest.php | 11 ++- .../Functional/Acceptance/DeveloperCest.php | 4 +- .../Acceptance/Elasticsearch74Cest.php | 53 ++++++++++ .../Acceptance/ElasticsearchCest.php | 18 +--- .../Functional/Acceptance/MailHogCest.php | 7 +- .../Functional/Acceptance/OpensearchCest.php | 96 +++++++++++++++++++ tests/functional/Codeception/BaseModule.php | 8 +- .../Codeception/TestInfrastructure.php | 7 ++ 15 files changed, 239 insertions(+), 39 deletions(-) create mode 100644 src/Test/Functional/Acceptance/Acceptance74Cest.php create mode 100644 src/Test/Functional/Acceptance/Elasticsearch74Cest.php create mode 100644 src/Test/Functional/Acceptance/OpensearchCest.php diff --git a/composer.json b/composer.json index 1a5281a8..5aa6184f 100644 --- a/composer.json +++ b/composer.json @@ -2,21 +2,21 @@ "name": "magento/magento-cloud-docker", "description": "Magento Cloud Docker", "type": "magento2-component", - "version": "1.3.0", + "version": "1.3.1", "license": [ "OSL-3.0", "AFL-3.0" ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "ext-json": "*", - "composer/composer": "^1.0||^2.0", - "composer/semver": "^1.0||^2.0||^3.0", - "illuminate/config": "^5.5", - "symfony/config": "^4.4||^5.1", - "symfony/console": "^2.8||^4.0", - "symfony/dependency-injection": "^3.3||^4.3||^5.1", - "symfony/yaml": "^3.3||^4.0||^5.1" + "composer/composer": "^1.4 || ^2.0", + "composer/semver": "@stable", + "illuminate/config": "^5.5||^8.77", + "symfony/config": "^4.4 || ^5.1", + "symfony/console": "^2.8 || ^4.0 || ^5.1", + "symfony/dependency-injection": "^3.3 || ^4.3 || ^5.1", + "symfony/yaml": "^3.3 || ^4.0 || ^5.1" }, "require-dev": { "codeception/codeception": "^4.1", @@ -27,7 +27,7 @@ "consolidation/robo": "^1.2", "phpmd/phpmd": "@stable", "phpstan/phpstan": "^0.12", - "phpunit/phpunit": "^8.5", + "phpunit/phpunit": "^8.5 || ^9.5", "squizlabs/php_codesniffer": "^3.0" }, "bin": [ diff --git a/images/elasticsearch/7.11/Dockerfile b/images/elasticsearch/7.11/Dockerfile index 26220aa7..aaf237db 100644 --- a/images/elasticsearch/7.11/Dockerfile +++ b/images/elasticsearch/7.11/Dockerfile @@ -1,7 +1,7 @@ FROM docker.elastic.co/elasticsearch/elasticsearch:7.11.2 RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-* && \ - sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-Linux-* && \ + sed -i 's|#baseurl=http://mirror.centos.org|baseurl=https://vault.centos.org|g' /etc/yum.repos.d/CentOS-Linux-* && \ yum -y install zip && \ zip -q -d /usr/share/elasticsearch/lib/log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class && \ yum remove -y zip && \ diff --git a/src/Command/Image/GenerateEs.php b/src/Command/Image/GenerateEs.php index 234f62fa..623dd549 100644 --- a/src/Command/Image/GenerateEs.php +++ b/src/Command/Image/GenerateEs.php @@ -105,7 +105,7 @@ public function execute(InputInterface $input, OutputInterface $output): int { $fixRepo = <<versionMap as $version => $versionData) { diff --git a/src/Test/Functional/Acceptance/AbstractCest.php b/src/Test/Functional/Acceptance/AbstractCest.php index cb464442..e9432f19 100644 --- a/src/Test/Functional/Acceptance/AbstractCest.php +++ b/src/Test/Functional/Acceptance/AbstractCest.php @@ -33,12 +33,30 @@ public function _before(\CliTester $I): void $I->cloneTemplateToWorkDir(static::TEMPLATE_VERSION); $I->createAuthJson(); $I->createArtifactsDir(); - $I->createArtifactCurrentTestedCode('docker', '1.3.99'); + $I->createArtifactCurrentTestedCode('docker', '1.3.1'); $I->addArtifactsRepoToComposer(); - $I->addDependencyToComposer('magento/magento-cloud-docker', '1.3.99'); + $I->addDependencyToComposer('magento/magento-cloud-docker', '1.3.1'); $I->addEceToolsGitRepoToComposer(); - $I->addDependencyToComposer('magento/ece-tools', 'dev-develop as 2002.1.99'); + $I->addDependencyToComposer( + 'magento/ece-tools', + $I->getDependencyVersion('magento/ece-tools') ?: 'dev-develop as 2002.1.99' + ); + + if ($mccVersion = $I->getDependencyVersion('magento/magento-cloud-components')) { + $I->addCloudComponentsGitRepoToComposer(); + $I->addDependencyToComposer('magento/magento-cloud-components', $mccVersion); + } + + if ($mcpVersion = $I->getDependencyVersion('magento/magento-cloud-patches')) { + $I->addCloudPatchesGitRepoToComposer(); + $I->addDependencyToComposer('magento/magento-cloud-patches', $mcpVersion); + } + + if ($mqpVersion = $I->getDependencyVersion('magento/quality-patches')) { + $I->addQualityPatchesGitRepoToComposer(); + $I->addDependencyToComposer('magento/quality-patches', $mqpVersion); + } $I->assertTrue($I->composerUpdate(), 'Composer update failed'); $I->cacheWorkDir(static::TEMPLATE_VERSION); @@ -49,6 +67,7 @@ public function _before(\CliTester $I): void */ public function _after(\CliTester $I): void { + $I->runDockerComposeCommand('ps'); $I->stopEnvironment(); $I->removeWorkDir(); } diff --git a/src/Test/Functional/Acceptance/Acceptance72Cest.php b/src/Test/Functional/Acceptance/Acceptance72Cest.php index a48e22cf..b435d2d9 100644 --- a/src/Test/Functional/Acceptance/Acceptance72Cest.php +++ b/src/Test/Functional/Acceptance/Acceptance72Cest.php @@ -12,5 +12,8 @@ */ class Acceptance72Cest extends AcceptanceCest { + /** + * Template version for testing + */ protected const TEMPLATE_VERSION = '2.3.2'; } diff --git a/src/Test/Functional/Acceptance/Acceptance73Cest.php b/src/Test/Functional/Acceptance/Acceptance73Cest.php index a9418220..1c689cd0 100644 --- a/src/Test/Functional/Acceptance/Acceptance73Cest.php +++ b/src/Test/Functional/Acceptance/Acceptance73Cest.php @@ -12,5 +12,8 @@ */ class Acceptance73Cest extends AcceptanceCest { + /** + * Template version for testing + */ protected const TEMPLATE_VERSION = '2.3.5'; } diff --git a/src/Test/Functional/Acceptance/Acceptance74Cest.php b/src/Test/Functional/Acceptance/Acceptance74Cest.php new file mode 100644 index 00000000..65a277aa --- /dev/null +++ b/src/Test/Functional/Acceptance/Acceptance74Cest.php @@ -0,0 +1,19 @@ +updateBaseUrl('http://magento2.test:8080/'); + $I->updateBaseUrl('http://magento2.test/'); $I->assertTrue( - $I->generateDockerCompose('--mode=production --host=magento2.test --port=8080'), + $I->generateDockerCompose('--mode=production --host=magento2.test'), 'Command build:compose failed' ); $I->replaceImagesWithCustom(); diff --git a/src/Test/Functional/Acceptance/DeveloperCest.php b/src/Test/Functional/Acceptance/DeveloperCest.php index 0cb34926..1e383fb0 100644 --- a/src/Test/Functional/Acceptance/DeveloperCest.php +++ b/src/Test/Functional/Acceptance/DeveloperCest.php @@ -10,14 +10,14 @@ use CliTester; /** - * @group php74 + * @group php81 */ class DeveloperCest extends AbstractCest { /** * Template version for testing */ - protected const TEMPLATE_VERSION = '2.4.1'; + protected const TEMPLATE_VERSION = '2.4.4'; /** * Tests that php settings contains configuration from php.dev.ini diff --git a/src/Test/Functional/Acceptance/Elasticsearch74Cest.php b/src/Test/Functional/Acceptance/Elasticsearch74Cest.php new file mode 100644 index 00000000..18f4d7d0 --- /dev/null +++ b/src/Test/Functional/Acceptance/Elasticsearch74Cest.php @@ -0,0 +1,53 @@ + '6.5', + 'xms' => '518m', + 'xmx' => '518m', + 'param' => [ + 'key' => 'node.store.allow_mmapfs', + 'value' => 'false', + 'needle' => '"store":{"allow_mmapfs":"false"}', + ] + ], + [ + 'version' => '7.5', + 'xms' => '520m', + 'xmx' => '520m', + 'plugins' => ['analysis-nori'], + 'param' => [ + 'key' => 'node.store.allow_mmap', + 'value' => 'false', + 'needle' => '"store":{"allow_mmap":"false"}', + ] + ], + ]; + } +} diff --git a/src/Test/Functional/Acceptance/ElasticsearchCest.php b/src/Test/Functional/Acceptance/ElasticsearchCest.php index dabb3941..98e29c77 100644 --- a/src/Test/Functional/Acceptance/ElasticsearchCest.php +++ b/src/Test/Functional/Acceptance/ElasticsearchCest.php @@ -12,14 +12,14 @@ use Robo\Exception\TaskException; /** - * @group php74 + * @group php81 */ class ElasticsearchCest extends AbstractCest { /** * Template version for testing */ - protected const TEMPLATE_VERSION = '2.4.0'; + protected const TEMPLATE_VERSION = '2.4.4'; /** * @param CliTester $I @@ -58,7 +58,7 @@ public function testElasticsearch(CliTester $I, Example $data) private function buildCommand(Example $data): string { $command = sprintf( - '--mode=production --es=%s --es-env-var="ES_JAVA_OPTS=-Xms%s -Xmx%s"', + '--mode=production --es=%s --es-env-var="ES_JAVA_OPTS=-Xms%s -Xmx%s" --no-os', $data['version'], $data['xms'], $data['xmx'] @@ -81,17 +81,7 @@ protected function dataProvider(): array { return [ [ - 'version' => '6.5', - 'xms' => '518m', - 'xmx' => '518m', - 'param' => [ - 'key' => 'node.store.allow_mmapfs', - 'value' => 'false', - 'needle' => '"store":{"allow_mmapfs":"false"}', - ] - ], - [ - 'version' => '7.5', + 'version' => '7.6', 'xms' => '520m', 'xmx' => '520m', 'plugins' => ['analysis-nori'], diff --git a/src/Test/Functional/Acceptance/MailHogCest.php b/src/Test/Functional/Acceptance/MailHogCest.php index 46e3ccd7..96e74941 100644 --- a/src/Test/Functional/Acceptance/MailHogCest.php +++ b/src/Test/Functional/Acceptance/MailHogCest.php @@ -8,10 +8,15 @@ namespace Magento\CloudDocker\Test\Functional\Acceptance; /** - * @group php74 + * @group php81 */ class MailHogCest extends AbstractCest { + /** + * Template version for testing + */ + protected const TEMPLATE_VERSION = '2.4.4'; + /** * @param \CliTester $I * @throws \Exception diff --git a/src/Test/Functional/Acceptance/OpensearchCest.php b/src/Test/Functional/Acceptance/OpensearchCest.php new file mode 100644 index 00000000..4ebcf492 --- /dev/null +++ b/src/Test/Functional/Acceptance/OpensearchCest.php @@ -0,0 +1,96 @@ +generateDockerCompose($this->buildCommand($data)); + $I->replaceImagesWithCustom(); + $I->startEnvironment(); + if (!empty($data['plugins'])) { + $I->runDockerComposeCommand('logs opensearch'); + foreach ($data['plugins'] as $plugin) { + $I->seeInOutput($plugin); + } + } + $I->runDockerComposeCommand('exec -T opensearch curl localhost:9200/_nodes'); + $I->seeInOutput('-Xms' . $data['xms']); + $I->seeInOutput('-Xmx' . $data['xmx']); + + if (!empty($data['param'])) { + $I->runDockerComposeCommand('exec -T opensearch curl http://localhost:9200/_nodes/settings'); + $I->seeInOutput($data['param']['needle']); + } + } + + /** + * Builds build:compose command from given test data + * + * @param Example $data + * @return string + */ + private function buildCommand(Example $data): string + { + $command = sprintf( + '--mode=production --os=%s --os-env-var="OPENSEARCH_JAVA_OPTS=-Xms%s -Xmx%s"', + $data['version'], + $data['xms'], + $data['xmx'] + ); + + if (!empty($data['param'])) { + $command .= " --os-env-var={$data['param']['key']}={$data['param']['value']}"; + } + if (!empty($data['plugins'])) { + $command .= sprintf(' --os-env-var="OS_PLUGINS=%s"', implode(' ', $data['plugins'])); + } + + return $command; + } + + /** + * @return array + */ + protected function dataProvider(): array + { + return [ + [ + 'version' => '1.2', + 'xms' => '520m', + 'xmx' => '520m', + 'plugins' => ['analysis-nori'], + 'param' => [ + 'key' => 'node.store.allow_mmap', + 'value' => 'false', + 'needle' => '"store":{"allow_mmap":"false"}', + ] + ], + ]; + } +} diff --git a/tests/functional/Codeception/BaseModule.php b/tests/functional/Codeception/BaseModule.php index 6105c0e6..81439429 100644 --- a/tests/functional/Codeception/BaseModule.php +++ b/tests/functional/Codeception/BaseModule.php @@ -141,10 +141,10 @@ public function seeInOutput($text): void { if (is_array($text)) { foreach ($text as $value) { - Assert::assertContains($value, static::$output); + Assert::assertStringContainsString($value, static::$output); } } else { - Assert::assertContains($text, static::$output); + Assert::assertStringContainsString($text, static::$output); } } @@ -157,10 +157,10 @@ public function doNotSeeInOutput($text): void { if (is_array($text)) { foreach ($text as $value) { - Assert::assertNotContains($value, static::$output); + Assert::assertStringNotContainsString($value, static::$output); } } else { - Assert::assertNotContains($text, static::$output); + Assert::assertStringNotContainsString($text, static::$output); } } diff --git a/tests/functional/Codeception/TestInfrastructure.php b/tests/functional/Codeception/TestInfrastructure.php index eec4d91e..70ad4e1e 100644 --- a/tests/functional/Codeception/TestInfrastructure.php +++ b/tests/functional/Codeception/TestInfrastructure.php @@ -191,6 +191,13 @@ public function createAuthJson(): bool ], ]; + foreach ((array)$this->_getConfig('additional_creds') as $creds) { + $auth['http-basic'][$creds['host']] = [ + 'username' => $creds['username'], + 'password' => $creds['password'] + ]; + } + $githubToken = $this->_getConfig('composer_github_token'); if ($githubToken) { $auth['github-oauth'] = [ From b57f8b0d7eb86d6e8dc1d9f46918a462662af61d Mon Sep 17 00:00:00 2001 From: Oleksandr Shmyheliuk Date: Wed, 23 Feb 2022 11:58:20 -0600 Subject: [PATCH 11/13] MCLOUD-8450: Remove limitation of memory limit in nginx container (#85) --- images/nginx/1.19/etc/vhost.conf | 2 +- images/php/7.2-fpm/etc/php-fpm.ini | 1 + images/php/7.3-fpm/etc/php-fpm.ini | 1 + images/php/7.4-fpm/etc/php-fpm.ini | 1 + images/php/8.0-fpm/etc/php-fpm.ini | 1 + images/php/8.1-fpm/etc/php-fpm.ini | 1 + images/php/fpm/etc/php-fpm.ini | 1 + 7 files changed, 7 insertions(+), 1 deletion(-) diff --git a/images/nginx/1.19/etc/vhost.conf b/images/nginx/1.19/etc/vhost.conf index 2c6df7e4..690bbcd2 100755 --- a/images/nginx/1.19/etc/vhost.conf +++ b/images/nginx/1.19/etc/vhost.conf @@ -161,7 +161,7 @@ server { fastcgi_buffers 1024 4k; fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off"; - fastcgi_param PHP_VALUE "memory_limit=768M \n max_execution_time=18000"; + fastcgi_param PHP_VALUE "max_execution_time=18000"; fastcgi_read_timeout 600s; fastcgi_connect_timeout 600s; fastcgi_param MAGE_MODE $MAGE_MODE; diff --git a/images/php/7.2-fpm/etc/php-fpm.ini b/images/php/7.2-fpm/etc/php-fpm.ini index 93a85129..387c8aeb 100644 --- a/images/php/7.2-fpm/etc/php-fpm.ini +++ b/images/php/7.2-fpm/etc/php-fpm.ini @@ -1,3 +1,4 @@ memory_limit = ${PHP_MEMORY_LIMIT} opcache.enable = 1 opcache.validate_timestamps = ${PHP_VALIDATE_TIMESTAMPS} +user_ini.filename = diff --git a/images/php/7.3-fpm/etc/php-fpm.ini b/images/php/7.3-fpm/etc/php-fpm.ini index 93a85129..387c8aeb 100644 --- a/images/php/7.3-fpm/etc/php-fpm.ini +++ b/images/php/7.3-fpm/etc/php-fpm.ini @@ -1,3 +1,4 @@ memory_limit = ${PHP_MEMORY_LIMIT} opcache.enable = 1 opcache.validate_timestamps = ${PHP_VALIDATE_TIMESTAMPS} +user_ini.filename = diff --git a/images/php/7.4-fpm/etc/php-fpm.ini b/images/php/7.4-fpm/etc/php-fpm.ini index 93a85129..387c8aeb 100644 --- a/images/php/7.4-fpm/etc/php-fpm.ini +++ b/images/php/7.4-fpm/etc/php-fpm.ini @@ -1,3 +1,4 @@ memory_limit = ${PHP_MEMORY_LIMIT} opcache.enable = 1 opcache.validate_timestamps = ${PHP_VALIDATE_TIMESTAMPS} +user_ini.filename = diff --git a/images/php/8.0-fpm/etc/php-fpm.ini b/images/php/8.0-fpm/etc/php-fpm.ini index 93a85129..387c8aeb 100644 --- a/images/php/8.0-fpm/etc/php-fpm.ini +++ b/images/php/8.0-fpm/etc/php-fpm.ini @@ -1,3 +1,4 @@ memory_limit = ${PHP_MEMORY_LIMIT} opcache.enable = 1 opcache.validate_timestamps = ${PHP_VALIDATE_TIMESTAMPS} +user_ini.filename = diff --git a/images/php/8.1-fpm/etc/php-fpm.ini b/images/php/8.1-fpm/etc/php-fpm.ini index 93a85129..387c8aeb 100644 --- a/images/php/8.1-fpm/etc/php-fpm.ini +++ b/images/php/8.1-fpm/etc/php-fpm.ini @@ -1,3 +1,4 @@ memory_limit = ${PHP_MEMORY_LIMIT} opcache.enable = 1 opcache.validate_timestamps = ${PHP_VALIDATE_TIMESTAMPS} +user_ini.filename = diff --git a/images/php/fpm/etc/php-fpm.ini b/images/php/fpm/etc/php-fpm.ini index 93a85129..387c8aeb 100755 --- a/images/php/fpm/etc/php-fpm.ini +++ b/images/php/fpm/etc/php-fpm.ini @@ -1,3 +1,4 @@ memory_limit = ${PHP_MEMORY_LIMIT} opcache.enable = 1 opcache.validate_timestamps = ${PHP_VALIDATE_TIMESTAMPS} +user_ini.filename = From bf56a55cc66d21980de61df0fc13e8b27ce3a637 Mon Sep 17 00:00:00 2001 From: Bohdan Korablov Date: Wed, 23 Feb 2022 13:49:18 -0600 Subject: [PATCH 12/13] MACI-1446: Remove JndiLookup (#77) (#87) From 861ee2ed79221e213c2489679e251d26834ca02d Mon Sep 17 00:00:00 2001 From: Bohdan Korablov Date: Mon, 28 Feb 2022 12:05:15 -0600 Subject: [PATCH 13/13] Adding the stable mirror for Centos (#89) --- images/elasticsearch/7.11/Dockerfile | 2 +- src/Command/Image/GenerateEs.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/images/elasticsearch/7.11/Dockerfile b/images/elasticsearch/7.11/Dockerfile index aaf237db..7fc8c453 100644 --- a/images/elasticsearch/7.11/Dockerfile +++ b/images/elasticsearch/7.11/Dockerfile @@ -1,7 +1,7 @@ FROM docker.elastic.co/elasticsearch/elasticsearch:7.11.2 RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-* && \ - sed -i 's|#baseurl=http://mirror.centos.org|baseurl=https://vault.centos.org|g' /etc/yum.repos.d/CentOS-Linux-* && \ + sed -i 's|#baseurl=http://mirror.centos.org|baseurl=https://mirror.rackspace.com\/centos-vault|g' /etc/yum.repos.d/CentOS-Linux-* && \ yum -y install zip && \ zip -q -d /usr/share/elasticsearch/lib/log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class && \ yum remove -y zip && \ diff --git a/src/Command/Image/GenerateEs.php b/src/Command/Image/GenerateEs.php index 623dd549..51ac68e2 100644 --- a/src/Command/Image/GenerateEs.php +++ b/src/Command/Image/GenerateEs.php @@ -103,11 +103,14 @@ protected function configure(): void */ public function execute(InputInterface $input, OutputInterface $output): int { +// phpcs:disable $fixRepo = <<versionMap as $version => $versionData) { $destination = $this->directoryList->getImagesRoot() . '/elasticsearch/' . $version; $dataDir = $this->directoryList->getImagesRoot() . '/elasticsearch/es/';