feat: add --gpu support for custom docker command

This commit is contained in:
Andras Bacsai
2024-11-06 10:13:40 +01:00
parent 673ac44fe8
commit ff6f089483
11 changed files with 41 additions and 23 deletions

View File

@@ -2,7 +2,7 @@
test('ConvertCapAdd', function () {
$input = '--cap-add=NET_ADMIN --cap-add=NET_RAW --cap-add SYS_ADMIN';
$output = convert_docker_run_to_compose($input);
$output = convertDockerRunToCompose($input);
expect($output)->toBe([
'cap_add' => ['NET_ADMIN', 'NET_RAW', 'SYS_ADMIN'],
]);
@@ -10,7 +10,7 @@ test('ConvertCapAdd', function () {
test('ConvertIp', function () {
$input = '--cap-add=NET_ADMIN --cap-add=NET_RAW --cap-add SYS_ADMIN --ip 127.0.0.1 --ip 127.0.0.2';
$output = convert_docker_run_to_compose($input);
$output = convertDockerRunToCompose($input);
expect($output)->toBe([
'cap_add' => ['NET_ADMIN', 'NET_RAW', 'SYS_ADMIN'],
'ip' => ['127.0.0.1', '127.0.0.2'],
@@ -19,7 +19,7 @@ test('ConvertIp', function () {
test('ConvertPrivilegedAndInit', function () {
$input = '---privileged --init';
$output = convert_docker_run_to_compose($input);
$output = convertDockerRunToCompose($input);
expect($output)->toBe([
'privileged' => true,
'init' => true,
@@ -28,7 +28,7 @@ test('ConvertPrivilegedAndInit', function () {
test('ConvertUlimit', function () {
$input = '--ulimit nofile=262144:262144';
$output = convert_docker_run_to_compose($input);
$output = convertDockerRunToCompose($input);
expect($output)->toBe([
'ulimits' => [
'nofile' => [
@@ -38,3 +38,19 @@ test('ConvertUlimit', function () {
],
]);
});
test('ConvertGpus', function () {
$input = '--gpus all';
$output = convertDockerRunToCompose($input);
expect($output)->toBe([
'gpus' => 'all',
]);
});
test('ConvertGpusWithQuotes', function () {
$input = '--gpus "device=0"';
$output = convertDockerRunToCompose($input);
expect($output)->toBe([
'gpus' => '"device=0"',
]);
});