Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

wip

Andras Bacsai321087cb6dea
diff --git a/app/Http/Livewire/CheckUpdate.php b/app/Http/Livewire/CheckUpdate.php
index 069cf60c9b..218bef150a 100644
--- a/app/Http/Livewire/CheckUpdate.php
+++ b/app/Http/Livewire/CheckUpdate.php
@@ -15,12 +15,22 @@ class CheckUpdate extends Component
protected function upgrade()
{
+ $branch = 'v4';
+ $location = "https://github.com/coollabsio/coolify/tree/$branch";
+
$server = Server::where('ip', 'host.docker.internal')->first();
if (!$server) {
return;
}
- runRemoteCommandSync($server, ['curl -fsSL https://raw.githubusercontent.com/coollabsio/coolify/v4/scripts/upgrade.sh -o /data/coolify/source/upgrade.sh']);
- runRemoteCommandSync($server, ["bash /data/coolify/source/upgrade.sh $this->latestVersion"]);
+
+ runRemoteCommandSync($server, [
+ "curl -fsSL $location/docker-compose.yml -o /data/coolify/source/docker-compose.yml",
+ "curl -fsSL $location/docker-compose.prod.yml -o /data/coolify/source/docker-compose.prod.yml",
+ "curl -fsSL $location/.env.production -o /data/coolify/source/.env.production",
+ "curl -fsSL $location/scripts/upgrade.sh -o /data/coolify/source/upgrade.sh",
+ "nohup bash /data/coolify/source/upgrade.sh $this->latestVersion &"
+ ]);
+ $this->emit('updateInitiated');
}
public function forceUpgrade()
{
diff --git a/resources/views/components/layout.blade.php b/resources/views/components/layout.blade.php
index 0dd70fc613..e814572017 100644
--- a/resources/views/components/layout.blade.php
+++ b/resources/views/components/layout.blade.php
@@ -25,6 +25,25 @@
<x-confirm-modal />
@livewireScripts
+ @auth
+ <script>
+ Livewire.on('updateInitiated', () => {
+ let checkStatus = null;
+ console.log('Update initiated')
+ setInterval(async () => {
+ const res = await fetch('/api/health');
+ if (res.ok) {
+ console.log('Server is back online')
+ clearInterval(checkStatus);
+ window.location.reload();
+ } else {
+ console.log('Waiting for server to come back online...');
+ }
+ return;
+ }, 2000);
+ })
+ </script>
+ @endauth
</body>
</html>
diff --git a/resources/views/livewire/check-update.blade.php b/resources/views/livewire/check-update.blade.php
index 3d21af1318..efdc181f49 100644
--- a/resources/views/livewire/check-update.blade.php
+++ b/resources/views/livewire/check-update.blade.php
@@ -3,14 +3,12 @@
<div wire:loading wire:target="checkUpdate">
Checking for updates...
</div>
- @env('production')
@if (auth()->user()->teams->contains(0))
<button wire:click='forceUpgrade'>Force Upgrade</button>
<div wire:loading wire:target="forceUpgrade">
Updating Coolify...
</div>
@endif
- @endenv
@if ($updateAvailable)
Update available
@endif
diff --git a/scripts/upgrade.sh b/scripts/upgrade.sh
index 3260814602..942593bea7 100644
--- a/scripts/upgrade.sh
+++ b/scripts/upgrade.sh
@@ -2,9 +2,4 @@
## Do not modify this file. You will lost the ability to autoupdate!
VERSION="0.1.0"
-if [ "$EUID" -ne 0 ]; then
- echo "Please run as root"
- exit
-fi
-
docker run --pull always -v /data/coolify/source:/data/coolify/source -v /var/run/docker.sock:/var/run/docker.sock --rm ghcr.io/coollabsio/coolify-builder bash -c "APP_TAG=${1:-} docker compose --env-file /data/coolify/source/.env -f /data/coolify/source/docker-compose.yml -f /data/coolify/source/docker-compose.prod.yml up -d --pull always --remove-orphans --force-recreate"