Merge branch 'coollabsio:main' into fix-#2546-deletion-issues

This commit is contained in:
ayntk-ai
2024-08-08 15:40:13 +02:00
committed by GitHub
13 changed files with 51 additions and 31 deletions

View File

@@ -4,6 +4,8 @@ namespace App\Actions\Server;
use App\Models\InstanceSettings; use App\Models\InstanceSettings;
use App\Models\Server; use App\Models\Server;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Http;
use Lorisleiva\Actions\Concerns\AsAction; use Lorisleiva\Actions\Concerns\AsAction;
class UpdateCoolify class UpdateCoolify
@@ -25,6 +27,11 @@ class UpdateCoolify
return; return;
} }
CleanupDocker::dispatch($this->server, false)->onQueue('high'); CleanupDocker::dispatch($this->server, false)->onQueue('high');
$response = Http::retry(3, 1000)->get('https://cdn.coollabs.io/coolify/versions.json');
if ($response->successful()) {
$versions = $response->json();
File::put(base_path('versions.json'), json_encode($versions, JSON_PRETTY_PRINT));
}
$this->latestVersion = get_latest_version_of_coolify(); $this->latestVersion = get_latest_version_of_coolify();
$this->currentVersion = config('version'); $this->currentVersion = config('version');
if (! $manual_update) { if (! $manual_update) {
@@ -39,6 +46,8 @@ class UpdateCoolify
} }
} }
$this->update(); $this->update();
$settings->new_version_available = false;
$settings->save();
} catch (\Throwable $e) { } catch (\Throwable $e) {
throw $e; throw $e;
} }

View File

@@ -43,15 +43,15 @@ class ServerCheckJob implements ShouldBeEncrypted, ShouldQueue
public function __construct(public Server $server) {} public function __construct(public Server $server) {}
public function middleware(): array // public function middleware(): array
{ // {
return [(new WithoutOverlapping($this->server->uuid))]; // return [(new WithoutOverlapping($this->server->uuid))];
} // }
public function uniqueId(): int // public function uniqueId(): int
{ // {
return $this->server->uuid; // return $this->server->uuid;
} // }
public function handle() public function handle()
{ {

View File

@@ -16,7 +16,7 @@ class SettingsBackup extends Component
public $s3s; public $s3s;
public StandalonePostgresql|null|array $database = []; public ?StandalonePostgresql $database = null;
public ScheduledDatabaseBackup|null|array $backup = []; public ScheduledDatabaseBackup|null|array $backup = [];
@@ -43,19 +43,19 @@ class SettingsBackup extends Component
{ {
if (isInstanceAdmin()) { if (isInstanceAdmin()) {
$settings = InstanceSettings::get(); $settings = InstanceSettings::get();
$database = StandalonePostgresql::whereName('coolify-db')->first(); $this->database = StandalonePostgresql::whereName('coolify-db')->first();
$s3s = S3Storage::whereTeamId(0)->get() ?? []; $s3s = S3Storage::whereTeamId(0)->get() ?? [];
if ($database) { if ($this->database) {
if ($database->status !== 'running') { if ($this->database->status !== 'running') {
$database->status = 'running'; $this->database->status = 'running';
$database->save(); $this->database->save();
} }
$this->database = $database; $this->backup = $this->database->scheduledBackups->first();
$this->executions = $this->backup->executions;
} }
$this->settings = $settings; $this->settings = $settings;
$this->s3s = $s3s; $this->s3s = $s3s;
$this->backup = $this->database?->scheduledBackups?->first() ?? null;
$this->executions = $this->backup?->executions ?? [];
} else { } else {
return redirect()->route('dashboard'); return redirect()->route('dashboard');
} }

View File

@@ -715,8 +715,8 @@ $schema://$host {
} }
return [ return [
'containers' => $containers ?? collect([]), 'containers' => collect($containers) ?? collect([]),
'containerReplicates' => $containerReplicates ?? collect([]), 'containerReplicates' => collect($containerReplicates) ?? collect([]),
]; ];
} }

View File

@@ -9,6 +9,11 @@ const VALID_CRON_STRINGS = [
'weekly' => '0 0 * * 0', 'weekly' => '0 0 * * 0',
'monthly' => '0 0 1 * *', 'monthly' => '0 0 1 * *',
'yearly' => '0 0 1 1 *', 'yearly' => '0 0 1 1 *',
'@hourly' => '0 * * * *',
'@daily' => '0 0 * * *',
'@weekly' => '0 0 * * 0',
'@monthly' => '0 0 1 * *',
'@yearly' => '0 0 1 1 *',
]; ];
const RESTART_MODE = 'unless-stopped'; const RESTART_MODE = 'unless-stopped';

View File

@@ -1,6 +1,7 @@
<?php <?php
use App\Actions\Proxy\SaveConfiguration; use App\Actions\Proxy\SaveConfiguration;
use App\Enums\ProxyTypes;
use App\Models\Application; use App\Models\Application;
use App\Models\Server; use App\Models\Server;
use Symfony\Component\Yaml\Yaml; use Symfony\Component\Yaml\Yaml;

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.320', 'release' => '4.0.0-beta.323',
// 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.320'; return '4.0.0-beta.323';

