coolify/app/Jobs/DockerCleanupDanglingImagesJob.php

41 lines
934 B
PHP
Raw Normal View History

2023-04-28 09:00:47 +02:00
<?php
namespace App\Jobs;
use App\Models\Server;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
class DockerCleanupDanglingImagesJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Create a new job instance.
*/
public function __construct()
{
//
}
/**
* Execute the job.
*/
public function handle(): void
{
2023-04-28 10:38:22 +02:00
try {
$servers = Server::all();
foreach ($servers as $server) {
instantRemoteProcess(['docker image prune -f'], $server);
2023-04-28 10:38:22 +02:00
}
} catch (\Exception $e) {
Log::error($e->getMessage());
2023-04-28 09:00:47 +02:00
}
}
}