Compare commits

...

7 Commits

Author SHA1 Message Date
Andras Bacsai
ab853cac87 Merge pull request #1560 from coollabsio/next
v4.0.0-beta.169
2023-12-20 16:21:06 +01:00
Andras Bacsai
51db2f797d fix: storage error on dbs 2023-12-20 16:19:48 +01:00
Andras Bacsai
0c90d3d0a1 fix: docker compose apps env rewritten 2023-12-20 16:15:13 +01:00
Andras Bacsai
51efe23690 Merge pull request #1559 from coollabsio/next
disable db + service deployments swarm
2023-12-20 14:46:12 +01:00
Andras Bacsai
e3ee84105c disable db + service deployments swarm 2023-12-20 14:45:47 +01:00
Andras Bacsai
6cbd61ac6c Merge pull request #1558 from coollabsio/next
fix: get swarm service logs
2023-12-20 14:25:53 +01:00
Andras Bacsai
638d0c8c99 fix: get swarm service logs 2023-12-20 14:11:50 +01:00
11 changed files with 78 additions and 42 deletions

View File

@@ -65,7 +65,11 @@ class Show extends Component
public function delete() public function delete()
{ {
$this->env->delete(); try {
$this->dispatch('refreshEnvs'); $this->env->delete();
$this->dispatch('refreshEnvs');
} catch (\Exception $e) {
return handleError($e);
}
} }
} }

View File

@@ -73,9 +73,17 @@ class GetLogs extends Component
if (!$refresh && $this->resource?->getMorphClass() === 'App\Models\Service') return; if (!$refresh && $this->resource?->getMorphClass() === 'App\Models\Service') return;
if ($this->container) { if ($this->container) {
if ($this->showTimeStamps) { 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 { } 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) { if ($refresh) {
$this->outputs = ''; $this->outputs = '';

View File

@@ -34,7 +34,15 @@ class Logs extends Component
$this->resource = Application::where('uuid', $this->parameters['application_uuid'])->firstOrFail(); $this->resource = Application::where('uuid', $this->parameters['application_uuid'])->firstOrFail();
$this->status = $this->resource->status; $this->status = $this->resource->status;
$this->server = $this->resource->destination->server; $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) { if ($containers->count() > 0) {
$containers->each(function ($container) { $containers->each(function ($container) {
$this->containers->push(str_replace('/', '', $container['Names'])); $this->containers->push(str_replace('/', '', $container['Names']));
@@ -62,7 +70,7 @@ class Logs extends Component
$this->status = $this->resource->status; $this->status = $this->resource->status;
$this->server = $this->resource->destination->server; $this->server = $this->resource->destination->server;
$this->container = $this->resource->uuid; $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); $this->containers->push($this->container);
} }
} else if (data_get($this->parameters, 'service_uuid')) { } else if (data_get($this->parameters, 'service_uuid')) {

View File

@@ -31,14 +31,16 @@ class Add extends Component
public function mount() public function mount()
{ {
$this->parameters = get_route_parameters(); $this->parameters = get_route_parameters();
$applicationUuid = $this->parameters['application_uuid']; if (data_get($this->parameters, 'application_uuid')) {
$application = Application::where('uuid', $applicationUuid)->first(); $applicationUuid = $this->parameters['application_uuid'];
if (!$application) { $application = Application::where('uuid', $applicationUuid)->first();
abort(404); if (!$application) {
} abort(404);
if ($application->destination->server->isSwarm()) { }
$this->isSwarm = true; if ($application->destination->server->isSwarm()) {
$this->rules['host_path'] = 'required|string'; $this->isSwarm = true;
$this->rules['host_path'] = 'required|string';
}
} }
} }

View File

@@ -14,20 +14,23 @@ use Visus\Cuid2\Cuid2;
function getCurrentApplicationContainerStatus(Server $server, int $id, ?int $pullRequestId = null): Collection function getCurrentApplicationContainerStatus(Server $server, int $id, ?int $pullRequestId = null): Collection
{ {
$containers = collect([]); $containers = collect([]);
$containers = instant_remote_process(["docker ps -a --filter='label=coolify.applicationId={$id}' --format '{{json .}}' "], $server); if (!$server->isSwarm()) {
$containers = format_docker_command_output_to_json($containers); $containers = instant_remote_process(["docker ps -a --filter='label=coolify.applicationId={$id}' --format '{{json .}}' "], $server);
$containers = $containers->map(function ($container) use ($pullRequestId) { $containers = format_docker_command_output_to_json($containers);
$labels = data_get($container, 'Labels'); $containers = $containers->map(function ($container) use ($pullRequestId) {
if (!str($labels)->contains("coolify.pullRequestId=")) { $labels = data_get($container, 'Labels');
data_set($container, 'Labels', $labels . ",coolify.pullRequestId={$pullRequestId}"); if (!str($labels)->contains("coolify.pullRequestId=")) {
return $container; data_set($container, 'Labels', $labels . ",coolify.pullRequestId={$pullRequestId}");
} return $container;
if (str($labels)->contains("coolify.pullRequestId=$pullRequestId")) { }
return $container; if (str($labels)->contains("coolify.pullRequestId=$pullRequestId")) {
} return $container;
return null; }
}); return null;
$containers = $containers->filter(); });
$containers = $containers->filter();
return $containers;
}
return $containers; return $containers;
} }

View File

@@ -1330,7 +1330,8 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
if ($value?->startsWith('$')) { if ($value?->startsWith('$')) {
$foundEnv = EnvironmentVariable::where([ $foundEnv = EnvironmentVariable::where([
'key' => $key, 'key' => $key,
'service_id' => $resource->id, 'application_id' => $resource->id,
'is_preview' => false,
])->first(); ])->first();
$value = Str::of(replaceVariables($value)); $value = Str::of(replaceVariables($value));
$key = $value; $key = $value;
@@ -1397,14 +1398,22 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
$defaultValue = data_get($foundEnv, 'value'); $defaultValue = data_get($foundEnv, 'value');
} }
$isBuildTime = data_get($foundEnv, 'is_build_time', false); $isBuildTime = data_get($foundEnv, 'is_build_time', false);
EnvironmentVariable::updateOrCreate([ if ($foundEnv) {
'key' => $key->value(), $foundEnv->update([
'application_id' => $resource->id, 'key' => $key,
], [ 'application_id' => $resource->id,
'value' => $defaultValue, 'is_build_time' => $isBuildTime,
'is_build_time' => $isBuildTime, 'value' => $defaultValue,
'application_id' => $resource->id, ]);
]); } else {
EnvironmentVariable::create([
'key' => $key,
'value' => $defaultValue,
'is_build_time' => $isBuildTime,
'application_id' => $resource->id,
'is_preview' => false,
]);
}
} }
} }
} }

