Skip to content

Commit a8f8191

Browse files
committed
Merge remote-tracking branch 'origin/develop' into imported-magento-magento-cloud-docker-298
2 parents b72c720 + d8aad29 commit a8f8191

File tree

32 files changed

+327
-52
lines changed

32 files changed

+327
-52
lines changed

config/services.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
<service id="Magento\CloudDocker\App\ConfigurationMismatchException" autowire="false"/>
5252
<service id="Magento\CloudDocker\App\GenericException" autowire="false"/>
5353
<service id="Magento\CloudDocker\Compose\DeveloperBuilder" shared="false"/>
54-
<service id="Magento\CloudDocker\Config\Config" autowire="false"/>
5554
<service id="Magento\CloudDocker\Config\Source\CliSource" autowire="false"/>
5655
<service id="Magento\CloudDocker\Config\Source\CustomSource" autowire="false"/>
5756
<service id="Composer\Semver\VersionParser"/>

src/Command/BuildCompose.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,11 @@ protected function configure(): void
305305
null,
306306
InputOption::VALUE_REQUIRED,
307307
'"auto_increment_offset" database variable'
308+
)->addOption(
309+
Source\CliSource::OPTION_ROOT_DIR,
310+
null,
311+
InputOption::VALUE_REQUIRED,
312+
'Root directory'
308313
);
309314

310315
parent::configure();

