Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

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

Andras Bacsai47c0080d3b5a
diff --git a/bootstrap/helpers/docker.php b/bootstrap/helpers/docker.php
index ea00f9352e..3be2ae008b 100644
--- a/bootstrap/helpers/docker.php
+++ b/bootstrap/helpers/docker.php
@@ -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
{
diff --git a/tests/Feature/DockerVersionStorageTest.php b/tests/Feature/DockerVersionStorageTest.php
index 4693846937..4f99e382fc 100644
--- a/tests/Feature/DockerVersionStorageTest.php
+++ b/tests/Feature/DockerVersionStorageTest.php
@@ -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',