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
refactor(shared helpers): remove unused parseServiceVolumes function to clean up codebase
Andras Bacsai1675c85d4de7
diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.phpindex c342244fc9..23393a4a45 100644--- a/bootstrap/helpers/shared.php+++ b/bootstrap/helpers/shared.php@@ -1326,143 +1326,6 @@ function customApiValidator(Collection|array $item, array $rules)'required' => 'This field is required.',]);}--function parseServiceVolumes($serviceVolumes, $resource, $topLevelVolumes, $pull_request_id = 0)-{- $serviceVolumes = $serviceVolumes->map(function ($volume) use ($resource, $topLevelVolumes, $pull_request_id) {- $type = null;- $source = null;- $target = null;- $content = null;- $isDirectory = false;- if (is_string($volume)) {- $source = str($volume)->before(':');- $target = str($volume)->after(':')->beforeLast(':');- $foundConfig = $resource->fileStorages()->whereMountPath($target)->first();- if ($source->startsWith('./') || $source->startsWith('/') || $source->startsWith('~')) {- $type = str('bind');- if ($foundConfig) {- $contentNotNull = data_get($foundConfig, 'content');- if ($contentNotNull) {- $content = $contentNotNull;- }- $isDirectory = data_get($foundConfig, 'is_directory');- } else {- // By default, we cannot determine if the bind is a directory or not, so we set it to directory- $isDirectory = true;- }- } else {- $type = str('volume');- }- } elseif (is_array($volume)) {- $type = data_get_str($volume, 'type');- $source = data_get_str($volume, 'source');- $target = data_get_str($volume, 'target');- $content = data_get($volume, 'content');- $isDirectory = (bool) data_get($volume, 'isDirectory', null) || (bool) data_get($volume, 'is_directory', null);- $foundConfig = $resource->fileStorages()->whereMountPath($target)->first();- if ($foundConfig) {- $contentNotNull = data_get($foundConfig, 'content');- if ($contentNotNull) {- $content = $contentNotNull;- }- $isDirectory = data_get($foundConfig, 'is_directory');- } else {- $isDirectory = (bool) data_get($volume, 'isDirectory', null) || (bool) data_get($volume, 'is_directory', null);- if ((is_null($isDirectory) || ! $isDirectory) && is_null($content)) {- // if isDirectory is not set (or false) & content is also not set, we assume it is a directory- $isDirectory = true;- }- }- }- if ($type?->value() === 'bind') {- if ($source->value() === '/var/run/docker.sock') {- return $volume;- }- if ($source->value() === '/tmp' || $source->value() === '/tmp/') {- return $volume;- }- if (get_class($resource) === \App\Models\Application::class) {- $dir = base_configuration_dir().'/applications/'.$resource->uuid;- } else {- $dir = base_configuration_dir().'/services/'.$resource->service->uuid;- }-- if ($source->startsWith('.')) {- $source = $source->replaceFirst('.', $dir);- }- if ($source->startsWith('~')) {- $source = $source->replaceFirst('~', $dir);- }- if ($pull_request_id !== 0) {- $source = $source."-pr-$pull_request_id";- }- if (! $resource?->settings?->is_preserve_repository_enabled || $foundConfig?->is_based_on_git) {- LocalFileVolume::updateOrCreate(- [- 'mount_path' => $target,- 'resource_id' => $resource->id,- 'resource_type' => get_class($resource),- ],- [- 'fs_path' => $source,- 'mount_path' => $target,- 'content' => $content,- 'is_directory' => $isDirectory,- 'resource_id' => $resource->id,- 'resource_type' => get_class($resource),- ]- );- }- } elseif ($type->value() === 'volume') {- if ($topLevelVolumes->has($source->value())) {- $v = $topLevelVolumes->get($source->value());- if (data_get($v, 'driver_opts.type') === 'cifs') {- return $volume;- }- }- $slugWithoutUuid = Str::slug($source, '-');- if (get_class($resource) === \App\Models\Application::class) {- $name = "{$resource->uuid}_{$slugWithoutUuid}";- } else {- $name = "{$resource->service->uuid}_{$slugWithoutUuid}";- }- if (is_string($volume)) {- $source = str($volume)->before(':');- $target = str($volume)->after(':')->beforeLast(':');- $source = $name;- $volume = "$source:$target";- } elseif (is_array($volume)) {- data_set($volume, 'source', $name);- }- $topLevelVolumes->put($name, [- 'name' => $name,- ]);- LocalPersistentVolume::updateOrCreate(- [- 'mount_path' => $target,- 'resource_id' => $resource->id,- 'resource_type' => get_class($resource),- ],- [- 'name' => $name,- 'mount_path' => $target,- 'resource_id' => $resource->id,- 'resource_type' => get_class($resource),- ]- );- }- dispatch(new ServerFilesFromServerJob($resource));-- return $volume;- });-- return [- 'serviceVolumes' => $serviceVolumes,- 'topLevelVolumes' => $topLevelVolumes,- ];-}-function parseDockerComposeFile(Service|Application $resource, bool $isNew = false, int $pull_request_id = 0, ?int $preview_id = null){if ($resource->getMorphClass() === \App\Models\Service::class) {