forked from coollabsio/coolify
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
468 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
namespace App\Jobs; | ||
|
||
use App\Models\InstanceSettings; | ||
use App\Models\Server; | ||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Contracts\Queue\ShouldBeEncrypted; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Foundation\Bus\Dispatchable; | ||
use Illuminate\Queue\InteractsWithQueue; | ||
use Illuminate\Queue\SerializesModels; | ||
use Illuminate\Support\Facades\File; | ||
use Illuminate\Support\Facades\Http; | ||
|
||
class PullCoolifyImageJob implements ShouldQueue, ShouldBeEncrypted | ||
{ | ||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; | ||
|
||
public $timeout = 1000; | ||
|
||
public function __construct() | ||
{ | ||
} | ||
public function handle(): void | ||
{ | ||
try { | ||
if (isDev() || isCloud()) { | ||
return; | ||
} | ||
$server = Server::findOrFail(0); | ||
$response = Http::retry(3, 1000)->get('https://cdn.coollabs.io/coolify/versions.json'); | ||
if ($response->successful()) { | ||
$versions = $response->json(); | ||
File::put(base_path('versions.json'), json_encode($versions, JSON_PRETTY_PRINT)); | ||
} | ||
$latest_version = get_latest_version_of_coolify(); | ||
instant_remote_process(["docker pull -q ghcr.io/coollabsio/coolify:{$latest_version}"], $server, false); | ||
|
||
$settings = InstanceSettings::get(); | ||
$current_version = config('version'); | ||
if (!$settings->is_auto_update_enabled) { | ||
return; | ||
} | ||
if ($latest_version === $current_version) { | ||
return; | ||
} | ||
if (version_compare($latest_version, $current_version, '<')) { | ||
return; | ||
} | ||
instant_remote_process([ | ||
"curl -fsSL https://cdn.coollabs.io/coolify/upgrade.sh -o /data/coolify/source/upgrade.sh", | ||
"bash /data/coolify/source/upgrade.sh $latest_version" | ||
], $server); | ||
} catch (\Throwable $e) { | ||
throw $e; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
namespace App\Livewire\Project\Application; | ||
|
||
use App\Models\ApplicationPreview; | ||
use Livewire\Component; | ||
use Spatie\Url\Url; | ||
use Visus\Cuid2\Cuid2; | ||
|
||
class PreviewsCompose extends Component | ||
{ | ||
public $service; | ||
public $serviceName; | ||
public ApplicationPreview $preview; | ||
public function render() | ||
{ | ||
return view('livewire.project.application.previews-compose'); | ||
} | ||
public function save() | ||
{ | ||
$domain = data_get($this->service, 'domain'); | ||
$docker_compose_domains = data_get($this->preview, 'docker_compose_domains'); | ||
$docker_compose_domains = json_decode($docker_compose_domains, true); | ||
$docker_compose_domains[$this->serviceName]['domain'] = $domain; | ||
$this->preview->docker_compose_domains = json_encode($docker_compose_domains); | ||
$this->preview->save(); | ||
$this->dispatch('update_links'); | ||
$this->dispatch('success', 'Domain saved.'); | ||
} | ||
public function generate() | ||
{ | ||
$domains = collect(json_decode($this->preview->application->docker_compose_domains)) ?? collect(); | ||
$domain = $domains->first(function ($_, $key) { | ||
return $key === $this->serviceName; | ||
}); | ||
if ($domain) { | ||
$domain = data_get($domain, 'domain'); | ||
$url = Url::fromString($domain); | ||
$template = $this->preview->application->preview_url_template; | ||
$host = $url->getHost(); | ||
$schema = $url->getScheme(); | ||
$random = new Cuid2(7); | ||
$preview_fqdn = str_replace('{{random}}', $random, $template); | ||
$preview_fqdn = str_replace('{{domain}}', $host, $preview_fqdn); | ||
$preview_fqdn = str_replace('{{pr_id}}', $this->preview->pull_request_id, $preview_fqdn); | ||
$preview_fqdn = "$schema://$preview_fqdn"; | ||
$docker_compose_domains = data_get($this->preview, 'docker_compose_domains'); | ||
$docker_compose_domains = json_decode($docker_compose_domains, true); | ||
$docker_compose_domains[$this->serviceName]['domain'] = $this->service->domain = $preview_fqdn; | ||
$this->preview->docker_compose_domains = json_encode($docker_compose_domains); | ||
$this->preview->save(); | ||
} | ||
$this->dispatch('update_links'); | ||
$this->dispatch('success', 'Domain generated.'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.