src/Command/Image/GenerateEs.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use Magento\CloudDocker\Cli;
1111
use Magento\CloudDocker\Filesystem\DirectoryList;
12+
use Magento\CloudDocker\Filesystem\FileNotFoundException;
1213
use Magento\CloudDocker\Filesystem\Filesystem;
1314
use Symfony\Component\Console\Command\Command;
1415
use Symfony\Component\Console\Input\InputInterface;
@@ -93,6 +94,8 @@ protected function configure(): void
9394
* Generates data for elasticsearch images.
9495
*
9596
* {@inheritDoc}
97+
* @throws FileNotFoundException
98+
* @throws \Magento\CloudDocker\Filesystem\FileSystemException
9699
*/
97100
public function execute(InputInterface $input, OutputInterface $output): int
98101
{

src/Command/Image/GeneratePhp.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
use Composer\Semver\Semver;
1111
use Magento\CloudDocker\App\ConfigurationMismatchException;
1212
use Magento\CloudDocker\Cli;
13-
use Magento\CloudDocker\Filesystem\FileNotFoundException;
14-
use Magento\CloudDocker\Filesystem\Filesystem;
1513
use Magento\CloudDocker\Compose\Php\ExtensionResolver;
1614
use Magento\CloudDocker\Filesystem\DirectoryList;
15+
use Magento\CloudDocker\Filesystem\FileNotFoundException;
16+
use Magento\CloudDocker\Filesystem\Filesystem;
1717
use Symfony\Component\Console\Command\Command;
1818
use Symfony\Component\Console\Input\InputArgument;
1919
use Symfony\Component\Console\Input\InputInterface;
@@ -133,6 +133,7 @@ protected function configure(): void
133133
*
134134
* @throws ConfigurationMismatchException
135135
* @throws FileNotFoundException
136+
* @throws \Magento\CloudDocker\Filesystem\FileSystemException
136137
*/
137138
public function execute(InputInterface $input, OutputInterface $output): int
138139
{
@@ -161,6 +162,7 @@ public function execute(InputInterface $input, OutputInterface $output): int
161162
* @param string $edition
162163
* @throws ConfigurationMismatchException
163164
* @throws FileNotFoundException
165+
* @throws \Magento\CloudDocker\Filesystem\FileSystemException
164166
*/
165167
private function build(string $version, string $edition): void
166168
{

src/Compose/BuilderInterface.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,13 @@ interface BuilderInterface
3939
public const NETWORK_MAGENTO = 'magento';
4040
public const NETWORK_MAGENTO_BUILD = 'magento-build';
4141

42-
public const VOLUME_MAGENTO = '.';
4342
public const VOLUME_DOCKER_MNT = '.docker/mnt';
4443
public const VOLUME_MARIADB_CONF = '.docker/mysql/mariadb.conf.d';
4544
public const VOLUME_MAGENTO_VENDOR = 'magento-vendor';
4645
public const VOLUME_MAGENTO_GENERATED = 'magento-generated';
4746
public const VOLUME_MAGENTO_DB = 'magento-db';
4847
public const VOLUME_MAGENTO_DB_QUOTE = 'magento-db-quote';
4948
public const VOLUME_MAGENTO_DB_SALES = 'magento-db-sales';
50-
public const VOLUME_MAGENTO_DEV = './dev';
5149
public const VOLUME_DOCKER_ENTRYPOINT = '.docker/mysql/docker-entrypoint-initdb.d';
5250
public const VOLUME_DOCKER_ENTRYPOINT_QUOTE = '.docker/mysql-quote/docker-entrypoint-initdb.d';
5351
public const VOLUME_DOCKER_ENTRYPOINT_SALES = '.docker/mysql-sales/docker-entrypoint-initdb.d';

src/Compose/DeveloperBuilder.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\CloudDocker\Compose;
99

1010
use Magento\CloudDocker\Compose\Php\ExtensionResolver;
11+
use Magento\CloudDocker\Compose\ProductionBuilder\VolumeResolver;
1112
use Magento\CloudDocker\Config\Config;
1213
use Magento\CloudDocker\Config\Environment\Converter;
1314
use Magento\CloudDocker\Filesystem\FileList;
@@ -51,22 +52,30 @@ class DeveloperBuilder implements BuilderInterface
5152
*/
5253
private $extensionResolver;
5354

55+
/**
56+
* @var VolumeResolver
57+
*/
58+
private $volumeResolver;
59+
5460
/**
5561
* @param BuilderFactory $builderFactory
5662
* @param FileList $fileList
5763
* @param Converter $converter
5864
* @param ExtensionResolver $extensionResolver
65+
* @param VolumeResolver $volumeResolver
5966
*/
6067
public function __construct(
6168
BuilderFactory $builderFactory,
6269
FileList $fileList,
6370
Converter $converter,
64-
ExtensionResolver $extensionResolver
71+
ExtensionResolver $extensionResolver,
72+
VolumeResolver $volumeResolver
6573
) {
6674
$this->builderFactory = $builderFactory;
6775
$this->fileList = $fileList;
6876
$this->converter = $converter;
6977
$this->extensionResolver = $extensionResolver;
78+
$this->volumeResolver = $volumeResolver;
7079
}
7180

7281
/**
@@ -87,7 +96,7 @@ public function build(Config $config): Manager
8796
$volumePrefix . self::VOLUME_MAGENTO_DB => []
8897
];
8998

90-
$volumes = [self::VOLUME_MAGENTO . ':' . self::DIR_MAGENTO . ':delegated'];
99+
$volumes = [$this->volumeResolver->getMagentoVolume($config) . ':' . self::DIR_MAGENTO . ':delegated'];
91100

92101
if (in_array($syncEngine, [self::SYNC_ENGINE_MUTAGEN, self::SYNC_ENGINE_DOCKER_SYNC], true)) {
93102
$volumesList[$volumePrefix . self::VOLUME_MAGENTO_SYNC] = $syncEngine === self::SYNC_ENGINE_DOCKER_SYNC

src/Compose/ProductionBuilder.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,9 @@ private function hasServiceEnabled(ServiceBuilderInterface $service, Config $con
152152
BuilderInterface::SERVICE_DB_QUOTE,
153153
BuilderInterface::SERVICE_DB_SALES,
154154
];
155-
$service = in_array($service->getName(), $serviceNames) ? $service->getServiceName() : $service->getName();
156155

157-
return $config->hasServiceEnabled($service);
156+
return $config->hasServiceEnabled(
157+
in_array($service->getName(), $serviceNames, true) ? $service->getServiceName() : $service->getName()
158+
);
158159
}
159160
}

src/Compose/ProductionBuilder/Service/ElasticSearch.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,13 @@ public function getServiceName(): string
5454
*/
5555
public function getConfig(Config $config): array
5656
{
57-
$esEnvVars = [];
57+
$esEnvVars = [
58+
'cluster.name=docker-cluster',
59+
'bootstrap.memory_lock=true'
60+
];
5861

5962
if (!empty($config->get(SourceInterface::SERVICES_ES_VARS))) {
60-
$esEnvVars = $config->get(SourceInterface::SERVICES_ES_VARS);
63+
$esEnvVars = array_merge($esEnvVars, $config->get(SourceInterface::SERVICES_ES_VARS));
6164
}
6265

6366
if (!empty($plugins = $config->get(SourceInterface::SERVICES_ES_PLUGINS)) && is_array($plugins)) {

src/Compose/ProductionBuilder/Volume.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public function __construct(VolumeResolver $volumeResolver)
4040
public function getRo(Config $config): array
4141
{
4242
return $this->volumeResolver->normalize(array_merge(
43-
$this->volumeResolver->getRootVolume(true),
44-
$this->volumeResolver->getDevVolumes($config->hasServiceEnabled(ServiceInterface::SERVICE_TEST)),
43+
$this->volumeResolver->getRootVolume($config, true),
44+
$this->volumeResolver->getDevVolumes($config, $config->hasServiceEnabled(ServiceInterface::SERVICE_TEST)),
4545
$this->volumeResolver->getMagentoVolumes($config->getMounts(), true, $this->hasGenerated($config)),
4646
$this->volumeResolver->getMountVolumes($config->hasTmpMounts())
4747
));
@@ -57,8 +57,8 @@ public function getRo(Config $config): array
5757
public function getRw(Config $config): array
5858
{
5959
return $this->volumeResolver->normalize(array_merge(
60-
$this->volumeResolver->getRootVolume(false),
61-
$this->volumeResolver->getDevVolumes($config->hasServiceEnabled(ServiceInterface::SERVICE_TEST)),
60+
$this->volumeResolver->getRootVolume($config, false),
61+
$this->volumeResolver->getDevVolumes($config, $config->hasServiceEnabled(ServiceInterface::SERVICE_TEST)),
6262
$this->volumeResolver->getMagentoVolumes($config->getMounts(), false, $this->hasGenerated($config)),
6363
$this->volumeResolver->getMountVolumes($config->hasTmpMounts()),
6464
$this->volumeResolver->getComposerVolumes()
@@ -75,7 +75,7 @@ public function getRw(Config $config): array
7575
public function getBuild(Config $config): array
7676
{
7777
return $this->volumeResolver->normalize(array_merge(
78-
$this->volumeResolver->getRootVolume(false),
78+
$this->volumeResolver->getRootVolume($config, false),
7979
$this->volumeResolver->getDefaultMagentoVolumes(false, $this->hasGenerated($config)),
8080
$this->volumeResolver->getComposerVolumes()
8181
));

src/Compose/ProductionBuilder/VolumeResolver.php

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,26 @@
77

88
namespace Magento\CloudDocker\Compose\ProductionBuilder;
99

10+
use Magento\CloudDocker\App\ConfigurationMismatchException;
1011
use Magento\CloudDocker\Compose\BuilderInterface;
12+
use Magento\CloudDocker\Config\Config;
1113

1214
/**
1315
* Resolves the volume definitions.
1416
*/
1517
class VolumeResolver
1618
{
17-
public function getRootVolume(bool $isReadOnly): array
19+
/**
20+
* @param Config $config
21+
* @param bool $isReadOnly
22+
* @return array[]
23+
*/
24+
public function getRootVolume(Config $config, bool $isReadOnly): array
1825
{
1926
$mode = $isReadOnly ? 'ro,delegated' : 'rw,delegated';
2027

2128
return [
22-
BuilderInterface::VOLUME_MAGENTO => [
29+
$this->getMagentoVolume($config) => [
2330
'path' => BuilderInterface::DIR_MAGENTO,
2431
'volume' => '/',
2532
'mode' => $mode
@@ -28,14 +35,15 @@ public function getRootVolume(bool $isReadOnly): array
2835
}
2936

3037
/**
38+
* @param Config $config
3139
* @param bool $hasTest
3240
* @return array
3341
*/
34-
public function getDevVolumes(bool $hasTest): array
42+
public function getDevVolumes(Config $config, bool $hasTest): array
3543
{
3644
if ($hasTest) {
3745
return [
38-
BuilderInterface::VOLUME_MAGENTO_DEV => [
46+
$this->getMagentoDevVolume($config) => [
3947
'path' => BuilderInterface::DIR_MAGENTO . '/dev',
4048
'volume' => '/dev',
4149
'mode' => 'rw,delegated'
@@ -153,4 +161,24 @@ public function normalize(array $volumes): array
153161

154162
return $normalized;
155163
}
164+
165+
/**
166+
* @param Config $config
167+
* @return string
168+
* @throws ConfigurationMismatchException
169+
*/
170+
public function getMagentoVolume(Config $config): string
171+
{
172+
return $config->getRootDirectory();
173+
}
174+
175+
/**
176+
* @param Config $config
177+
* @return string
178+
* @throws ConfigurationMismatchException
179+
*/
180+
public function getMagentoDevVolume(Config $config): string
181+
{
182+
return $config->getRootDirectory() . '/dev';
183+
}
156184
}

0 commit comments

Comments
 (0)