diff --git a/app/Livewire/Project/Service/Navbar.php b/app/Livewire/Project/Service/Navbar.php index 7d3987b3d..f2fd5ae96 100644 --- a/app/Livewire/Project/Service/Navbar.php +++ b/app/Livewire/Project/Service/Navbar.php @@ -62,11 +62,15 @@ class Navbar extends Component public function checkDeployments() { - $activity = Activity::where('properties->type_uuid', $this->service->uuid)->latest()->first(); - $status = data_get($activity, 'properties.status'); - if ($status === 'queued' || $status === 'in_progress') { - $this->isDeploymentProgress = true; - } else { + try { + $activity = Activity::where('properties->type_uuid', $this->service->uuid)->latest()->first(); + $status = data_get($activity, 'properties.status'); + if ($status === 'queued' || $status === 'in_progress') { + $this->isDeploymentProgress = true; + } else { + $this->isDeploymentProgress = false; + } + } catch (\Exception $e) { $this->isDeploymentProgress = false; } } diff --git a/app/Livewire/Project/Shared/EnvironmentVariable/Show.php b/app/Livewire/Project/Shared/EnvironmentVariable/Show.php index c21d899e5..d78b47363 100644 --- a/app/Livewire/Project/Shared/EnvironmentVariable/Show.php +++ b/app/Livewire/Project/Shared/EnvironmentVariable/Show.php @@ -24,6 +24,7 @@ class Show extends Component public string $type; protected $listeners = [ + 'refresh' => 'refresh', 'compose_loaded' => '$refresh', ]; @@ -46,6 +47,12 @@ class Show extends Component 'env.is_shown_once' => 'Shown Once', ]; + public function refresh() + { + $this->env->refresh(); + $this->checkEnvs(); + } + public function mount() { if ($this->env->getMorphClass() === 'App\Models\SharedEnvironmentVariable') { diff --git a/bootstrap/helpers/services.php b/bootstrap/helpers/services.php index c33b7eb34..d4e9ebcde 100644 --- a/bootstrap/helpers/services.php +++ b/bootstrap/helpers/services.php @@ -116,7 +116,7 @@ function updateCompose(ServiceApplication|ServiceDatabase $resource) if ($resourceFqdns->count() === 1) { $resourceFqdns = $resourceFqdns->first(); $variableName = 'SERVICE_FQDN_'.str($resource->name)->upper()->replace('-', ''); - $generatedEnv = EnvironmentVariable::where('service_id', $resource->service_id)->where('key', 'LIKE', "{$variableName}_%")->first(); + $generatedEnv = EnvironmentVariable::where('service_id', $resource->service_id)->where('key', $variableName)->first(); $fqdn = Url::fromString($resourceFqdns); $port = $fqdn->getPort(); $path = $fqdn->getPath(); @@ -128,14 +128,13 @@ function updateCompose(ServiceApplication|ServiceDatabase $resource) if ($port) { $variableName = $variableName."_$port"; $generatedEnv = EnvironmentVariable::where('service_id', $resource->service_id)->where('key', $variableName)->first(); - // ray($generatedEnv); if ($generatedEnv) { $generatedEnv->value = $fqdn.$path; $generatedEnv->save(); } } $variableName = 'SERVICE_URL_'.str($resource->name)->upper()->replace('-', ''); - $generatedEnv = EnvironmentVariable::where('service_id', $resource->service_id)->where('key', 'LIKE', "{$variableName}_%")->first(); + $generatedEnv = EnvironmentVariable::where('service_id', $resource->service_id)->where('key', $variableName)->first(); $url = Url::fromString($fqdn); $port = $url->getPort(); $path = $url->getPath(); diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index 2959e6d21..56487c8a6 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -977,6 +977,8 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal $target = str($volume)->after(':')->beforeLast(':'); if ($source->startsWith('./') || $source->startsWith('/') || $source->startsWith('~')) { $type = str('bind'); + // 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'); } @@ -985,14 +987,19 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal $source = data_get_str($volume, 'source'); $target = data_get_str($volume, 'target'); $content = data_get($volume, 'content'); - $isDirectory = (bool) data_get($volume, 'isDirectory', false) || (bool) data_get($volume, 'is_directory', false); + $isDirectory = (bool) data_get($volume, 'isDirectory', null) || (bool) data_get($volume, 'is_directory', null); $foundConfig = $savedService->fileStorages()->whereMountPath($target)->first(); if ($foundConfig) { $contentNotNull = data_get($foundConfig, 'content'); if ($contentNotNull) { $content = $contentNotNull; } - $isDirectory = (bool) data_get($volume, 'isDirectory', false) || (bool) data_get($volume, 'is_directory', false); + $isDirectory = (bool) data_get($volume, 'isDirectory', null) || (bool) data_get($volume, 'is_directory', null); + } + if (is_null($isDirectory) && is_null($content)) { + // if isDirectory is not set & content is also not set, we assume it is a directory + ray('setting isDirectory to true'); + $isDirectory = true; } } if ($type?->value() === 'bind') { @@ -1058,30 +1065,26 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal data_set($service, 'volumes', $serviceVolumes->toArray()); } - // Add env_file with at least .env to the service - // $envFile = collect(data_get($service, 'env_file', [])); - // if ($envFile->count() > 0) { - // if (!$envFile->contains('.env')) { - // $envFile->push('.env'); - // } - // } else { - // $envFile = collect(['.env']); - // } - // data_set($service, 'env_file', $envFile->toArray()); - // Get variables from the service foreach ($serviceVariables as $variableName => $variable) { if (is_numeric($variableName)) { - $variable = str($variable); - if ($variable->contains('=')) { - // - SESSION_SECRET=123 - // - SESSION_SECRET= - $key = $variable->before('='); - $value = $variable->after('='); + if (is_array($variable)) { + // - SESSION_SECRET: 123 + // - SESSION_SECRET: + $key = str(collect($variable)->keys()->first()); + $value = str(collect($variable)->values()->first()); } else { - // - SESSION_SECRET - $key = $variable; - $value = null; + $variable = str($variable); + if ($variable->contains('=')) { + // - SESSION_SECRET=123 + // - SESSION_SECRET= + $key = $variable->before('='); + $value = $variable->after('='); + } else { + // - SESSION_SECRET + $key = $variable; + $value = null; + } } } else { // SESSION_SECRET: 123 @@ -1837,16 +1840,23 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal // Get variables from the service foreach ($serviceVariables as $variableName => $variable) { if (is_numeric($variableName)) { - $variable = str($variable); - if ($variable->contains('=')) { - // - SESSION_SECRET=123 - // - SESSION_SECRET= - $key = $variable->before('='); - $value = $variable->after('='); + if (is_array($variable)) { + // - SESSION_SECRET: 123 + // - SESSION_SECRET: + $key = str(collect($variable)->keys()->first()); + $value = str(collect($variable)->values()->first()); } else { - // - SESSION_SECRET - $key = $variable; - $value = null; + $variable = str($variable); + if ($variable->contains('=')) { + // - SESSION_SECRET=123 + // - SESSION_SECRET= + $key = $variable->before('='); + $value = $variable->after('='); + } else { + // - SESSION_SECRET + $key = $variable; + $value = null; + } } } else { // SESSION_SECRET: 123 diff --git a/config/sentry.php b/config/sentry.php index 5a8a7c08e..b2f6ded80 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -7,7 +7,7 @@ return [ // The release version of your application // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')) - 'release' => '4.0.0-beta.318', + 'release' => '4.0.0-beta.319', // When left empty or `null` the Laravel environment will be used 'environment' => config('app.env'), diff --git a/config/version.php b/config/version.php index 4c8bc6513..8b5a5afc6 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@