Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: boolean docker options

Andras Bacsai364a6aa3a264
diff --git a/bootstrap/helpers/docker.php b/bootstrap/helpers/docker.php
index eb0898bfdf..5308b3fa8f 100644
--- a/bootstrap/helpers/docker.php
+++ b/bootstrap/helpers/docker.php
@@ -340,17 +340,22 @@ function convert_docker_run_to_compose(?string $custom_docker_run_options = null
'--cap-drop' => 'cap_drop',
'--security-opt' => 'security_opt',
'--sysctl' => 'sysctls',
- '--device' => 'devices',
'--ulimit' => 'ulimits',
+ '--device' => 'devices',
'--init' => 'init',
'--ulimit' => 'ulimits',
'--privileged' => 'privileged',
]);
foreach ($matches as $match) {
$option = $match[1];
- $value = isset($match[2]) && $match[2] !== '' ? $match[2] : true;
- $options[$option][] = $value;
- $options[$option] = array_unique($options[$option]);
+ if (isset($match[2]) && $match[2] !== '') {
+ $value = $match[2];
+ $options[$option][] = $value;
+ $options[$option] = array_unique($options[$option]);
+ } else {
+ $value = true;
+ $options[$option] = $value;
+ }
}
$options = collect($options);
// Easily get mappings from https://github.com/composerize/composerize/blob/master/packages/composerize/src/mappings.js
diff --git a/tests/Feature/DockerRunTest.php b/tests/Feature/DockerRunTest.php
index 8821d1ad40..d0494f6527 100644
--- a/tests/Feature/DockerRunTest.php
+++ b/tests/Feature/DockerRunTest.php
@@ -1,9 +1,31 @@
<?php
-it('ConvertDockerTunCommand', function () {
+it('ConvertCapAdd', function () {
$input = '--cap-add=NET_ADMIN --cap-add=NET_RAW --cap-add SYS_ADMIN';
$output = convert_docker_run_to_compose($input);
expect($output)->toBe([
'cap_add' => ['NET_ADMIN', 'NET_RAW', 'SYS_ADMIN'],
])->ray();
});
+
+it('ConvertPrivilegedAndInit', function () {
+ $input = '---privileged --init';
+ $output = convert_docker_run_to_compose($input);
+ expect($output)->toBe([
+ 'privileged' => true,
+ 'init' => true,
+ ])->ray();
+});
+
+it('ConvertUlimit', function () {
+ $input = '--ulimit nofile=262144:262144';
+ $output = convert_docker_run_to_compose($input);
+ expect($output)->toBe([
+ 'ulimits' => [
+ 'nofile' => [
+ 'soft' => '262144',
+ 'hard' => '262144',
+ ],
+ ],
+ ])->ray();
+});