autoupdate feature
This commit is contained in:
parent
9fd62b4437
commit
4d69094a1f
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use Illuminate\Support\Facades\Process;
|
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
class CheckUpdate extends Component
|
class CheckUpdate extends Component
|
||||||
@ -14,6 +13,19 @@ class CheckUpdate extends Component
|
|||||||
protected $currentVersion;
|
protected $currentVersion;
|
||||||
protected $image = 'ghcr.io/coollabsio/coolify';
|
protected $image = 'ghcr.io/coollabsio/coolify';
|
||||||
|
|
||||||
|
protected function upgrade()
|
||||||
|
{
|
||||||
|
$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']);
|
||||||
|
}
|
||||||
|
public function forceUpgrade()
|
||||||
|
{
|
||||||
|
$this->upgrade();
|
||||||
|
}
|
||||||
public function checkUpdate()
|
public function checkUpdate()
|
||||||
{
|
{
|
||||||
$response = Http::get('https://get.coollabs.io/versions.json');
|
$response = Http::get('https://get.coollabs.io/versions.json');
|
||||||
|
@ -13,6 +13,6 @@
|
|||||||
@csrf
|
@csrf
|
||||||
<button type="submit">Logout</button>
|
<button type="submit">Logout</button>
|
||||||
</form>
|
</form>
|
||||||
{{-- <livewire:check-update> --}}
|
<livewire:check-update>
|
||||||
@endauth
|
@endauth
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<button wire:click='checkUpdate'>Updates</button>
|
<button wire:click='checkUpdate'>Updates</button>
|
||||||
|
@env('production')
|
||||||
|
<button wire:click='forceUpgrade'>Force Upgrade</button>
|
||||||
|
@endenv
|
||||||
{{ $updateAvailable ? 'Update available' : 'No updates' }}
|
{{ $updateAvailable ? 'Update available' : 'No updates' }}
|
||||||
</div>
|
</div>
|
||||||
|
@ -23,18 +23,29 @@ mkdir -p /data/coolify/source
|
|||||||
chown -R 9999:root /data
|
chown -R 9999:root /data
|
||||||
chmod -R 700 /data
|
chmod -R 700 /data
|
||||||
|
|
||||||
if [ ! -z "$(ls -A /data/coolify/source/.gitignore)" ]; then
|
if [ ! -f /data/coolify/source/docker-compose.yml ]; then
|
||||||
git -C /data/coolify/source fetch --all
|
echo "Downloading docker-compose.yml..."
|
||||||
git -C /data/coolify/source reset --hard origin/${COOLIFY_VERSION_BRANCH}
|
curl -fsSL https://raw.githubusercontent.com/coollabsio/coolify/${COOLIFY_VERSION_BRANCH}/docker-compose.yml -o /data/coolify/source/docker-compose.yml
|
||||||
else
|
echo "docker-compose.yml downloaded successfully"
|
||||||
git -C /data/coolify/source clone --branch ${COOLIFY_VERSION_BRANCH} https://github.com/coollabsio/coolify .
|
fi
|
||||||
|
|
||||||
|
if [ ! -f /data/coolify/source/docker-compose.prod.yml ]; then
|
||||||
|
echo "Downloading docker-compose.prod.yml..."
|
||||||
|
curl -fsSL https://raw.githubusercontent.com/coollabsio/coolify/${COOLIFY_VERSION_BRANCH}/docker-compose.prod.yml -o /data/coolify/source/docker-compose.prod.yml
|
||||||
|
echo "docker-compose.prod.yml downloaded successfully"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f /data/coolify/source/.env.example ]; then
|
||||||
|
echo "Downloading .env.example..."
|
||||||
|
curl -fsSL https://raw.githubusercontent.com/coollabsio/coolify/${COOLIFY_VERSION_BRANCH}/.env.example -o /data/coolify/source/.env.example
|
||||||
|
echo ".env.example downloaded successfully"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy .env.example if .env does not exist
|
# Copy .env.example if .env does not exist
|
||||||
if [ ! -f /data/coolify/source/.env ]; then
|
if [ ! -f /data/coolify/source/.env ]; then
|
||||||
cp /data/coolify/source/.env.example /data/coolify/source/.env
|
cp /data/coolify/source/.env.example /data/coolify/source/.env
|
||||||
sed -i 's/APP_ENV=.*/APP_ENV=production/g' /data/coolify/source/.env
|
sed -i 's/APP_ENV=.*/APP_ENV=production/g' /data/coolify/source/.env
|
||||||
sed -i 's/APP_DEBUG=.*/APP_DEBUG=false/g' /data/coolify/source/.env
|
sed -i 's/APP_DEBUG=.*/APP_DEBUG=true/g' /data/coolify/source/.env
|
||||||
sed -i "s|APP_KEY=.*|APP_KEY=base64:$(openssl rand -base64 32)|g" /data/coolify/source/.env
|
sed -i "s|APP_KEY=.*|APP_KEY=base64:$(openssl rand -base64 32)|g" /data/coolify/source/.env
|
||||||
sed -i "s|DB_PASSWORD=.*|DB_PASSWORD=$(openssl rand -base64 32)|g" /data/coolify/source/.env
|
sed -i "s|DB_PASSWORD=.*|DB_PASSWORD=$(openssl rand -base64 32)|g" /data/coolify/source/.env
|
||||||
fi
|
fi
|
||||||
|
4
scripts/upgrade.sh
Normal file
4
scripts/upgrade.sh
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
## Do not modify this file. You will lost the ability to autoupdate!
|
||||||
|
|
||||||
|
docker compose --env-file /data/coolify/source/.env -f /data/coolify/source/docker-compose.yml -f /data/coolify/source/docker-compose.prod.yml up --pull always
|
Loading…
Reference in New Issue
Block a user