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.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix(parsers): enhance volume string handling by preserving mode in application and service parsers. Update related unit tests for validation.
Andras Bacsaicde528bf5eb3
diff --git a/bootstrap/helpers/parsers.php b/bootstrap/helpers/parsers.phpindex 0fadaf7c7c..649b872126 100644--- a/bootstrap/helpers/parsers.php+++ b/bootstrap/helpers/parsers.php@@ -551,8 +551,14 @@ function applicationParser(Application $resource, int $pull_request_id = 0, ?intif ($type->value() === 'bind') {if ($source->value() === '/var/run/docker.sock') {$volume = $source->value().':'.$target->value();+ if (isset($parsed['mode']) && $parsed['mode']) {+ $volume .= ':'.$parsed['mode']->value();+ }} elseif ($source->value() === '/tmp' || $source->value() === '/tmp/') {$volume = $source->value().':'.$target->value();+ if (isset($parsed['mode']) && $parsed['mode']) {+ $volume .= ':'.$parsed['mode']->value();+ }} else {if ((int) $resource->compose_parsing_version >= 4) {$mainDirectory = str(base_configuration_dir().'/applications/'.$uuid);@@ -586,6 +592,9 @@ function applicationParser(Application $resource, int $pull_request_id = 0, ?int}}$volume = "$source:$target";+ if (isset($parsed['mode']) && $parsed['mode']) {+ $volume .= ':'.$parsed['mode']->value();+ }}} elseif ($type->value() === 'volume') {if ($topLevel->get('volumes')->has($source->value())) {@@ -609,6 +618,9 @@ function applicationParser(Application $resource, int $pull_request_id = 0, ?int$target = $parsed['target'];$source = $name;$volume = "$source:$target";+ if (isset($parsed['mode']) && $parsed['mode']) {+ $volume .= ':'.$parsed['mode']->value();+ }} elseif (is_array($volume)) {data_set($volume, 'source', $name);}@@ -1562,8 +1574,14 @@ function serviceParser(Service $resource): Collectionif ($type->value() === 'bind') {if ($source->value() === '/var/run/docker.sock') {$volume = $source->value().':'.$target->value();+ if (isset($parsed['mode']) && $parsed['mode']) {+ $volume .= ':'.$parsed['mode']->value();+ }} elseif ($source->value() === '/tmp' || $source->value() === '/tmp/') {$volume = $source->value().':'.$target->value();+ if (isset($parsed['mode']) && $parsed['mode']) {+ $volume .= ':'.$parsed['mode']->value();+ }} else {if ((int) $resource->compose_parsing_version >= 4) {$mainDirectory = str(base_configuration_dir().'/services/'.$uuid);@@ -1594,6 +1612,9 @@ function serviceParser(Service $resource): Collection}}$volume = "$source:$target";+ if (isset($parsed['mode']) && $parsed['mode']) {+ $volume .= ':'.$parsed['mode']->value();+ }}} elseif ($type->value() === 'volume') {if ($topLevel->get('volumes')->has($source->value())) {@@ -1614,6 +1635,9 @@ function serviceParser(Service $resource): Collection$target = $parsed['target'];$source = $name;$volume = "$source:$target";+ if (isset($parsed['mode']) && $parsed['mode']) {+ $volume .= ':'.$parsed['mode']->value();+ }} elseif (is_array($volume)) {data_set($volume, 'source', $name);}diff --git a/resources/views/livewire/project/shared/storages/all.blade.php b/resources/views/livewire/project/shared/storages/all.blade.phpindex f7bd7bdceb..bd377e3b28 100644--- a/resources/views/livewire/project/shared/storages/all.blade.php+++ b/resources/views/livewire/project/shared/storages/all.blade.php@@ -6,7 +6,8 @@:resource="$resource" :isFirst="$loop->first" isReadOnly='true' isService='true' />@else<livewire:project.shared.storages.show wire:key="storage-{{ $storage->id }}" :storage="$storage"- :resource="$resource" isReadOnly="{{ data_get($storage, 'is_readonly') }}"+ :resource="$resource"+ isReadOnly="{{ data_get($storage, 'is_readonly') || $resource?->build_pack === 'dockercompose' ? true : false }}"startedAt="{{ data_get($resource, 'started_at') }}" />@endif@endforeachdiff --git a/tests/Unit/ParseDockerVolumeStringTest.php b/tests/Unit/ParseDockerVolumeStringTest.phpindex 3b993efb53..6d31725e31 100644--- a/tests/Unit/ParseDockerVolumeStringTest.php+++ b/tests/Unit/ParseDockerVolumeStringTest.php@@ -191,3 +191,31 @@ test('parses complex real-world examples', function () {expect($result['target']->value())->toBe('/var/lib/app-data');expect($result['mode'])->toBeNull();});++test('preserves mode when reconstructing volume strings', function () {+ // Test cases that specifically verify mode preservation+ $testCases = [+ '/var/run/docker.sock:/var/run/docker.sock:ro' => ['source' => '/var/run/docker.sock', 'target' => '/var/run/docker.sock', 'mode' => 'ro'],+ '/etc/localtime:/etc/localtime:ro' => ['source' => '/etc/localtime', 'target' => '/etc/localtime', 'mode' => 'ro'],+ '/tmp:/tmp:rw' => ['source' => '/tmp', 'target' => '/tmp', 'mode' => 'rw'],+ 'gitea-data:/data:ro' => ['source' => 'gitea-data', 'target' => '/data', 'mode' => 'ro'],+ './config:/app/config:cached' => ['source' => './config', 'target' => '/app/config', 'mode' => 'cached'],+ 'volume:/data:delegated' => ['source' => 'volume', 'target' => '/data', 'mode' => 'delegated'],+ ];++ foreach ($testCases as $input => $expected) {+ $result = parseDockerVolumeString($input);++ // Verify parsing+ expect($result['source']->value())->toBe($expected['source']);+ expect($result['target']->value())->toBe($expected['target']);+ expect($result['mode']->value())->toBe($expected['mode']);++ // Verify reconstruction would preserve the mode+ $reconstructed = $result['source']->value().':'.$result['target']->value();+ if ($result['mode']) {+ $reconstructed .= ':'.$result['mode']->value();+ }+ expect($reconstructed)->toBe($input);+ }+});