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(services): avoid reading bind-mount files when syncing volumes
Andras Bacsai14ecadc0debb
diff --git a/bootstrap/helpers/services.php b/bootstrap/helpers/services.phpindex 20b184a013..e46769a15c 100644--- a/bootstrap/helpers/services.php+++ b/bootstrap/helpers/services.php@@ -139,7 +139,7 @@ function replaceVariables(string $variable): Stringablefunction getFilesystemVolumesFromServer(ServiceApplication|ServiceDatabase|Application $oneService, bool $isInit = false){try {- if ($oneService->getMorphClass() === \App\Models\Application::class) {+ if ($oneService->getMorphClass() === Application::class) {$workdir = $oneService->workdir();$server = $oneService->destination->server;} else {@@ -167,13 +167,12 @@ function getFilesystemVolumesFromServer(ServiceApplication|ServiceDatabase|Appli$isDir = instant_remote_process(["test -d $fileLocation && echo OK || echo NOK"], $server);if ($isFile === 'OK') {- // If its a file & exists- $filesystemContent = instant_remote_process(["cat $fileLocation"], $server);if ($fileVolume->is_based_on_git) {- $fileVolume->content = $filesystemContent;+ $fileVolume->loadStorageOnServer();+ } else {+ $fileVolume->is_directory = false;+ $fileVolume->save();}- $fileVolume->is_directory = false;- $fileVolume->save();} elseif ($isDir === 'OK') {// If its a directory & exists$fileVolume->content = null;@@ -204,7 +203,7 @@ function getFilesystemVolumesFromServer(ServiceApplication|ServiceDatabase|Appliinstant_remote_process(["mkdir -p $fileLocation"], $server);}}- } catch (\Throwable $e) {+ } catch (Throwable $e) {return handleError($e);}}@@ -214,7 +213,7 @@ function updateCompose(ServiceApplication|ServiceDatabase $resource)$name = data_get($resource, 'name');$dockerComposeRaw = data_get($resource, 'service.docker_compose_raw');if (! $dockerComposeRaw) {- throw new \Exception('No compose file found or not a valid YAML file.');+ throw new Exception('No compose file found or not a valid YAML file.');}$dockerCompose = Yaml::parse($dockerComposeRaw);@@ -396,7 +395,7 @@ function updateCompose(ServiceApplication|ServiceDatabase $resource)}}}- } catch (\Throwable $e) {+ } catch (Throwable $e) {return handleError($e);}}@@ -495,7 +494,7 @@ function applyServiceApplicationPrerequisites(Service $service): void}}}- } catch (\Throwable $e) {+ } catch (Throwable $e) {// Log error but don't throw - prerequisites are nice-to-have, not criticalLog::error('Failed to apply service application prerequisites', ['service_id' => $service->id,diff --git a/tests/Unit/LocalFileVolumeContentSizeTest.php b/tests/Unit/LocalFileVolumeContentSizeTest.phpindex 1fd315884e..0ad69e28aa 100644--- a/tests/Unit/LocalFileVolumeContentSizeTest.php+++ b/tests/Unit/LocalFileVolumeContentSizeTest.php@@ -64,3 +64,16 @@ it('exposes the too-large flag via toArray for Livewire serialization', functionexpect($array)->toHaveKey('is_too_large');expect($array['is_too_large'])->toBeTrue();});++it('does not read regular bind-mounted file contents while loading service settings', function () {+ $helpers = file_get_contents(base_path('bootstrap/helpers/services.php'));+ $filesystemSync = str($helpers)+ ->after('function getFilesystemVolumesFromServer')+ ->before('function updateCompose');++ expect($filesystemSync->value())+ ->not->toContain('instant_remote_process(["cat $fileLocation"]');+ expect($filesystemSync->value())+ ->toContain('if ($fileVolume->is_based_on_git)')+ ->toContain('$fileVolume->loadStorageOnServer();');+});