2023-10-26 09:38:37 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Jobs;
|
|
|
|
|
|
|
|
use App\Models\Server;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldBeEncrypted;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
|
|
use Illuminate\Queue\Middleware\WithoutOverlapping;
|
|
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
|
2024-06-10 20:43:34 +00:00
|
|
|
class PullHelperImageJob implements ShouldBeEncrypted, ShouldQueue
|
2023-10-26 09:38:37 +00:00
|
|
|
{
|
|
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
|
|
|
|
public $timeout = 1000;
|
|
|
|
|
|
|
|
public function middleware(): array
|
|
|
|
{
|
2024-01-18 12:33:57 +00:00
|
|
|
return [(new WithoutOverlapping($this->server->uuid))];
|
2023-10-26 09:38:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function uniqueId(): string
|
|
|
|
{
|
|
|
|
return $this->server->uuid;
|
|
|
|
}
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-06-19 06:59:46 +00:00
|
|
|
public function __construct(public Server $server) {}
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2023-10-26 09:38:37 +00:00
|
|
|
public function handle(): void
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
$helperImage = config('coolify.helper_image');
|
|
|
|
ray("Pulling {$helperImage}");
|
2023-10-27 07:28:43 +00:00
|
|
|
instant_remote_process(["docker pull -q {$helperImage}"], $this->server, false);
|
2023-10-26 09:38:37 +00:00
|
|
|
ray('PullHelperImageJob done');
|
|
|
|
} catch (\Throwable $e) {
|
2024-06-10 20:43:34 +00:00
|
|
|
send_internal_notification('PullHelperImageJob failed with: '.$e->getMessage());
|
2023-10-26 09:38:37 +00:00
|
|
|
ray($e->getMessage());
|
|
|
|
throw $e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|