feat: add shm-size for custom docker commands

This commit is contained in:
Andras Bacsai 2024-08-16 12:24:42 +02:00
parent 2227858f58
commit c15740aa57

View File

@ -677,18 +677,19 @@ function convert_docker_run_to_compose(?string $custom_docker_run_options = null
'--sysctl',
'--ulimit',
'--device',
'--shm-size',
]);
$mapping = collect([
'--cap-add' => 'cap_add',
'--cap-drop' => 'cap_drop',
'--security-opt' => 'security_opt',
'--sysctl' => 'sysctls',
'--ulimit' => 'ulimits',
'--device' => 'devices',
'--init' => 'init',
'--ulimit' => 'ulimits',
'--privileged' => 'privileged',
'--ip' => 'ip',
'--shm-size' => 'shm_size',
]);
foreach ($matches as $match) {
$option = $match[1];
@ -704,6 +705,7 @@ function convert_docker_run_to_compose(?string $custom_docker_run_options = null
$options = collect($options);
// Easily get mappings from https://github.com/composerize/composerize/blob/master/packages/composerize/src/mappings.js
foreach ($options as $option => $value) {
// ray($option,$value);
if (! data_get($mapping, $option)) {
continue;
}
@ -728,6 +730,10 @@ function convert_docker_run_to_compose(?string $custom_docker_run_options = null
}
});
$compose_options->put($mapping[$option], $ulimits);
} elseif ($option === '--shm-size') {
if (!is_null($value) && is_array($value) && count($value) > 0) {
$compose_options->put($mapping[$option], $value[0]);
}
} else {
if ($list_options->contains($option)) {
if ($compose_options->has($mapping[$option])) {