This commit is contained in:
Andras Bacsai 2023-06-15 13:28:16 +02:00
parent 890f0819ad
commit cbfc490d95
12 changed files with 75 additions and 43 deletions

View File

@ -2,21 +2,28 @@
namespace App\Actions\Server;
use App\Enums\ActivityTypes;
use App\Models\Server;
class InstallDocker
{
public function __invoke(Server $server)
{
$dockerVersion = '23.0';
$config = base64_encode('{ "live-restore": true }');
$activity = remote_process([
"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"
"echo ####### Installing Prerequisites...",
"command -v jq >/dev/null || apt-get update",
"command -v jq >/dev/null || apt install -y jq",
"echo ####### Installing/updating Docker Engine...",
"curl https://releases.rancher.com/install-docker/{$dockerVersion}.sh | sh",
"echo ####### Configuring Docker Engine (merging existing configuration with the required)...",
"test -s /etc/docker/daemon.json && cp /etc/docker/daemon.json \"/etc/docker/daemon.json.original-`date +\"%Y%m%d-%H%M%S\"`\" || echo '{$config}' | base64 -d > /etc/docker/daemon.json",
"echo '{$config}' | base64 -d > /etc/docker/daemon.json.coolify",
"cat <<< $(jq . /etc/docker/daemon.json.coolify) > /etc/docker/daemon.json.coolify",
"cat <<< $(jq -s '.[0] * .[1]' /etc/docker/daemon.json /etc/docker/daemon.json.coolify) > /etc/docker/daemon.json",
"echo ####### Restarting Docker Engine...",
"systemctl restart docker",
"echo ####### Done!"
], $server);
return $activity;

View File

@ -39,16 +39,15 @@ public function validateServer()
if (!$this->uptime) {
$this->uptime = 'Server not reachable.';
throw new \Exception('Server not reachable.');
} else {
if (!$this->server->settings->is_validated) {
$this->server->settings->is_validated = true;
$this->server->settings->save();
$this->emit('serverValidated');
}
}
$this->dockerVersion = instant_remote_process(['docker version|head -2|grep -i version'], $this->server, false);
if (!$this->dockerVersion) {
$this->dockerVersion = 'Not installed.';
} else {
$this->server->settings->is_docker_installed = true;
$this->server->settings->is_validated = true;
$this->server->settings->save();
$this->emit('serverValidated');
}
$this->dockerComposeVersion = instant_remote_process(['docker compose version|head -2|grep -i version'], $this->server, false);
if (!$this->dockerComposeVersion) {

View File

@ -35,6 +35,5 @@ public function handle(): void
]);
$remote_process();
// @TODO: Remove file at $this->activity->getExtraProperty('private_key_location') after process is finished
}
}

View File

