Skip to content

Commit 04c6a23

Browse files
committed
added new service valkey
1 parent cd6949a commit 04c6a23

File tree

10 files changed

+131
-0
lines changed

10 files changed

+131
-0
lines changed

config/services.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<argument type="service" id="Magento\CloudDocker\Compose\ProductionBuilder\Service\Database\DbQuote" />
2525
<argument type="service" id="Magento\CloudDocker\Compose\ProductionBuilder\Service\Database\DbSales" />
2626
<argument type="service" id="Magento\CloudDocker\Compose\ProductionBuilder\Service\Redis" />
27+
<argument type="service" id="Magento\CloudDocker\Compose\ProductionBuilder\Service\Valkey" />
2728
<argument type="service" id="Magento\CloudDocker\Compose\ProductionBuilder\Service\ElasticSearch" />
2829
<argument type="service" id="Magento\CloudDocker\Compose\ProductionBuilder\Service\OpenSearch" />
2930
<argument type="service" id="Magento\CloudDocker\Compose\ProductionBuilder\Service\Fpm" />

src/Command/BuildCompose.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ protected function configure(): void
138138
null,
139139
InputOption::VALUE_REQUIRED,
140140
'Redis version'
141+
)->addOption(
142+
Source\CliSource::OPTION_VALKEY,
143+
null,
144+
InputOption::VALUE_REQUIRED,
145+
'Valkey version'
141146
)->addOption(
142147
Source\CliSource::OPTION_ES,
143148
null,

src/Compose/BuilderInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ interface BuilderInterface
2929
public const SERVICE_TLS = ServiceInterface::SERVICE_TLS;
3030
public const SERVICE_RABBITMQ = ServiceInterface::SERVICE_RABBITMQ;
3131
public const SERVICE_REDIS = ServiceInterface::SERVICE_REDIS;
32+
public const SERVICE_VALKEY = ServiceInterface::SERVICE_VALKEY;
3233
public const SERVICE_ELASTICSEARCH = ServiceInterface::SERVICE_ELASTICSEARCH;
3334
public const SERVICE_OPENSEARCH = ServiceInterface::SERVICE_OPENSEARCH;
3435
public const SERVICE_NODE = ServiceInterface::SERVICE_NODE;

src/Compose/ProductionBuilder/CliDepend.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ class CliDepend
2727
BuilderInterface::SERVICE_REDIS => [
2828
'condition' => 'service_healthy'
2929
],
30+
BuilderInterface::SERVICE_VALKEY => [
31+
'condition' => 'service_healthy'
32+
],
3033
BuilderInterface::SERVICE_ELASTICSEARCH => [
3134
'condition' => 'service_healthy'
3235
],
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CloudDocker\Compose\ProductionBuilder\Service;
9+
10+
use Magento\CloudDocker\Compose\BuilderInterface;
11+
use Magento\CloudDocker\Compose\ProductionBuilder\ServiceBuilderInterface;
12+
use Magento\CloudDocker\Config\Config;
13+
use Magento\CloudDocker\Service\ServiceFactory;
14+
15+
/**
16+
* Returns Redis service configuration
17+
*/
18+
class Valkey implements ServiceBuilderInterface
19+
{
20+
/**
21+
* @var ServiceFactory
22+
*/
23+
private ServiceFactory $serviceFactory;
24+
25+
/**
26+
* @param ServiceFactory $serviceFactory
27+
*/
28+
public function __construct(ServiceFactory $serviceFactory)
29+
{
30+
$this->serviceFactory = $serviceFactory;
31+
}
32+
33+
/**
34+
* @inheritDoc
35+
*/
36+
public function getName(): string
37+
{
38+
return BuilderInterface::SERVICE_VALKEY;
39+
}
40+
41+
/**
42+
* @inheritDoc
43+
*/
44+
public function getServiceName(): string
45+
{
46+
return $this->getName();
47+
}
48+
49+
/**
50+
* @inheritDoc
51+
*/
52+
public function getConfig(Config $config): array
53+
{
54+
return $this->serviceFactory->create(
55+
$this->getServiceName(),
56+
$config->getServiceVersion($this->getServiceName()),
57+
[
58+
BuilderInterface::SERVICE_HEALTHCHECK => [
59+
'test' => 'valkey-cli ping || exit 1',
60+
'interval' => '30s',
61+
'timeout' => '30s',
62+
'retries' => 3
63+
]
64+
],
65+
$config->getServiceImage($this->getServiceName()),
66+
$config->getCustomRegistry()
67+
);
68+
}
69+
70+
/**
71+
* @inheritDoc
72+
*/
73+
public function getNetworks(): array
74+
{
75+
return [BuilderInterface::NETWORK_MAGENTO];
76+
}
77+
78+
/**
79+
* @inheritDoc
80+
*/
81+
public function getDependsOn(Config $config): array
82+
{
83+
return [];
84+
}
85+
}

src/Config/Relationship.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ class Relationship
5555
'port' => '6379'
5656
]
5757
],
58+
'valkey' => [
59+
[
60+
'host' => 'valkey',
61+
'port' => '6379'
62+
]
63+
],
5864
'elasticsearch' => [
5965
[
6066
'host' => 'elasticsearch',

src/Config/Source/CliSource.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class CliSource implements SourceInterface
2727
public const OPTION_EXPOSE_DB_QUOTE_PORT = 'expose-db-quote-port';
2828
public const OPTION_EXPOSE_DB_SALES_PORT = 'expose-db-sales-port';
2929
public const OPTION_REDIS = 'redis';
30+
public const OPTION_VALKEY = 'valkey';
3031
public const OPTION_ES = 'es';
3132
public const OPTION_OS = 'os';
3233
public const OPTION_RABBIT_MQ = 'rmq';
@@ -124,6 +125,9 @@ class CliSource implements SourceInterface
124125
self::OPTION_REDIS => [
125126
self::SERVICES_REDIS => true
126127
],
128+
self::OPTION_VALKEY => [
129+
self::SERVICES_VALKEY => true
130+
],
127131
self::OPTION_ES => [
128132
self::SERVICES_ES => true
129133
],

src/Config/Source/SourceInterface.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ interface SourceInterface
7373
*/
7474
public const SERVICES_REDIS = self::SERVICES . '.' . ServiceInterface::SERVICE_REDIS;
7575

76+
/**
77+
* Valkey
78+
*/
79+
public const SERVICES_VALKEY = self::SERVICES . '.' . ServiceInterface::SERVICE_VALKEY;
80+
7681
/**
7782
* ES
7883
*/

src/Service/ServiceFactory.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,26 @@ class ServiceFactory
105105
]
106106
],
107107
],
108+
ServiceInterface::SERVICE_VALKEY => [
109+
'image' => 'valkey',
110+
'pattern' => self::PATTERN_STD,
111+
'config' => [
112+
'volumes' => [
113+
'/data',
114+
],
115+
'ports' => [6379],
116+
'sysctls' => [
117+
'net.core.somaxconn' => 1024,
118+
],
119+
'ulimits' => [
120+
'nproc' => 65535,
121+
'nofile' => [
122+
'soft' => 20000,
123+
'hard' => 40000
124+
],
125+
]
126+
],
127+
],
108128
ServiceInterface::SERVICE_ELASTICSEARCH => [
109129
'image' => 'magento/magento-cloud-docker-elasticsearch',
110130
'pattern' => self::PATTERN_VERSIONED,

src/Service/ServiceInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ interface ServiceInterface
2323
public const SERVICE_DB_SALES = 'mysql-sales';
2424
public const SERVICE_NGINX = 'nginx';
2525
public const SERVICE_REDIS = 'redis';
26+
public const SERVICE_VALKEY = 'vakey';
2627
public const SERVICE_ELASTICSEARCH = 'elasticsearch';
2728
public const SERVICE_OPENSEARCH = 'opensearch';
2829
public const SERVICE_RABBITMQ = 'rabbitmq';

0 commit comments

Comments
 (0)