fix(helper): prefer newer fetched helper version

Use a CDN-fetched helper version when it is newer than the bundled
version, while ignoring stale stored versions.
This commit is contained in:
Andras Bacsai
2026-09-14 20:50:16 +02:00
parent 398f32712a
commit 065ca9c861
2 changed files with 47 additions and 1 deletions
+9 -1
View File
@@ -4234,6 +4234,8 @@ function coolifyHelperImage(): string
function getHelperVersion(): string
{
$configuredHelperVersion = config('constants.coolify.helper_version');
if (isDev()) {
$devHelperVersion = InstanceSettings::query()->whereKey(0)->value('dev_helper_version');
@@ -4242,7 +4244,13 @@ function getHelperVersion(): string
}
}
return config('constants.coolify.helper_version');
$fetchedHelperVersion = InstanceSettings::query()->whereKey(0)->value('helper_version');
if (! empty($fetchedHelperVersion) && version_compare($fetchedHelperVersion, $configuredHelperVersion, '>')) {
return $fetchedHelperVersion;
}
return $configuredHelperVersion;
}
function loggy($message = null, array $context = [])
+38
View File
@@ -0,0 +1,38 @@
<?php
use App\Jobs\CheckHelperImageJob;
use App\Models\InstanceSettings;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Http;
uses(RefreshDatabase::class);
beforeEach(function () {
InstanceSettings::forceCreate(['id' => 0]);
config([
'app.env' => 'production',
'constants.coolify.helper_version' => '1.0.17',
'constants.coolify.versions_url' => 'https://cdn.example.com/coolify/versions.json',
]);
});
it('uses a newer helper version after fetching it from the CDN', function () {
Http::preventStrayRequests();
Http::fake([
'https://cdn.example.com/coolify/versions.json' => Http::response([
'coolify' => ['helper' => ['version' => '1.0.18']],
]),
]);
(new CheckHelperImageJob)->handle();
expect(InstanceSettings::findOrFail(0)->helper_version)->toBe('1.0.18')
->and(getHelperVersion())->toBe('1.0.18');
});
it('does not use a stored helper version older than the bundled version', function () {
InstanceSettings::findOrFail(0)->update(['helper_version' => '1.0.16']);
expect(getHelperVersion())->toBe('1.0.17');
});