fix(docker): replace deprecated stop flags with version-aware ones

Store each server's Docker version and build stop commands via
dockerStopCommand() so newer Docker uses --timeout instead of
deprecated --time/-t. Also show Docker version in server details.
This commit is contained in:
Andras Bacsai
2026-08-13 11:17:44 +02:00
parent 6481ffffcf
commit e79230cf37
32 changed files with 697 additions and 64 deletions
+62
View File
@@ -1,10 +1,13 @@
<?php
use App\Livewire\Server\Show;
use App\Livewire\Server\ValidateAndInstall;
use App\Models\PrivateKey;
use App\Models\Server;
use App\Models\Team;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Process;
use Livewire\Livewire;
uses(RefreshDatabase::class);
@@ -16,8 +19,13 @@ beforeEach(function () {
$this->actingAs($user);
session(['currentTeam' => $this->team]);
$this->privateKey = PrivateKey::factory()->create([
'team_id' => $this->team->id,
]);
$this->server = Server::factory()->create([
'team_id' => $this->team->id,
'private_key_id' => $this->privateKey->id,
]);
});
@@ -84,6 +92,60 @@ it('returns null from gatherServerMetadata when server is not functional', funct
expect($this->server->gatherServerMetadata())->toBeNull();
});
it('stores a parsed docker version when gathering server metadata', function () {
$this->server->settings->update([
'is_reachable' => true,
'is_usable' => true,
]);
Process::fake([
'*' => Process::result(output: implode("\n", [
'---PRETTY_NAME---',
'Debian GNU/Linux 12 (bookworm)',
'---ARCH---',
'aarch64',
'---KERNEL---',
'6.1.0-17-arm64',
'---CPUS---',
'8',
'---MEMORY---',
'17179869184',
'---UPTIME_SINCE---',
'2024-03-01 08:00:00',
'---DOCKER---',
'29.4.3-ce',
'---COMPOSE---',
'v2.32.4',
]), exitCode: 0),
]);
expect($this->server->gatherServerMetadata()['os'])->toBe('Debian GNU/Linux 12 (bookworm)')
->and($this->server->fresh()->dockerVersion())->toBe('29.4.3')
->and($this->server->fresh()->composeVersion())->toBe('2.32.4');
});
it('shows the stored docker version in remote server details', function () {
$this->server->update([
'server_metadata' => [
'os' => 'Debian GNU/Linux 12 (bookworm)',
'arch' => 'aarch64',
'kernel' => '6.1.0-17-arm64',
'cpus' => 8,
'memory_bytes' => 17179869184,
'uptime_since' => '2024-03-01 08:00:00',
'collected_at' => now()->toIso8601String(),
],
]);
$this->server->rememberDockerVersion('27.5.1');
$this->server->rememberComposeVersion('2.29.7');
Livewire::test(Show::class, ['server_uuid' => $this->server->uuid])
->assertSee('Docker version')
->assertSee('27.5.1')
->assertSee('Compose version')
->assertSee('2.29.7');
});
it('can overwrite server_metadata with new values', function () {
$this->server->update(['server_metadata' => ['os' => 'Ubuntu 20.04', 'cpus' => 2]]);
$this->server->refresh();