2023-04-28 13:08:48 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Livewire;
|
|
|
|
|
2023-05-03 06:24:34 +00:00
|
|
|
use App\Enums\ActivityTypes;
|
2023-04-28 13:08:48 +00:00
|
|
|
use App\Models\Server;
|
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
class ForceUpgrade extends Component
|
|
|
|
{
|
|
|
|
public function upgrade()
|
|
|
|
{
|
2023-05-03 06:24:34 +00:00
|
|
|
if (config('app.env') === 'local') {
|
2023-04-28 13:08:48 +00:00
|
|
|
$server = Server::where('ip', 'coolify-testing-host')->first();
|
|
|
|
if (!$server) {
|
|
|
|
return;
|
|
|
|
}
|
2023-05-03 07:38:53 +00:00
|
|
|
instantRemoteProcess([
|
2023-04-28 13:08:48 +00:00
|
|
|
"sleep 2"
|
2023-05-03 07:38:53 +00:00
|
|
|
], $server);
|
2023-04-28 13:08:48 +00:00
|
|
|
remoteProcess([
|
|
|
|
"sleep 10"
|
2023-05-03 06:25:50 +00:00
|
|
|
], $server, ActivityTypes::INLINE->value);
|
2023-04-28 13:08:48 +00:00
|
|
|
$this->emit('updateInitiated');
|
|
|
|
} else {
|
2023-04-28 13:22:36 +00:00
|
|
|
$latestVersion = getLatestVersionOfCoolify();
|
|
|
|
|
2023-04-28 13:08:48 +00:00
|
|
|
$cdn = "https://coolify-cdn.b-cdn.net/files";
|
|
|
|
$server = Server::where('ip', 'host.docker.internal')->first();
|
|
|
|
if (!$server) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-05-03 07:38:53 +00:00
|
|
|
instantRemoteProcess([
|
2023-04-28 13:08:48 +00:00
|
|
|
"curl -fsSL $cdn/docker-compose.yml -o /data/coolify/source/docker-compose.yml",
|
|
|
|
"curl -fsSL $cdn/docker-compose.prod.yml -o /data/coolify/source/docker-compose.prod.yml",
|
|
|
|
"curl -fsSL $cdn/.env.production -o /data/coolify/source/.env.production",
|
|
|
|
"curl -fsSL $cdn/upgrade.sh -o /data/coolify/source/upgrade.sh",
|
2023-05-03 07:38:53 +00:00
|
|
|
], $server);
|
|
|
|
|
|
|
|
instantRemoteProcess([
|
2023-04-28 13:08:48 +00:00
|
|
|
"docker compose -f /data/coolify/source/docker-compose.yml -f /data/coolify/source/docker-compose.prod.yml pull",
|
2023-05-03 07:38:53 +00:00
|
|
|
], $server);
|
2023-04-28 13:08:48 +00:00
|
|
|
|
|
|
|
remoteProcess([
|
2023-04-28 13:22:36 +00:00
|
|
|
"bash /data/coolify/source/upgrade.sh $latestVersion"
|
2023-05-03 06:25:50 +00:00
|
|
|
], $server, ActivityTypes::INLINE->value);
|
2023-04-28 13:08:48 +00:00
|
|
|
|
|
|
|
$this->emit('updateInitiated');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|