View File

@@ -7,7 +7,7 @@ return [
// The release version of your application // The release version of your application
// Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')) // 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.169',
// When left empty or `null` the Laravel environment will be used // When left empty or `null` the Laravel environment will be used
'environment' => config('app.env'), 'environment' => config('app.env'),

View File

@@ -1,3 +1,3 @@
<?php <?php
return '4.0.0-beta.166'; return '4.0.0-beta.169';

View File

@@ -3,10 +3,12 @@
href="{{ route('project.application.configuration', $parameters) }}"> href="{{ route('project.application.configuration', $parameters) }}">
<button>Configuration</button> <button>Configuration</button>
</a> </a>
@if(!$application->destination->server->isSwarm())
<a wire:navigate class="{{ request()->routeIs('project.application.command') ? 'text-white' : '' }}" <a wire:navigate class="{{ request()->routeIs('project.application.command') ? 'text-white' : '' }}"
href="{{ route('project.application.command', $parameters) }}"> href="{{ route('project.application.command', $parameters) }}">
<button>Execute Command</button> <button>Execute Command</button>
</a> </a>
@endif
<a wire:navigate class="{{ request()->routeIs('project.application.logs') ? 'text-white' : '' }}" <a wire:navigate class="{{ request()->routeIs('project.application.logs') ? 'text-white' : '' }}"
href="{{ route('project.application.logs', $parameters) }}"> href="{{ route('project.application.logs', $parameters) }}">
<button>Logs</button> <button>Logs</button>

View File

@@ -202,14 +202,14 @@
<li class="step step-secondary">Select a Server</li> <li class="step step-secondary">Select a Server</li>
<li class="step">Select a Destination</li> <li class="step">Select a Destination</li>
</ul> </ul>
@if ($isDatabase) {{-- @if ($isDatabase)
<div class="flex items-center justify-center pt-4"> <div class="flex items-center justify-center pt-4">
<x-forms.checkbox instantSave wire:model="includeSwarm" <x-forms.checkbox instantSave wire:model="includeSwarm"
helper="Swarm clusters are excluded from this list by default. For database, services or complex compose deployments with databases to work with Swarm, helper="Swarm clusters are excluded from this list by default. For database, services or complex compose deployments with databases to work with Swarm,
you need to set a few things on the server. Read more <a class='text-white underline' href='https://coolify.io/docs/swarm#database-requirements' target='_blank'>here</a>." you need to set a few things on the server. Read more <a class='text-white underline' href='https://coolify.io/docs/swarm#database-requirements' target='_blank'>here</a>."
label="Include Swarm Clusters" /> label="Include Swarm Clusters" />
</div> </div>
@endif @endif --}}
<div class="flex flex-col justify-center gap-2 text-left xl:flex-row xl:flex-wrap"> <div class="flex flex-col justify-center gap-2 text-left xl:flex-row xl:flex-wrap">
@forelse($servers as $server) @forelse($servers as $server)
<div class="box group" wire:click="setServer({{ $server }})"> <div class="box group" wire:click="setServer({{ $server }})">

View File

@@ -4,7 +4,7 @@
"version": "3.12.36" "version": "3.12.36"
}, },
"v4": { "v4": {
"version": "4.0.0-beta.166" "version": "4.0.0-beta.169"
} }
} }
} }