@ -3,9 +3,10 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
class LocalPersistentVolume extends BaseModel
class LocalPersistentVolume extends Model
{
protected $fillable = [
'name',

View File

@ -7,7 +7,8 @@
class ServerSetting extends Model
{
protected $fillable = [
'server_id'
'server_id',
'is_docker_installed',
];
public function server()
{

View File

@ -18,7 +18,6 @@ class UserFactory extends Factory
public function definition(): array
{
return [
'uuid' => Str::uuid(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password

View File

@ -17,6 +17,7 @@ public function up(): void
$table->boolean('is_jump_server')->default(false);
$table->boolean('is_build_server')->default(false);
$table->boolean('is_validated')->default(false);
$table->boolean('is_docker_installed')->default(false);
$table->foreignId('server_id');
$table->timestamps();
});

View File

@ -1,16 +1,21 @@
<x-layout>
<main class="grid min-h-full px-6 place-items-center lg:px-8">
<div class="text-center">
<p class="text-6xl font-semibold text-warning">404</p>
<h1 class="mt-4 text-3xl font-bold tracking-tight text-white sm:text-5xl">Page not found</h1>
<p class="mt-6 text-base leading-7 text-neutral-300">Sorry, we couldnt find the page youre looking for.</p>
<div class="flex items-center justify-center mt-10 gap-x-6">
<a href="/"
class="rounded-md bg-coollabs px-3.5 py-2.5 text-sm font-semibold text-white shadow-sm hover:bg-coollabs-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 hover:no-underline">Go
back home</a>
<a href="https://docs.coollabs.io/contact.html" class="text-sm font-semibold text-white">Contact support
<span aria-hidden="true">&rarr;</span></a>
<div class="min-h-screen hero">
<div class="text-center hero-content">
<div class="">
<p class="font-mono text-6xl font-semibold text-warning">404</p>
<h1 class="mt-4 font-bold tracking-tight text-white">How did you got here?</h1>
<p class="mt-6 text-base leading-7 text-neutral-300">Sorry, we couldnt find the page youre looking for.
</p>
<div class="flex items-center justify-center mt-10 gap-x-6">
<a href="/">
<x-forms.button isHighlighted>Go back home</x-forms.button>
</a>
<a target="_blank" class="text-xs" href="https://docs.coollabs.io/contact.html">Contact
support
<x-external-link />
</a>
</div>
</div>
</div>
</main>
</div>
</x-layout>

View File

@ -1,5 +1,20 @@
@extends('errors::minimal')
@section('title', __('Page Expired'))
@section('code', '419')
@section('message', __('Page Expired'))
<x-layout>
<div class="min-h-screen hero">
<div class="text-center hero-content">
<div class="">
<p class="font-mono text-6xl font-semibold text-warning">419</p>
<h1 class="mt-4 font-bold tracking-tight text-white">This page is definitely old</h1>
<p class="mt-6 text-base leading-7 text-neutral-300">Sorry, we couldnt find the page youre looking for.
</p>
<div class="flex items-center justify-center mt-10 gap-x-6">
<a href="/"
class="rounded-md bg-coollabs px-3.5 py-2.5 text-sm font-semibold text-white shadow-sm hover:bg-coollabs-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 hover:no-underline">Go
back home</a>
<a href="https://docs.coollabs.io/contact.html" class="text-sm font-semibold text-white">Contact
support
<span aria-hidden="true">&rarr;</span></a>
</div>
</div>
</div>
</div>
</x-layout>

View File

@ -49,20 +49,30 @@
<h3 class="pt-8 pb-4">Quick Actions</h3>
<div class="flex items-center gap-2">
<x-forms.button wire:click.prevent='validateServer'>
Check Connection
Check Server Details
</x-forms.button>
<x-forms.button wire:click.prevent='installDocker'>
@if ($server->settings->is_docker_installed)
Reconfigure Docker Engine
@else
Install Docker Engine
@endif
</x-forms.button>
{{-- <x-forms.button wire:click.prevent='installDocker'>Install Docker</x-forms.button> --}}
</div>
@endif
<div class="container w-full py-4 mx-auto">
<livewire:activity-monitor :header="true" />
</div>
@isset($uptime)
<h3 class="py-3">Server Info</h3>
<h3 class="pb-3">Server Info</h3>
<div class="text-sm">
<p>Uptime: {{ $uptime }}</p>
@isset($dockerVersion)
<p>Docker Engine {{ $dockerVersion }}</p>
@endisset
@isset($dockerComposeVersion)
<p>{{ $dockerComposeVersion }}</p>
<p>Compose: {{ $dockerComposeVersion }}</p>
@endisset
</div>
@endisset

View File

@ -1,6 +1,6 @@
<div>
@if ($server->settings->is_validated)
<div wire:poll.10000ms="proxyStatus">
<div wire:poll.10000ms="proxyStatus" x-init="$wire.proxyStatus">
@if ($server->extra_attributes->proxy_status === 'running')
<x-status.running />
@elseif ($server->extra_attributes->proxy_status === 'restarting')

View File

@ -1,5 +0,0 @@
#!/bin/bash
curl https://releases.rancher.com/install-docker/23.0.sh | sh
echo "Docker installed successfully"
echo '{ "live-restore": true }' >/etc/docker/daemon.json
systemctl restart docker