coolify/app/Actions/Proxy/SaveProxyConfiguration.php

33 lines
898 B
PHP
Raw Normal View History

2023-09-18 10:18:45 +00:00
<?php
namespace App\Actions\Proxy;
use App\Models\Server;
use Lorisleiva\Actions\Concerns\AsAction;
class SaveProxyConfiguration
2023-09-18 10:18:45 +00:00
{
use AsAction;
public function handle(Server $server, string $configuration): void
2023-09-18 10:18:45 +00:00
{
2024-03-11 14:08:05 +00:00
$proxy_path = $server->proxyPath();
$docker_compose_yml_base64 = base64_encode($configuration);
2023-09-18 10:18:45 +00:00
// Update the saved settings hash
$server->proxy->last_saved_settings = str($docker_compose_yml_base64)->pipe('md5')->value;
2023-09-18 10:18:45 +00:00
$server->save();
// Transfer the configuration file to the server
instant_remote_process([
2023-09-18 10:18:45 +00:00
"mkdir -p $proxy_path",
[
'transfer_file' => [
'content' => base64_decode($docker_compose_yml_base64),
'destination' => "$proxy_path/docker-compose.yml",
],
],
2023-09-18 10:18:45 +00:00
], $server);
}
}