fix(docker): log docker stop command only in local development

Log the generated docker stop command and Docker version when
running locally so developers can inspect version-aware flags.
Skip logging outside local development.
This commit is contained in:
Andras Bacsai
2026-08-13 11:24:08 +02:00
parent e79230cf37
commit 47c0080d3b
2 changed files with 33 additions and 1 deletions
+11 -1
View File
@@ -7,6 +7,7 @@ use App\Models\Server;
use App\Models\ServiceApplication;
use App\Support\ValidationPatterns;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;
use Spatie\Url\Url;
use Symfony\Component\Yaml\Yaml;
@@ -251,7 +252,16 @@ function dockerStopCommand(int $timeout, string $containers, Server|string|null
? "--timeout={$timeout}"
: "--time={$timeout}";
return "docker stop {$flag} {$containers}";
$command = "docker stop {$flag} {$containers}";
if (app()->bound('config') && isDev()) {
Log::info('docker stop command', [
'command' => $command,
'docker_version' => $version,
]);
}
return $command;
}
function escapeShellValue(string $value): string
{
@@ -6,6 +6,7 @@ use App\Models\Server;
use App\Models\Team;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Process;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\Storage;
@@ -33,6 +34,27 @@ afterEach(function () {
Carbon::setTestNow();
});
it('logs the docker stop command in local development', function () {
config(['app.env' => 'local']);
Log::spy();
dockerStopCommand(30, 'app-1', '27.5.1');
Log::shouldHaveReceived('info')
->once()
->with('docker stop command', Mockery::on(fn (array $context): bool => $context['command'] === 'docker stop --time=30 app-1'
&& $context['docker_version'] === '27.5.1'));
});
it('does not log the docker stop command outside local development', function () {
config(['app.env' => 'testing']);
Log::spy();
dockerStopCommand(30, 'app-1', '27.5.1');
Log::shouldNotHaveReceived('info');
});
it('has docker and compose version columns on server settings', function () {
expect(Schema::hasColumns('server_settings', [
'docker_version',