diff --git a/app/Livewire/Project/Shared/GetLogs.php b/app/Livewire/Project/Shared/GetLogs.php index e6f1ab009..b1398f909 100644 --- a/app/Livewire/Project/Shared/GetLogs.php +++ b/app/Livewire/Project/Shared/GetLogs.php @@ -73,9 +73,17 @@ class GetLogs extends Component if (!$refresh && $this->resource?->getMorphClass() === 'App\Models\Service') return; if ($this->container) { if ($this->showTimeStamps) { - $sshCommand = generateSshCommand($this->server, "docker logs -n {$this->numberOfLines} -t {$this->container}"); + if ($this->server->isSwarm()) { + $sshCommand = generateSshCommand($this->server, "docker service logs -n {$this->numberOfLines} -t {$this->container}"); + } else { + $sshCommand = generateSshCommand($this->server, "docker logs -n {$this->numberOfLines} -t {$this->container}"); + } } else { - $sshCommand = generateSshCommand($this->server, "docker logs -n {$this->numberOfLines} {$this->container}"); + if ($this->server->isSwarm()) { + $sshCommand = generateSshCommand($this->server, "docker service logs -n {$this->numberOfLines} {$this->container}"); + } else { + $sshCommand = generateSshCommand($this->server, "docker logs -n {$this->numberOfLines} {$this->container}"); + } } if ($refresh) { $this->outputs = ''; diff --git a/app/Livewire/Project/Shared/Logs.php b/app/Livewire/Project/Shared/Logs.php index f7c952b46..a8f41c92e 100644 --- a/app/Livewire/Project/Shared/Logs.php +++ b/app/Livewire/Project/Shared/Logs.php @@ -34,7 +34,15 @@ class Logs extends Component $this->resource = Application::where('uuid', $this->parameters['application_uuid'])->firstOrFail(); $this->status = $this->resource->status; $this->server = $this->resource->destination->server; - $containers = getCurrentApplicationContainerStatus($this->server, $this->resource->id, 0); + if ($this->server->isSwarm()) { + $containers = collect([ + [ + 'Names' => $this->resource->uuid . '_' . $this->resource->uuid, + ] + ]); + } else { + $containers = getCurrentApplicationContainerStatus($this->server, $this->resource->id, 0); + } if ($containers->count() > 0) { $containers->each(function ($container) { $this->containers->push(str_replace('/', '', $container['Names'])); @@ -62,7 +70,7 @@ class Logs extends Component $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')) { + if (str(data_get($this, 'resource.status'))->startsWith('running')) { $this->containers->push($this->container); } } else if (data_get($this->parameters, 'service_uuid')) { diff --git a/bootstrap/helpers/docker.php b/bootstrap/helpers/docker.php index c46c4d558..19b3d5b18 100644 --- a/bootstrap/helpers/docker.php +++ b/bootstrap/helpers/docker.php @@ -14,20 +14,23 @@ use Visus\Cuid2\Cuid2; function getCurrentApplicationContainerStatus(Server $server, int $id, ?int $pullRequestId = null): Collection { $containers = collect([]); - $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) { - $labels = data_get($container, 'Labels'); - if (!str($labels)->contains("coolify.pullRequestId=")) { - data_set($container, 'Labels', $labels . ",coolify.pullRequestId={$pullRequestId}"); - return $container; - } - if (str($labels)->contains("coolify.pullRequestId=$pullRequestId")) { - return $container; - } - return null; - }); - $containers = $containers->filter(); + 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) { + $labels = data_get($container, 'Labels'); + if (!str($labels)->contains("coolify.pullRequestId=")) { + data_set($container, 'Labels', $labels . ",coolify.pullRequestId={$pullRequestId}"); + return $container; + } + if (str($labels)->contains("coolify.pullRequestId=$pullRequestId")) { + return $container; + } + return null; + }); + $containers = $containers->filter(); + return $containers; + } return $containers; } diff --git a/config/sentry.php b/config/sentry.php index e4fbdc97a..d73f428ca 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.166', + 'release' => '4.0.0-beta.167', // 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 313acc6cc..d16975469 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ + @if(!$application->destination->server->isSwarm()) + @endif diff --git a/versions.json b/versions.json index 34e17aa72..f9cde0283 100644 --- a/versions.json +++ b/versions.json @@ -4,7 +4,7 @@ "version": "3.12.36" }, "v4": { - "version": "4.0.0-beta.166" + "version": "4.0.0-beta.167" } } }