View File

@@ -1,5 +1,7 @@
<form class="flex flex-col w-full gap-2 rounded" wire:submit='submit'> <form class="flex flex-col w-full gap-2 rounded" wire:submit='submit'>
<x-forms.input autofocus placeholder="0 0 * * * or daily" id="frequency" label="Frequency" required /> <x-forms.input autofocus placeholder="0 0 * * * or daily" id="frequency"
helper="You can use every_minute, hourly, daily, weekly, monthly, yearly or a cron expression." label="Frequency"
required />
<x-forms.checkbox id="save_s3" label="Save to S3" /> <x-forms.checkbox id="save_s3" label="Save to S3" />
<x-forms.select id="selected_storage_id"> <x-forms.select id="selected_storage_id">
@if ($s3s->count() === 0) @if ($s3s->count() === 0)

View File

@@ -1,7 +1,9 @@
<form class="flex flex-col w-full gap-2 rounded" wire:submit='submit'> <form class="flex flex-col w-full gap-2 rounded" wire:submit='submit'>
<x-forms.input autofocus placeholder="Run cron" id="name" label="Name" /> <x-forms.input autofocus placeholder="Run cron" id="name" label="Name" />
<x-forms.input placeholder="php artisan schedule:run" id="command" label="Command" /> <x-forms.input placeholder="php artisan schedule:run" id="command" label="Command" />
<x-forms.input placeholder="0 0 * * * or daily" id="frequency" label="Frequency" /> <x-forms.input placeholder="0 0 * * * or daily"
helper="You can use every_minute, hourly, daily, weekly, monthly, yearly or a cron expression." id="frequency"
label="Frequency" />
@if ($type === 'application') @if ($type === 'application')
@if ($containerNames->count() > 1) @if ($containerNames->count() > 1)
<x-forms.select id="container" label="Container name"> <x-forms.select id="container" label="Container name">

View File

@@ -14,7 +14,7 @@
</div> </div>
<div class="pb-4">Backup configuration for Coolify instance.</div> <div class="pb-4">Backup configuration for Coolify instance.</div>
<div> <div>
@if (isset($database)) @if (isset($database) && isset($backup))
<div class="flex flex-col gap-3 pb-4"> <div class="flex flex-col gap-3 pb-4">
<div class="flex gap-2"> <div class="flex gap-2">
<x-forms.input label="UUID" readonly id="database.uuid" /> <x-forms.input label="UUID" readonly id="database.uuid" />
@@ -27,14 +27,15 @@
</div> </div>
</div> </div>
<livewire:project.database.backup-edit :backup="$backup" :s3s="$s3s" :status="data_get($database, 'status')" /> <livewire:project.database.backup-edit :backup="$backup" :s3s="$s3s" :status="data_get($database, 'status')" />
<div class="py-4">
<livewire:project.database.backup-executions :backup="$backup" />
</div>
@else @else
To configure automatic backup for your Coolify instance, you first need to add a database resource To configure automatic backup for your Coolify instance, you first need to add a database resource
into Coolify. into Coolify.
<x-forms.button class="mt-2" wire:click="add_coolify_database">Add Database</x-forms.button> <x-forms.button class="mt-2" wire:click="add_coolify_database">Add Database</x-forms.button>
@endif @endif
</div> </div>
<div class="py-4">
<livewire:project.database.backup-executions :backup="$backup" />
</div>
</div> </div>
</div> </div>

View File

@@ -60,13 +60,13 @@
<div class="flex items-end gap-2"> <div class="flex items-end gap-2">
<x-forms.input required id="update_check_frequency" label="Update Check Frequency" <x-forms.input required id="update_check_frequency" label="Update Check Frequency"
placeholder="0 * * * *" placeholder="0 * * * *"
helper="Cron expression for update check frequency (check for new Coolify versions and pull new Service Templates from CDN). Default is every hour." /> helper="Cron expression for update check frequency (check for new Coolify versions and pull new Service Templates from CDN).<br>You can use every_minute, hourly, daily, weekly, monthly, yearly.<br><br>Default is every hour." />
<x-forms.button wire:click='checkManually'>Check Manually</x-forms.button> <x-forms.button wire:click='checkManually'>Check Manually</x-forms.button>
</div> </div>
@if (is_null(env('AUTOUPDATE', null)) && $is_auto_update_enabled) @if (is_null(env('AUTOUPDATE', null)) && $is_auto_update_enabled)
<x-forms.input required id="auto_update_frequency" label="Auto Update Frequency" placeholder="0 0 * * *" <x-forms.input required id="auto_update_frequency" label="Auto Update Frequency" placeholder="0 0 * * *"
helper="Cron expression for auto update frequency (automatically update coolify). Default is every day at 00:00" /> helper="Cron expression for auto update frequency (automatically update coolify).<br>You can use every_minute, hourly, daily, weekly, monthly, yearly.<br><br>Default is every day at 00:00" />
@endif @endif
</div> </div>
</form> </form>

View File

@@ -1,7 +1,7 @@
{ {
"coolify": { "coolify": {
"v4": { "v4": {
"version": "4.0.0-beta.320" "version": "4.0.0-beta.323"
} }
} }
} }