diff --git a/app/Console/Commands/Init.php b/app/Console/Commands/Init.php index b85829256..8aefdad0e 100644 --- a/app/Console/Commands/Init.php +++ b/app/Console/Commands/Init.php @@ -5,7 +5,7 @@ namespace App\Console\Commands; use App\Enums\ActivityTypes; use App\Enums\ApplicationDeploymentStatus; use App\Jobs\CheckHelperImageJob; -use App\Jobs\PullChangelogFromGitHub; +use App\Jobs\PullChangelog; use App\Models\ApplicationDeploymentQueue; use App\Models\Environment; use App\Models\ScheduledDatabaseBackup; @@ -140,7 +140,7 @@ class Init extends Command private function pullChangelogFromGitHub() { try { - PullChangelogFromGitHub::dispatch(); + PullChangelog::dispatch(); echo "Changelog fetch initiated\n"; } catch (\Throwable $e) { echo "Could not fetch changelog from GitHub: {$e->getMessage()}\n"; diff --git a/app/Console/Commands/SyncBunny.php b/app/Console/Commands/SyncBunny.php index 6581bb587..b0cd24715 100644 --- a/app/Console/Commands/SyncBunny.php +++ b/app/Console/Commands/SyncBunny.php @@ -16,7 +16,7 @@ class SyncBunny extends Command * * @var string */ - protected $signature = 'sync:bunny {--templates} {--release} {--nightly}'; + protected $signature = 'sync:bunny {--templates} {--release} {--github-releases} {--nightly}'; /** * The console command description. @@ -25,6 +25,50 @@ class SyncBunny extends Command */ protected $description = 'Sync files to BunnyCDN'; + /** + * Fetch GitHub releases and sync to CDN + */ + private function syncGitHubReleases($parent_dir, $bunny_cdn_storage_name, $bunny_cdn_path, $bunny_cdn) + { + $this->info('Fetching releases from GitHub...'); + try { + $response = Http::timeout(30) + ->get('https://api.github.com/repos/coollabsio/coolify/releases', [ + 'per_page' => 30, // Fetch more releases for better changelog + ]); + + if ($response->successful()) { + $releases = $response->json(); + + // Save releases to a temporary file + $releases_file = "$parent_dir/releases.json"; + file_put_contents($releases_file, json_encode($releases, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); + + // Upload to CDN + Http::pool(fn (Pool $pool) => [ + $pool->storage(fileName: $releases_file)->put("/$bunny_cdn_storage_name/$bunny_cdn_path/releases.json"), + $pool->purge("$bunny_cdn/coolify/releases.json"), + ]); + + // Clean up temporary file + unlink($releases_file); + + $this->info('releases.json uploaded & purged...'); + $this->info('Total releases synced: '.count($releases)); + + return true; + } else { + $this->error('Failed to fetch releases from GitHub: '.$response->status()); + + return false; + } + } catch (\Throwable $e) { + $this->error('Error fetching releases: '.$e->getMessage()); + + return false; + } + } + /** * Execute the console command. */ @@ -33,6 +77,7 @@ class SyncBunny extends Command $that = $this; $only_template = $this->option('templates'); $only_version = $this->option('release'); + $only_github_releases = $this->option('github-releases'); $nightly = $this->option('nightly'); $bunny_cdn = 'https://cdn.coollabs.io'; $bunny_cdn_path = 'coolify'; @@ -90,7 +135,7 @@ class SyncBunny extends Command $install_script_location = "$parent_dir/other/nightly/$install_script"; $versions_location = "$parent_dir/other/nightly/$versions"; } - if (! $only_template && ! $only_version) { + if (! $only_template && ! $only_version && ! $only_github_releases) { if ($nightly) { $this->info('About to sync files NIGHTLY (docker-compose.prod.yaml, upgrade.sh, install.sh, etc) to BunnyCDN.'); } else { @@ -128,12 +173,29 @@ class SyncBunny extends Command if (! $confirmed) { return; } + + // First sync GitHub releases + $this->info('Syncing GitHub releases first...'); + $this->syncGitHubReleases($parent_dir, $bunny_cdn_storage_name, $bunny_cdn_path, $bunny_cdn); + + // Then sync versions.json Http::pool(fn (Pool $pool) => [ $pool->storage(fileName: $versions_location)->put("/$bunny_cdn_storage_name/$bunny_cdn_path/$versions"), $pool->purge("$bunny_cdn/$bunny_cdn_path/$versions"), ]); $this->info('versions.json uploaded & purged...'); + return; + } elseif ($only_github_releases) { + $this->info('About to sync GitHub releases to BunnyCDN.'); + $confirmed = confirm('Are you sure you want to sync GitHub releases?'); + if (! $confirmed) { + return; + } + + // Use the reusable function + $this->syncGitHubReleases($parent_dir, $bunny_cdn_storage_name, $bunny_cdn_path, $bunny_cdn); + return; } diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index c5c4d7e7f..c2ea27274 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -6,7 +6,7 @@ use App\Jobs\CheckAndStartSentinelJob; use App\Jobs\CheckForUpdatesJob; use App\Jobs\CheckHelperImageJob; use App\Jobs\CleanupInstanceStuffsJob; -use App\Jobs\PullChangelogFromGitHub; +use App\Jobs\PullChangelog; use App\Jobs\PullTemplatesFromCDN; use App\Jobs\RegenerateSslCertJob; use App\Jobs\ScheduledJobManager; @@ -68,7 +68,7 @@ class Kernel extends ConsoleKernel $this->scheduleInstance->command('cleanup:unreachable-servers')->daily()->onOneServer(); $this->scheduleInstance->job(new PullTemplatesFromCDN)->cron($this->updateCheckFrequency)->timezone($this->instanceTimezone)->onOneServer(); - $this->scheduleInstance->job(new PullChangelogFromGitHub)->cron($this->updateCheckFrequency)->timezone($this->instanceTimezone)->onOneServer(); + $this->scheduleInstance->job(new PullChangelog)->cron($this->updateCheckFrequency)->timezone($this->instanceTimezone)->onOneServer(); $this->scheduleInstance->job(new CleanupInstanceStuffsJob)->everyTwoMinutes()->onOneServer(); $this->scheduleUpdates(); diff --git a/app/Http/Controllers/Api/ApplicationsController.php b/app/Http/Controllers/Api/ApplicationsController.php index 16413d2ad..7ef1c3506 100644 --- a/app/Http/Controllers/Api/ApplicationsController.php +++ b/app/Http/Controllers/Api/ApplicationsController.php @@ -2284,6 +2284,9 @@ class ApplicationsController extends Controller data_set($data, 'docker_compose_domains', json_encode($dockerComposeDomainsJson)); } $application->fill($data); + if ($application->settings->is_container_label_readonly_enabled && $requestHasDomains && $server->isProxyShouldRun()) { + $application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n"); + } $application->save(); if ($instantDeploy) { diff --git a/app/Jobs/PullChangelogFromGitHub.php b/app/Jobs/PullChangelog.php similarity index 77% rename from app/Jobs/PullChangelogFromGitHub.php rename to app/Jobs/PullChangelog.php index e84766f7f..052e6d557 100644 --- a/app/Jobs/PullChangelogFromGitHub.php +++ b/app/Jobs/PullChangelog.php @@ -11,8 +11,9 @@ use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\Http; +use Illuminate\Support\Facades\Log; -class PullChangelogFromGitHub implements ShouldBeEncrypted, ShouldQueue +class PullChangelog implements ShouldBeEncrypted, ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; @@ -26,21 +27,36 @@ class PullChangelogFromGitHub implements ShouldBeEncrypted, ShouldQueue public function handle(): void { try { + // Fetch from CDN instead of GitHub API to avoid rate limits + $cdnUrl = config('constants.coolify.releases_url'); + $response = Http::retry(3, 1000) ->timeout(30) - ->get('https://api.github.com/repos/coollabsio/coolify/releases?per_page=10'); + ->get($cdnUrl); if ($response->successful()) { $releases = $response->json(); + + // Limit to 10 releases for processing (same as before) + $releases = array_slice($releases, 0, 10); + $changelog = $this->transformReleasesToChangelog($releases); // Group entries by month and save them $this->saveChangelogEntries($changelog); } else { - send_internal_notification('PullChangelogFromGitHub failed with: '.$response->status().' '.$response->body()); + // Log error instead of sending notification + Log::error('PullChangelogFromGitHub: Failed to fetch from CDN', [ + 'status' => $response->status(), + 'url' => $cdnUrl, + ]); } } catch (\Throwable $e) { - send_internal_notification('PullChangelogFromGitHub failed with: '.$e->getMessage()); + // Log error instead of sending notification + Log::error('PullChangelogFromGitHub: Exception occurred', [ + 'message' => $e->getMessage(), + 'trace' => $e->getTraceAsString(), + ]); } } diff --git a/app/Livewire/SettingsDropdown.php b/app/Livewire/SettingsDropdown.php index 314957462..7afa763df 100644 --- a/app/Livewire/SettingsDropdown.php +++ b/app/Livewire/SettingsDropdown.php @@ -2,7 +2,7 @@ namespace App\Livewire; -use App\Jobs\PullChangelogFromGitHub; +use App\Jobs\PullChangelog; use App\Services\ChangelogService; use Illuminate\Support\Facades\Auth; use Livewire\Component; @@ -23,6 +23,11 @@ class SettingsDropdown extends Component return app(ChangelogService::class)->getEntriesForUser($user); } + public function getCurrentVersionProperty() + { + return 'v'.config('constants.coolify.version'); + } + public function openWhatsNewModal() { $this->showWhatsNewModal = true; @@ -50,7 +55,7 @@ class SettingsDropdown extends Component } try { - PullChangelogFromGitHub::dispatch(); + PullChangelog::dispatch(); $this->dispatch('success', 'Changelog fetch initiated! Check back in a few moments.'); } catch (\Throwable $e) { $this->dispatch('error', 'Failed to fetch changelog: '.$e->getMessage()); @@ -62,6 +67,7 @@ class SettingsDropdown extends Component return view('livewire.settings-dropdown', [ 'entries' => $this->entries, 'unreadCount' => $this->unreadCount, + 'currentVersion' => $this->currentVersion, ]); } } diff --git a/config/constants.php b/config/constants.php index a75c64eaa..9c1b8b274 100644 --- a/config/constants.php +++ b/config/constants.php @@ -2,7 +2,7 @@ return [ 'coolify' => [ - 'version' => '4.0.0-beta.426', + 'version' => '4.0.0-beta.427', 'helper_version' => '1.0.10', 'realtime_version' => '1.0.10', 'self_hosted' => env('SELF_HOSTED', true), @@ -12,6 +12,7 @@ return [ 'helper_image' => env('HELPER_IMAGE', env('REGISTRY_URL', 'ghcr.io').'/coollabsio/coolify-helper'), 'realtime_image' => env('REALTIME_IMAGE', env('REGISTRY_URL', 'ghcr.io').'/coollabsio/coolify-realtime'), 'is_windows_docker_desktop' => env('IS_WINDOWS_DOCKER_DESKTOP', false), + 'releases_url' => 'https://cdn.coollabs.io/coolify/releases.json', ], 'urls' => [ diff --git a/other/nightly/versions.json b/other/nightly/versions.json index b22257d04..4da699d67 100644 --- a/other/nightly/versions.json +++ b/other/nightly/versions.json @@ -1,10 +1,10 @@ { "coolify": { "v4": { - "version": "4.0.0-beta.426" + "version": "4.0.0-beta.427" }, "nightly": { - "version": "4.0.0-beta.427" + "version": "4.0.0-beta.428" }, "helper": { "version": "1.0.10" diff --git a/resources/views/livewire/settings-dropdown.blade.php b/resources/views/livewire/settings-dropdown.blade.php index c67e02923..37cc420ed 100644 --- a/resources/views/livewire/settings-dropdown.blade.php +++ b/resources/views/livewire/settings-dropdown.blade.php @@ -242,6 +242,9 @@
Stay up to date with the latest features and improvements.
++ Current version: {{ $currentVersion }} +