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 @@ class Form extends Component
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 @@ class CoolifyTask implements ShouldQueue
]);
$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 @@ use Illuminate\Database\Eloquent\Model;
class ServerSetting extends Model
{
protected $fillable = [
'server_id'
'server_id',
'is_docker_installed',
];
public function server()
{