mirror of
https://github.com/coollabsio/coolify.git
synced 2026-03-11 08:55:47 +00:00
Merge ec170b10dd into 9a4b4280be
This commit is contained in:
commit
811d8a7437
2 changed files with 51 additions and 1 deletions
|
|
@ -1010,6 +1010,8 @@ function convertDockerRunToCompose(?string $custom_docker_run_options = null)
|
|||
'--gpus' => 'gpus',
|
||||
'--hostname' => 'hostname',
|
||||
'--entrypoint' => 'entrypoint',
|
||||
'--runtime' => 'runtime',
|
||||
'--pids-limit' => 'pids_limit',
|
||||
]);
|
||||
foreach ($matches as $match) {
|
||||
$option = $match[1];
|
||||
|
|
@ -1030,6 +1032,26 @@ function convertDockerRunToCompose(?string $custom_docker_run_options = null)
|
|||
$options[$option] = array_unique($options[$option]);
|
||||
}
|
||||
}
|
||||
if ($option === '--runtime') {
|
||||
// Match --runtime=value or --runtime value (e.g., --runtime=runsc, --runtime runc)
|
||||
$regexForParsingRuntime = '/--runtime(?:=|\s+)([^\s]+)/';
|
||||
preg_match($regexForParsingRuntime, $custom_docker_run_options, $runtime_matches);
|
||||
$value = $runtime_matches[1] ?? null;
|
||||
if ($value && ! empty(trim($value))) {
|
||||
$options[$option][] = $value;
|
||||
$options[$option] = array_unique($options[$option]);
|
||||
}
|
||||
}
|
||||
if ($option === '--pids-limit') {
|
||||
// Match --pids-limit=value or --pids-limit value (e.g., --pids-limit=256, --pids-limit 1024)
|
||||
$regexForParsingPidsLimit = '/--pids-limit(?:=|\s+)([^\s]+)/';
|
||||
preg_match($regexForParsingPidsLimit, $custom_docker_run_options, $pids_limit_matches);
|
||||
$value = $pids_limit_matches[1] ?? null;
|
||||
if ($value && ! empty(trim($value))) {
|
||||
$options[$option][] = $value;
|
||||
$options[$option] = array_unique($options[$option]);
|
||||
}
|
||||
}
|
||||
if ($option === '--entrypoint') {
|
||||
$value = null;
|
||||
// Match --entrypoint=value or --entrypoint value
|
||||
|
|
@ -1098,7 +1120,7 @@ function convertDockerRunToCompose(?string $custom_docker_run_options = null)
|
|||
}
|
||||
});
|
||||
$compose_options->put($mapping[$option], $ulimits);
|
||||
} elseif ($option === '--shm-size' || $option === '--hostname') {
|
||||
} elseif ($option === '--shm-size' || $option === '--hostname' || $option === '--runtime' || $option === '--pids-limit') {
|
||||
if (! is_null($value) && is_array($value) && count($value) > 0 && ! empty(trim($value[0]))) {
|
||||
$compose_options->put($mapping[$option], $value[0]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -198,3 +198,31 @@ test('ConvertEntrypointSingleQuotedWithDoubleQuotesInside', function () {
|
|||
'entrypoint' => 'python -c "print(\"hi\")"',
|
||||
]);
|
||||
});
|
||||
|
||||
test('RuntimeWithEquals', function () {
|
||||
$input = '--runtime=runsc';
|
||||
$output = convertDockerRunToCompose($input);
|
||||
expect($output)->toBe([
|
||||
'runtime' => 'runsc',
|
||||
]);
|
||||
});
|
||||
|
||||
test('RuntimeWithoutEquals', function () {
|
||||
$input = '--runtime runsc';
|
||||
$output = convertDockerRunToCompose($input);
|
||||
expect($output)->toBe([
|
||||
'runtime' => 'runsc',
|
||||
]);
|
||||
});
|
||||
|
||||
test('PidsLimitWithEquals', function () {
|
||||
$input = '--pids-limit=1024';
|
||||
$output = convertDockerRunToCompose($input);
|
||||
expect($output)->toBe(['pids_limit' => '1024']);
|
||||
});
|
||||
|
||||
test('PidsLimitWithoutEquals', function () {
|
||||
$input = '--pids-limit 256';
|
||||
$output = convertDockerRunToCompose($input);
|
||||
expect($output)->toBe(['pids_limit' => '256']);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue