This commit is contained in:
Andras Bacsai
2023-05-04 09:11:11 +02:00
parent 3156d97969
commit ac976d0f3a
9 changed files with 45 additions and 40 deletions

View File

@@ -0,0 +1,24 @@
<?php
namespace App\Actions\Server;
use App\Enums\ActivityTypes;
use App\Models\Server;
class InstallDocker
{
public function __invoke(Server $server)
{
$config = base64_encode('{ "live-restore": true }');
$activity = remoteProcess([
"echo Installing Docker...",
"curl https://releases.rancher.com/install-docker/23.0.sh | sh",
"echo Configuring Docker...",
"echo '{$config}' | base64 -d > /etc/docker/daemon.json",
"echo Restarting Docker...",
"systemctl restart docker"
], $server, ActivityTypes::INLINE->value);
return $activity;
}
}

View File

@@ -1,16 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Models\Server;
use Illuminate\Http\Request;
class ServerController extends Controller
{
public function show(Server $server)
{
return view('server.show', [
'server' => $server,
]);
}
}

View File

@@ -3,6 +3,8 @@
namespace App\Http\Livewire\PrivateKey;
use App\Models\PrivateKey;
use Illuminate\Routing\Route as RoutingRoute;
use Illuminate\Support\Facades\Route;
use Livewire\Component;
class Create extends Component
@@ -10,6 +12,12 @@ class Create extends Component
public $private_key_value;
public $private_key_name;
public $private_key_description;
public string $currentRoute;
public function mount()
{
$this->currentRoute = Route::current()->uri();
}
public function createPrivateKey()
{
$this->private_key_value = trim($this->private_key_value);
@@ -23,6 +31,8 @@ class Create extends Component
'team_id' => session('currentTeam')->id
]);
session('currentTeam')->privateKeys = PrivateKey::where('team_id', session('currentTeam')->id)->get();
redirect()->route('private-key.show', $new_private_key->uuid);
if ($this->currentRoute !== 'server/new') {
redirect()->route('private-key.show', $new_private_key->uuid);
}
}
}

View File

@@ -2,9 +2,8 @@
namespace App\Http\Livewire\Server;
use App\Enums\ActivityTypes;
use App\Actions\Server\InstallDocker;
use App\Models\Server;
use Illuminate\Support\Facades\Validator;
use Livewire\Component;
class Form extends Component
@@ -28,12 +27,9 @@ class Form extends Component
}
public function installDocker()
{
$config = base64_encode('{ "live-restore": true }');
remoteProcess([
"curl https://releases.rancher.com/install-docker/23.0.sh | sh",
"echo '{$config}' | base64 -d > /etc/docker/daemon.json",
"systemctl restart docker"
], $this->server, ActivityTypes::INLINE->value);
$activity = resolve(InstallDocker::class)($this->server);
$this->emit('newMonitorActivity', $activity->id);
}
public function checkServer()
{

View File

@@ -37,7 +37,7 @@ class DeployApplicationJob implements ShouldQueue
protected string $workdir;
protected string $docker_compose;
public static int $batch_counter = 0;
public $timeout = 3600;
/**
* Create a new job instance.
*/