wildcard domains
This commit is contained in:
parent
ecf0b30513
commit
8f7fd4295e
@ -3,8 +3,10 @@
|
||||
namespace App\Http\Livewire\Project\Application;
|
||||
|
||||
use App\Models\Application;
|
||||
use App\Models\InstanceSettings;
|
||||
use Livewire\Component;
|
||||
use Illuminate\Support\Str;
|
||||
use Spatie\Url\Url;
|
||||
|
||||
class General extends Component
|
||||
{
|
||||
@ -17,6 +19,9 @@ class General extends Component
|
||||
public string $git_branch;
|
||||
public string|null $git_commit_sha;
|
||||
public string $build_pack;
|
||||
public string|null $wildcard_domain = null;
|
||||
public string|null $project_wildcard_domain = null;
|
||||
public string|null $global_wildcard_domain = null;
|
||||
|
||||
public bool $is_static;
|
||||
public bool $is_git_submodules_allowed;
|
||||
@ -59,6 +64,14 @@ public function instantSave()
|
||||
$this->application->settings->save();
|
||||
$this->application->refresh();
|
||||
$this->emit('saved', 'Application settings updated!');
|
||||
$this->checkWildCardDomain();
|
||||
}
|
||||
protected function checkWildCardDomain()
|
||||
{
|
||||
$coolify_instance_settings = InstanceSettings::get();
|
||||
$this->project_wildcard_domain = data_get($this->application, 'environment.project.settings.wildcard_domain');
|
||||
$this->global_wildcard_domain = data_get($coolify_instance_settings, 'wildcard_domain');
|
||||
$this->wildcard_domain = $this->project_wildcard_domain ?? $this->global_wildcard_domain ?? null;
|
||||
}
|
||||
public function mount()
|
||||
{
|
||||
@ -71,14 +84,37 @@ public function mount()
|
||||
$this->is_http2 = $this->application->settings->is_http2;
|
||||
$this->is_auto_deploy = $this->application->settings->is_auto_deploy;
|
||||
$this->is_dual_cert = $this->application->settings->is_dual_cert;
|
||||
$this->checkWildCardDomain();
|
||||
}
|
||||
public function generateGlobalRandomDomain()
|
||||
{
|
||||
// Set wildcard domain based on Global wildcard domain
|
||||
$url = Url::fromString($this->global_wildcard_domain);
|
||||
$host = $url->getHost();
|
||||
$path = $url->getPath() === '/' ? '' : $url->getPath();
|
||||
$scheme = $url->getScheme();
|
||||
$this->application->fqdn = $scheme . '://' . $this->application->uuid . '.' . $host . $path;
|
||||
$this->application->save();
|
||||
}
|
||||
public function generateProjectRandomDomain()
|
||||
{
|
||||
// Set wildcard domain based on Project wildcard domain
|
||||
$url = Url::fromString($this->project_wildcard_domain);
|
||||
$host = $url->getHost();
|
||||
$path = $url->getPath() === '/' ? '' : $url->getPath();
|
||||
$scheme = $url->getScheme();
|
||||
$this->application->fqdn = $scheme . '://' . $this->application->uuid . '.' . $host . $path;
|
||||
$this->application->save();
|
||||
}
|
||||
public function submit()
|
||||
{
|
||||
try {
|
||||
$this->validate();
|
||||
|
||||
$domains = Str::of($this->application->fqdn)->trim()->explode(',')->map(function ($domain) {
|
||||
return Str::of($domain)->trim()->lower();
|
||||
});
|
||||
|
||||
$this->application->fqdn = $domains->implode(',');
|
||||
$this->application->save();
|
||||
} catch (\Exception $e) {
|
||||
|
@ -101,21 +101,10 @@ protected function generateComposeFile()
|
||||
public function handle(): void
|
||||
{
|
||||
try {
|
||||
$coolify_instance_settings = InstanceSettings::get();
|
||||
if ($this->application->deploymentType() === 'source') {
|
||||
$this->source = $this->application->source->getMorphClass()::where('id', $this->application->source->id)->first();
|
||||
}
|
||||
|
||||
// Get Wildcard Domain
|
||||
$project_wildcard_domain = data_get($this->application, 'environment.project.settings.wildcard_domain');
|
||||
$global_wildcard_domain = data_get($coolify_instance_settings, 'wildcard_domain');
|
||||
$wildcard_domain = $project_wildcard_domain ?? $global_wildcard_domain ?? null;
|
||||
|
||||
// Set wildcard domain
|
||||
if (!$this->application->fqdn && $wildcard_domain) {
|
||||
$this->application->fqdn = 'http://' . $this->application->uuid . '.' . $wildcard_domain;
|
||||
$this->application->save();
|
||||
}
|
||||
$this->workdir = "/artifacts/{$this->deployment_uuid}";
|
||||
|
||||
// Pull builder image
|
||||
|
@ -21,6 +21,9 @@ input {
|
||||
input[type="text"],[type="number"],[type="email"],[type="password"] {
|
||||
@apply read-only:opacity-40;
|
||||
}
|
||||
.label-text, label {
|
||||
@apply text-neutral-400 text-sm;
|
||||
}
|
||||
|
||||
textarea {
|
||||
@apply textarea placeholder:text-neutral-700 text-white;
|
||||
|
@ -5,7 +5,9 @@
|
||||
'confirmAction' => null,
|
||||
'tooltip' => null,
|
||||
])
|
||||
<div class="tooltip tooltip-warning" @isset($tooltip) data-tip="{{ $tooltip }}" @endisset>
|
||||
@isset($tooltip)
|
||||
<div class="tooltip tooltip-warning" data-tip="{{ $tooltip }}">
|
||||
@endisset
|
||||
@if ($type === 'submit')
|
||||
<button {{ $attributes }} type="submit" @if ($disabled !== null) disabled @endif wire:target="submit"
|
||||
wire:loading.delay.shorter.class="loading"
|
||||
@ -31,4 +33,6 @@
|
||||
</button>
|
||||
@endif
|
||||
|
||||
</div>
|
||||
@isset($tooltip)
|
||||
</div>
|
||||
@endisset
|
||||
|
@ -8,11 +8,25 @@
|
||||
</div>
|
||||
<x-inputs.checkbox instantSave id="is_static" label="Static website?" />
|
||||
<div class="flex flex-col gap-2 pb-4">
|
||||
<div class="flex flex-col gap-2 xl:flex-row">
|
||||
<div class="flex flex-col items-end gap-2 xl:flex-row">
|
||||
<x-inputs.input class="w-full" id="application.name" label="Name" required />
|
||||
<x-inputs.input placeholder="https://coolify.io" class="w-full" id="application.fqdn" label="Domains"
|
||||
helper="You can specify one domain with path or more with comma.<br><span class='inline-block font-bold text-warning'>Example</span>- http://app.coolify.io, https://cloud.coolify.io/dashboard<br>- http://app.coolify.io/api/v3" />
|
||||
|
||||
</div>
|
||||
@if ($wildcard_domain)
|
||||
<div class="pb-6">
|
||||
<div class="text-sm">Set Random Domain</div>
|
||||
@if ($global_wildcard_domain)
|
||||
<x-inputs.button isHighlighted wire:click="generateGlobalRandomDomain">Global Wildcard
|
||||
</x-inputs.button>
|
||||
@endif
|
||||
@if ($project_wildcard_domain)
|
||||
<x-inputs.button isHighlighted wire:click="generateProjectRandomDomain">Project Wildcard
|
||||
</x-inputs.button>
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
<x-inputs.select id="application.build_pack" label="Build Pack" required>
|
||||
<option value="nixpacks">Nixpacks</option>
|
||||
<option disabled value="docker">Docker</option>
|
||||
@ -24,7 +38,7 @@
|
||||
<option disabled value="apache:alpine">apache:alpine</option>
|
||||
</x-inputs.select>
|
||||
@endif
|
||||
<div class="flex flex-col gap-2 xl:flex-row">
|
||||
<div class="flex flex-col gap-2 pb-6 xl:flex-row">
|
||||
<x-inputs.input placeholder="pnpm install" id="application.install_command" label="Install Command" />
|
||||
<x-inputs.input placeholder="pnpm build" id="application.build_command" label="Build Command" />
|
||||
<x-inputs.input placeholder="pnpm start" id="application.start_command" label="Start Command" />
|
||||
@ -54,7 +68,6 @@
|
||||
<div class="flex flex-col">
|
||||
<x-inputs.checkbox helper="More logs will be visible during a deployment." instantSave id="is_debug"
|
||||
label="Debug" />
|
||||
|
||||
<x-inputs.checkbox helper="Automatically deploy new commits based on Git webhooks." instantSave
|
||||
id="is_auto_deploy" label="Auto Deploy?" />
|
||||
{{-- <x-inputs.checkbox helper="Preview deployments" instantSave id="is_previews" label="Previews?" /> --}}
|
||||
|
@ -2,8 +2,9 @@
|
||||
<form wire:submit.prevent='submit' class="flex flex-col">
|
||||
<div class="flex flex-col gap-2 xl:flex-row">
|
||||
<div class="flex flex-col w-96">
|
||||
<x-inputs.input id="settings.fqdn" label="FQDN" />
|
||||
<x-inputs.input id="settings.wildcard_domain" label="Wildcard Domain" />
|
||||
<x-inputs.input id="settings.fqdn" label="Coolify's Domain" />
|
||||
<x-inputs.input id="settings.wildcard_domain" label="Wildcard Domain"
|
||||
helper="Wildcard domain for your applications. If you set this, you will get a random generated domain for your new applications.<br><br><span class='inline-block font-bold text-warning'>Example</span>https://example.com<br>Your applications will get https://randomthing.example.com" />
|
||||
</div>
|
||||
<div class="flex flex-col w-96">
|
||||
<x-inputs.input type="number" id="settings.public_port_min" label="Public Port Min" />
|
||||
@ -15,9 +16,9 @@
|
||||
</x-inputs.button>
|
||||
</form>
|
||||
<div class="flex flex-col pt-4 text-right w-52">
|
||||
<x-inputs.input instantSave type="checkbox" id="do_not_track" label="Do Not Track" />
|
||||
<x-inputs.input instantSave type="checkbox" id="is_auto_update_enabled" label="Auto Update?" />
|
||||
<x-inputs.input instantSave type="checkbox" id="is_registration_enabled" label="Registration Enabled?" />
|
||||
<x-inputs.input instantSave type="checkbox" id="is_https_forced" label="Force https?" />
|
||||
<x-inputs.checkbox instantSave id="is_auto_update_enabled" label="Auto Update Coolify" />
|
||||
<x-inputs.checkbox instantSave id="is_registration_enabled" label="Registration Enabled?" />
|
||||
{{-- <x-inputs.checkbox instantSave id="is_https_forced" label="Force https?" /> --}}
|
||||
<x-inputs.checkbox instantSave id="do_not_track" label="Do Not Track" />
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user