Skip to content

Commit be4c7f7

Browse files
MAGECLOUD-3345: Add Node.JS Docker Image (#476)
1 parent fc190cc commit be4c7f7

File tree

6 files changed

+27
-3
lines changed

6 files changed

+27
-3
lines changed

src/Command/Docker/Build.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class Build extends Command
3939
const OPTION_REDIS = 'redis';
4040
const OPTION_ES = 'es';
4141
const OPTION_RABBIT_MQ = 'rmq';
42+
const OPTION_NODE = 'node';
4243
const OPTION_MODE = 'mode';
4344

4445
/**
@@ -142,6 +143,11 @@ protected function configure()
142143
null,
143144
InputOption::VALUE_OPTIONAL,
144145
'RabbitMQ version'
146+
)->addOption(
147+
self::OPTION_NODE,
148+
null,
149+
InputOption::VALUE_REQUIRED,
150+
'Node.js version'
145151
)->addOption(
146152
self::OPTION_MODE,
147153
'm',
@@ -176,6 +182,7 @@ public function execute(InputInterface $input, OutputInterface $output)
176182
self::OPTION_NGINX => Config::KEY_NGINX,
177183
self::OPTION_REDIS => Config::KEY_REDIS,
178184
self::OPTION_ES => Config::KEY_ELASTICSEARCH,
185+
self::OPTION_NODE => Config::KEY_NODE,
179186
self::OPTION_RABBIT_MQ => Config::KEY_RABBITMQ,
180187
];
181188

src/Docker/Compose/ProductionCompose.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,16 @@ public function build(Repository $config): array
117117
);
118118
}
119119

120+
$nodeVersion = $config->get(Config::KEY_NODE);
121+
122+
if ($nodeVersion) {
123+
$services['node'] = $this->serviceFactory->create(
124+
ServiceFactory::SERVICE_NODE,
125+
$nodeVersion,
126+
['volumes' => [$this->getMagentoVolumes(false)]]
127+
);
128+
}
129+
120130
$rabbitMQVersion = $config->get(Config::KEY_RABBITMQ)
121131
?: $this->config->getServiceVersion(Config::KEY_RABBITMQ);
122132

src/Docker/ComposeManagerInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ interface ComposeManagerInterface
1818
const REDIS_VERSION = 'redis.version';
1919
const ES_VERSION = 'es.version';
2020
const RABBIT_MQ_VERSION = 'rmq.version';
21+
const NODE_VERSION = 'node.version';
2122

2223
/**
2324
* @param Repository $config

src/Docker/Service/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Config
2323
const KEY_REDIS = 'redis';
2424
const KEY_ELASTICSEARCH = 'elasticsearch';
2525
const KEY_RABBITMQ = 'rabbitmq';
26-
26+
const KEY_NODE = 'node';
2727
const KEY_CRON = 'crons';
2828
const KEY_VARNISH = 'varnish';
2929

src/Docker/Service/ServiceFactory.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class ServiceFactory
2323
const SERVICE_ELASTICSEARCH = 'elasticsearch';
2424
const SERVICE_RABBIT_MQ = 'rabbitmq';
2525
const SERVICE_TLS = 'tls';
26+
const SERVICE_NODE = 'node';
2627

2728
const CONFIG = [
2829
self::SERVICE_CLI => [
@@ -85,6 +86,10 @@ class ServiceFactory
8586
'image' => 'rabbitmq:%s',
8687
'versions' => ['3.5', '3.7']
8788
],
89+
self::SERVICE_NODE => [
90+
'image' => 'node:%s',
91+
'versions' => ['6', '8', '10', '11'],
92+
],
8893
];
8994

9095
/**

src/Test/Unit/Command/Docker/BuildTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,13 @@ public function testExecuteWithParams()
198198
[Build::OPTION_REDIS, '3.2'],
199199
[Build::OPTION_ES, '2.4'],
200200
[Build::OPTION_RABBIT_MQ, '3.5'],
201-
[Build::OPTION_MODE, ComposeManagerFactory::COMPOSE_PRODUCTION]
201+
[Build::OPTION_NODE, '6.0'],
202+
[Build::OPTION_MODE, ComposeManagerFactory::COMPOSE_PRODUCTION],
202203
]);
203204
$this->managerMock->expects($this->once())
204205
->method('getConfigPath')
205206
->willReturn('magento_root/docker-compose.yml');
206-
$this->configMock->expects($this->exactly(6))
207+
$this->configMock->expects($this->exactly(7))
207208
->method('set');
208209
$this->distGenerator->expects($this->once())
209210
->method('generate');

0 commit comments

Comments
 (0)