원클릭으로
add-service-for-magento
Guide for adding new Docker services (e.g., cache, message broker, search engine) to the Magento 2 Dockerizer
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Guide for adding new Docker services (e.g., cache, message broker, search engine) to the Magento 2 Dockerizer
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
| name | add-service-for-magento |
| description | Guide for adding new Docker services (e.g., cache, message broker, search engine) to the Magento 2 Dockerizer |
Adding a new Docker service to the Dockerizer requires changes across multiple layers. This skill documents the full process using Valkey (cache) and ActiveMQ Artemis (message broker) as reference implementations.
Location:
templates/vendor/defaultvalue/dockerizer-templates/service/<service_name>/dv_<service_name>.yaml
Create a Docker Compose YAML fragment. The filename (without .yaml) becomes
the service code referenced in composition templates.
Minimal service (like Redis/Valkey -- no UI, no auth):
services:
<service-name>:
image: <image>:{{<version_param>}}
restart: always
Full-featured service (like RabbitMQ/Artemis -- UI via Traefik, auth, persistent data, healthcheck):
services:
<service-name>:
image: <image>:{{<version_param>}}
restart: always
labels:
- traefik.enable=true
- traefik.http.routers.<name>-{{environment}}-{{domains|first|replace:.:-}}-http.rule=Host(`<name>-{{environment}}-{{domains|first}}`)
- traefik.http.routers.<name>-{{environment}}-{{domains|first|replace:.:-}}-http.entrypoints=http
- traefik.http.services.<name>-{{domains|first|replace:.:-}}-http.loadbalancer.server.port=<ui_port>
environment:
<ENV_USER>: "{{<user_param>}}"
<ENV_PASS>: "{{<pass_param>}}"
volumes:
- <name>_{{environment}}_data:<data_path>
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:<port>/<path>"]
interval: 30s
timeout: 10s
retries: 5
volumes:
<name>_{{environment}}_data:
external: false
Rules:
{{param_name}} syntax with optional modifiers:
{{param|first|replace:.:-}}services: <service-name>:) becomes the Docker
Compose service nameAppContainers.php./templates/vendor/*/*/service/
(configured in config/services.yaml)Location: src/Docker/ContainerizedService/<ServiceName>.php
Extend AbstractService. Override initialize() to add a health check with
retry loop. Follow the Opensearch/Elasticsearch pattern.
When to create a dedicated class:
getMeta())When to use Generic:
getEnvironmentVariable(),
run(), mustRun())Health check pattern:
class ServiceName extends AbstractService
{
private const CONNECTION_RETRIES = 60;
private const STATE_CONNECTION_RETRIES = 10;
public function initialize(string $containerName): static
{
$self = parent::initialize($containerName);
$self->testConnection();
return $self;
}
private function testConnection(int $connectionRetries = self::CONNECTION_RETRIES): void
{
$stateConnectionRetries = min($connectionRetries, self::STATE_CONNECTION_RETRIES);
while ($connectionRetries--) {
try {
if ($this->getState() !== Container::CONTAINER_STATE_RUNNING) {
--$stateConnectionRetries;
}
if (!$stateConnectionRetries) {
throw new ContainerStateException(
'', 0, null, $this->getContainerName(), Container::CONTAINER_STATE_RUNNING
);
}
// YOUR HEALTH CHECK HERE (e.g., curl, CLI ping, etc.)
$this->mustRun('health-check-command', Shell::EXECUTION_TIMEOUT_SHORT, false);
return;
} catch (ProcessFailedException) {
if ($connectionRetries) {
sleep(1);
continue;
}
throw new \RuntimeException(
sprintf('Container "%s" is not responding', $this->getContainerName())
);
}
}
}
}
File: src/Platform/Magento/AppContainers.php
Add a public const with the Docker Compose service name (must match the
services: key in the template YAML):
public const MY_SERVICE = 'my-service-name';
File: src/Platform/Magento.php
initialize() method -- check
$dockerCompose->hasService() and call ->initialize()elseif to make them mutually exclusive. Check the newer/preferred
service first.File: src/Platform/Magento/SetupInstall.php
In updateMagentoConfig(), add the Magento CLI configuration commands. Use
$appContainers->hasService() to check availability and
$appContainers->getService()->getEnvironmentVariable() to read credentials.
Common Magento config patterns:
setup:config:set --cache-backend=redis --cache-backend-redis-server=<host> ...setup:config:set --session-save=redis --session-save-redis-host=<host> ...setup:config:set --amqp-host=<host> --amqp-port=5672 --amqp-user=<user> --amqp-password=<pass>updateMagentoConfig()If the new service replaces an existing one, use elseif and check the newer
service first (consistent with Magento.php::initialize()).
Add the new service to relevant Magento version composition templates in
templates/vendor/defaultvalue/dockerizer-templates/composition/magento/<version>/.
Place in optional: section if the service is not required for Magento to
function (Redis, Valkey, RabbitMQ, Artemis are all optional).
If the new service replaces an existing one, they go in the same group (e.g.,
cache: group with both Redis and Valkey options, message_queue: group with
both RabbitMQ and Artemis options).
service/valkey/dv_valkey.yaml,
ContainerizedService/Valkey.phpservice/activemq_artemis/dv_activemq_artemis.yaml,
ContainerizedService/ActivemqArtemis.phpservice/redis/dv_redis.yaml, initialized via
Generic in Magento.phpvendor/bin/phpstan analyse -l 8 ./src/ -- all new/modified files pass level
8vendor/bin/phpcs --standard=PSR12 --severity=1 ./src/ -- PSR-12 compliancephp bin/dockerizer list -- CLI boots without errors