diff --git a/app/Http/Controllers/Api/Deploy.php b/app/Http/Controllers/Api/Deploy.php index 27d4b1ea0..21da51d66 100644 --- a/app/Http/Controllers/Api/Deploy.php +++ b/app/Http/Controllers/Api/Deploy.php @@ -14,7 +14,7 @@ use Illuminate\Support\Collection; use Visus\Cuid2\Cuid2; -class APIDeploy extends Controller +class Deploy extends Controller { public function deploy(Request $request) { diff --git a/app/Http/Controllers/Api/Project.php b/app/Http/Controllers/Api/Project.php index 110e51803..fa2ba34bb 100644 --- a/app/Http/Controllers/Api/Project.php +++ b/app/Http/Controllers/Api/Project.php @@ -6,7 +6,7 @@ use App\Models\Project as ModelsProject; use Illuminate\Http\Request; -class APIProject extends Controller +class Project extends Controller { public function projects(Request $request) { diff --git a/app/Http/Controllers/Api/Server.php b/app/Http/Controllers/Api/Server.php index bab37928f..e7b071a43 100644 --- a/app/Http/Controllers/Api/Server.php +++ b/app/Http/Controllers/Api/Server.php @@ -6,7 +6,7 @@ use App\Models\Server as ModelsServer; use Illuminate\Http\Request; -class APIServer extends Controller +class Server extends Controller { public function servers(Request $request) { diff --git a/app/Livewire/Project/Shared/GetLogs.php b/app/Livewire/Project/Shared/GetLogs.php index b1398f909..5a2053fc4 100644 --- a/app/Livewire/Project/Shared/GetLogs.php +++ b/app/Livewire/Project/Shared/GetLogs.php @@ -23,6 +23,7 @@ class GetLogs extends Component public ServiceApplication|ServiceDatabase|null $servicesubtype = null; public Server $server; public ?string $container = null; + public ?string $pull_request = null; public ?bool $streamLogs = false; public ?bool $showTimeStamps = true; public int $numberOfLines = 100; @@ -70,7 +71,14 @@ public function instantSave() } public function getLogs($refresh = false) { - if (!$refresh && $this->resource?->getMorphClass() === 'App\Models\Service') return; + if ($this->resource?->getMorphClass() === 'App\Models\Application') { + if (str($this->container)->contains('-pr-')) { + $this->pull_request = "Pull Request: " . str($this->container)->afterLast('-pr-')->beforeLast('_')->value(); + } else { + $this->pull_request = 'branch'; + } + } + if (!$refresh && ($this->resource?->getMorphClass() === 'App\Models\Service' || str($this->container)->contains('-pr-'))) return; if ($this->container) { if ($this->showTimeStamps) { if ($this->server->isSwarm()) { diff --git a/app/Livewire/Project/Shared/Logs.php b/app/Livewire/Project/Shared/Logs.php index 19edbdd7b..3b9a121b8 100644 --- a/app/Livewire/Project/Shared/Logs.php +++ b/app/Livewire/Project/Shared/Logs.php @@ -41,13 +41,19 @@ public function mount() ] ]); } else { - $containers = getCurrentApplicationContainerStatus($this->server, $this->resource->id, 0); + $containers = getCurrentApplicationContainerStatus($this->server, $this->resource->id, includePullrequests: true); } if ($containers->count() > 0) { $containers->each(function ($container) { $this->containers->push(str_replace('/', '', $container['Names'])); }); } + $this->containers = $this->containers->sortByDesc(function ($container) { + if (str_contains($container, '-pr-')) { + return explode('-pr-', $container)[1]; + } + return $container; + }); } else if (data_get($this->parameters, 'database_uuid')) { $this->type = 'database'; $resource = StandalonePostgresql::where('uuid', $this->parameters['database_uuid'])->first(); @@ -70,21 +76,15 @@ public function mount() $this->status = $this->resource->status; $this->server = $this->resource->destination->server; $this->container = $this->resource->uuid; - // if (str(data_get($this, 'resource.status'))->startsWith('running')) { - $this->containers->push($this->container); - // } + $this->containers->push($this->container); } else if (data_get($this->parameters, 'service_uuid')) { $this->type = 'service'; $this->resource = Service::where('uuid', $this->parameters['service_uuid'])->firstOrFail(); $this->resource->applications()->get()->each(function ($application) { - // if (str(data_get($application, 'status'))->contains('running')) { - $this->containers->push(data_get($application, 'name') . '-' . data_get($this->resource, 'uuid')); - // } + $this->containers->push(data_get($application, 'name') . '-' . data_get($this->resource, 'uuid')); }); $this->resource->databases()->get()->each(function ($database) { - // if (str(data_get($database, 'status'))->contains('running')) { - $this->containers->push(data_get($database, 'name') . '-' . data_get($this->resource, 'uuid')); - // } + $this->containers->push(data_get($database, 'name') . '-' . data_get($this->resource, 'uuid')); }); $this->server = $this->resource->server; diff --git a/app/Livewire/Tags/Show.php b/app/Livewire/Tags/Show.php index c0c975f6d..05b25955a 100644 --- a/app/Livewire/Tags/Show.php +++ b/app/Livewire/Tags/Show.php @@ -2,7 +2,7 @@ namespace App\Livewire\Tags; -use App\Http\Controllers\Api\APIDeploy as Deploy; +use App\Http\Controllers\Api\Deploy; use App\Models\ApplicationDeploymentQueue; use App\Models\Tag; use Livewire\Component; diff --git a/bootstrap/helpers/docker.php b/bootstrap/helpers/docker.php index 6a3e3f839..008bd4d7f 100644 --- a/bootstrap/helpers/docker.php +++ b/bootstrap/helpers/docker.php @@ -8,18 +8,21 @@ use Illuminate\Support\Str; use Spatie\Url\Url; -function getCurrentApplicationContainerStatus(Server $server, int $id, ?int $pullRequestId = null): Collection +function getCurrentApplicationContainerStatus(Server $server, int $id, ?int $pullRequestId = null, ?bool $includePullrequests = false): Collection { $containers = collect([]); if (!$server->isSwarm()) { $containers = instant_remote_process(["docker ps -a --filter='label=coolify.applicationId={$id}' --format '{{json .}}' "], $server); $containers = format_docker_command_output_to_json($containers); - $containers = $containers->map(function ($container) use ($pullRequestId) { + $containers = $containers->map(function ($container) use ($pullRequestId, $includePullrequests) { $labels = data_get($container, 'Labels'); if (!str($labels)->contains("coolify.pullRequestId=")) { data_set($container, 'Labels', $labels . ",coolify.pullRequestId={$pullRequestId}"); return $container; } + if ($includePullrequests) { + return $container; + } if (str($labels)->contains("coolify.pullRequestId=$pullRequestId")) { return $container; } diff --git a/config/sentry.php b/config/sentry.php index 96c7207e0..c216bb219 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -7,7 +7,7 @@ // 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.226', + 'release' => '4.0.0-beta.227', // 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 b0f6d7453..3a84eb6f2 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ {{ $application->destination->server->name }}. Redeploy @endif - Remove Preview - - Get Deployment Logs + Deployment Logs + + + Application Logs + + + Delete + @endforeach diff --git a/resources/views/livewire/project/shared/get-logs.blade.php b/resources/views/livewire/project/shared/get-logs.blade.php index 9ca5c6abb..0cbd317b4 100644 --- a/resources/views/livewire/project/shared/get-logs.blade.php +++ b/resources/views/livewire/project/shared/get-logs.blade.php @@ -1,23 +1,26 @@
-
-
-

Container: {{ $container }}

+
+
+

{{ $container }}

+ @if ($pull_request) +
({{ $pull_request }})
+ @endif @if ($streamLogs) @endif
-
+
+
+ +
+ Refresh -
- - - Refresh -
-
+
+
- -
{{ $outputs }}
+ @if ($outputs) +
{{ $outputs }}
+ @else +
Refresh to get the logs...
+ @endif