static hosting
This commit is contained in:
parent
cc1c08786f
commit
f4210e39f2
@ -55,6 +55,7 @@ class General extends Component
|
||||
$this->application->settings->is_auto_deploy = $this->is_auto_deploy;
|
||||
$this->application->settings->is_dual_cert = $this->is_dual_cert;
|
||||
$this->application->settings->save();
|
||||
$this->application->refresh();
|
||||
}
|
||||
public function mount()
|
||||
{
|
||||
|
@ -24,14 +24,17 @@ class PublicGitRepository extends Component
|
||||
public $swarm_docker;
|
||||
public $chosenServer;
|
||||
public $chosenDestination;
|
||||
public $is_static = false;
|
||||
public $github_apps;
|
||||
public $gitlab_apps;
|
||||
|
||||
public bool $is_static = false;
|
||||
public string $publish_directory = '';
|
||||
|
||||
protected $rules = [
|
||||
'public_repository_url' => 'required|url',
|
||||
'port' => 'required|numeric',
|
||||
'is_static' => 'required|boolean',
|
||||
'publish_directory' => 'string',
|
||||
];
|
||||
public function mount()
|
||||
{
|
||||
@ -54,10 +57,20 @@ class PublicGitRepository extends Component
|
||||
$this->chosenDestination = $instance::where('uuid', $destination_uuid)->first();
|
||||
}
|
||||
|
||||
public function instantSave()
|
||||
{
|
||||
if ($this->is_static) {
|
||||
$this->port = 80;
|
||||
$this->publish_directory = '/dist';
|
||||
} else {
|
||||
$this->port = 3000;
|
||||
$this->publish_directory = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function submit()
|
||||
{
|
||||
$this->validate();
|
||||
|
||||
$url = Url::fromString($this->public_repository_url);
|
||||
$git_host = $url->getHost();
|
||||
$git_repository = $url->getSegment(1) . '/' . $url->getSegment(2);
|
||||
@ -75,6 +88,7 @@ class PublicGitRepository extends Component
|
||||
'git_branch' => $git_branch,
|
||||
'build_pack' => 'nixpacks',
|
||||
'ports_exposes' => $this->port,
|
||||
'publish_directory' => $this->publish_directory,
|
||||
'environment_id' => $environment->id,
|
||||
'destination_id' => $this->chosenDestination->id,
|
||||
'destination_type' => $this->chosenDestination->getMorphClass(),
|
||||
@ -88,6 +102,8 @@ class PublicGitRepository extends Component
|
||||
} elseif ($git_host == 'bitbucket.org') {
|
||||
}
|
||||
$application = Application::create($application_init);
|
||||
$application->settings->is_static = $this->is_static;
|
||||
$application->settings->save();
|
||||
|
||||
return redirect()->route('project.application.configuration', [
|
||||
'project_uuid' => $project->uuid,
|
||||
|
@ -222,6 +222,7 @@ COPY --from={$this->application->uuid}:{$this->git_commit}-build /app/{$this->ap
|
||||
{
|
||||
$persistentStorages = $this->generate_local_persistent_volumes();
|
||||
$volume_names = $this->generate_local_persistent_volumes_only_volume_names();
|
||||
$ports = $this->application->settings->is_static ? [80] : $this->application->ports_exposes_array;
|
||||
$docker_compose = [
|
||||
'version' => '3.8',
|
||||
'services' => [
|
||||
@ -230,10 +231,10 @@ COPY --from={$this->application->uuid}:{$this->git_commit}-build /app/{$this->ap
|
||||
'container_name' => $this->application->uuid,
|
||||
'restart' => 'always',
|
||||
'environment' => [
|
||||
'PORT' => $this->application->ports_exposes_array[0]
|
||||
'PORT' => $ports[0]
|
||||
],
|
||||
'labels' => $this->set_labels_for_applications(),
|
||||
'expose' => $this->application->ports_exposes_array,
|
||||
'expose' => $ports,
|
||||
'networks' => [
|
||||
$this->destination->network,
|
||||
],
|
||||
|
@ -33,7 +33,9 @@ class Application extends BaseModel
|
||||
'source_type',
|
||||
'ports_mappings',
|
||||
'ports_exposes',
|
||||
'publish_directory',
|
||||
];
|
||||
|
||||
public function environment()
|
||||
{
|
||||
return $this->belongsTo(Environment::class);
|
||||
@ -55,6 +57,18 @@ class Application extends BaseModel
|
||||
return $this->morphMany(LocalPersistentVolume::class, 'resource');
|
||||
}
|
||||
|
||||
public function publishDirectory(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
set: fn ($value) => $value ? '/' . ltrim($value, '/') : null,
|
||||
);
|
||||
}
|
||||
public function baseDirectory(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
set: fn ($value) => '/' . ltrim($value, '/'),
|
||||
);
|
||||
}
|
||||
public function portsMappingsArray(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ApplicationSetting extends Model
|
||||
@ -11,6 +12,20 @@ class ApplicationSetting extends Model
|
||||
'is_git_submodules_allowed',
|
||||
'is_git_lfs_allowed',
|
||||
];
|
||||
public function isStatic(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
set: function ($value) {
|
||||
if ($value) {
|
||||
$this->application->ports_exposes = '80';
|
||||
} else {
|
||||
$this->application->ports_exposes = '3000';
|
||||
}
|
||||
$this->application->save();
|
||||
return $value;
|
||||
}
|
||||
);
|
||||
}
|
||||
public function application()
|
||||
{
|
||||
return $this->belongsTo(Application::class);
|
||||
|
@ -18,6 +18,7 @@ class FormInput extends Component
|
||||
public string|null $label = null,
|
||||
public string|null $type = 'text',
|
||||
public bool $instantSave = false,
|
||||
public bool $disabled = false,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -1,7 +0,0 @@
|
||||
<x-layout>
|
||||
<h1>{{ $title ?? 'NOT SET' }}</h1>
|
||||
<x-applications.navbar :applicationId="$applicationId" />
|
||||
<div>
|
||||
{{ $slot }}
|
||||
</div>
|
||||
</x-layout>
|
@ -26,8 +26,8 @@
|
||||
@endif
|
||||
</label>
|
||||
<input type={{ $type }} id={{ $id }} wire:model.defer={{ $id }}
|
||||
@if ($required) required @endif
|
||||
@if ($readonly) readOnly=true disabled=true @endif />
|
||||
@if ($required) required @endif @if ($disabled) disabled @endif
|
||||
@if ($readonly) readOnly disabled @endif />
|
||||
@error($id)
|
||||
<div class="text-red-500">{{ $message }}</div>
|
||||
@enderror
|
||||
|
@ -17,11 +17,11 @@
|
||||
<a target="_blank" href="{{ data_get($application, 'fqdn') }}">Open URL</a>
|
||||
@endif
|
||||
|
||||
@if (data_get($application, 'ports_exposes_array'))
|
||||
@foreach ($application->ports_exposes_array as $port)
|
||||
@if (data_get($application, 'ports_mappings_array'))
|
||||
@foreach ($application->ports_mappings_array as $port)
|
||||
@if (env('APP_ENV') === 'local')
|
||||
<a target="_blank" href="http://localhost:{{ $port }}">Open
|
||||
{{ $port }}</a>
|
||||
<a target="_blank" href="http://localhost:{{ explode(':', $port)[0] }}">Open
|
||||
{{ explode(':', $port)[0] }}</a>
|
||||
@else
|
||||
<a target="_blank"
|
||||
href="http://{{ $application->destination->server->ip }}:{{ $port }}">Open
|
||||
|
@ -11,15 +11,26 @@
|
||||
<x-form-input id="application.start_command" label="Start Command" />
|
||||
<x-form-input id="application.build_pack" label="Build Pack" />
|
||||
@if ($application->settings->is_static)
|
||||
<x-form-input id="application.static_image" label="Static Image" />
|
||||
<x-form-input id="application.static_image" label="Static Image" required />
|
||||
@endif
|
||||
</div>
|
||||
<div class="flex flex-col w-96">
|
||||
|
||||
<x-form-input id="application.base_directory" label="Base Directory" />
|
||||
<x-form-input id="application.publish_directory" label="Publish Directory" />
|
||||
@if ($application->settings->is_static)
|
||||
<x-form-input id="application.publish_directory" label="Publish Directory" required />
|
||||
@else
|
||||
<x-form-input id="application.publish_directory" label="Publish Directory" />
|
||||
@endif
|
||||
|
||||
</div>
|
||||
<div class="flex flex-col w-96">
|
||||
<x-form-input id="application.ports_exposes" label="Ports Exposes" />
|
||||
@if ($application->settings->is_static)
|
||||
<x-form-input id="application.ports_exposes" label="Ports Exposes" disabled />
|
||||
@else
|
||||
<x-form-input id="application.ports_exposes" label="Ports Exposes" />
|
||||
@endif
|
||||
|
||||
<x-form-input id="application.ports_mappings" label="Ports Mappings" />
|
||||
</div>
|
||||
</div>
|
||||
|
@ -21,8 +21,12 @@
|
||||
@isset($chosenDestination)
|
||||
<form wire:submit.prevent='submit'>
|
||||
<x-form-input id="public_repository_url" label="Repository URL" />
|
||||
<x-form-input type="checkbox" id="is_static" label="Static Site?" />
|
||||
<x-form-input type="number" id="port" label="Port" />
|
||||
<x-form-input instantSave type="checkbox" id="is_static" label="Static Site?" />
|
||||
@if ($is_static)
|
||||
<x-form-input id="publish_directory" label="Publish Directory" />
|
||||
@else
|
||||
<x-form-input type="number" id="port" label="Port" :disabled="$is_static" />
|
||||
@endif
|
||||
<button type="submit">
|
||||
Submit
|
||||
</button>
|
||||
|
@ -1,4 +1,6 @@
|
||||
<x-applications.layout :applicationId="$application->id" title="Configurations">
|
||||
<x-layout>
|
||||
<h1>Configuration</h1>
|
||||
<x-applications.navbar :applicationId="$application->id" />
|
||||
<div x-data="{ tab: window.location.hash ? window.location.hash.substring(1) : 'general' }">
|
||||
<div class="flex gap-4">
|
||||
<a @click.prevent="tab = 'general'; window.location.hash = 'general'" href="#">General</a>
|
||||
@ -25,4 +27,4 @@
|
||||
<livewire:project.application.storages :storages="$application->persistentStorages" />
|
||||
</div>
|
||||
</div>
|
||||
</x-applications.layout>
|
||||
</x-layout>
|
||||
|
@ -1,3 +1,5 @@
|
||||
<x-applications.layout :applicationId="$application->id" title="Deployment">
|
||||
<x-layout>
|
||||
<h1>Deployment</h1>
|
||||
<x-applications.navbar :applicationId="$application->id" />
|
||||
<livewire:project.application.poll-deployment :activity="$activity" :deployment_uuid="$deployment_uuid" />
|
||||
</x-applications.layout>
|
||||
</x-layout>
|
||||
|
@ -1,4 +1,6 @@
|
||||
<x-applications.layout :applicationId="$application->id" title="Deployments">
|
||||
<x-layout>
|
||||
<h1>Deployments</h1>
|
||||
<x-applications.navbar :applicationId="$application->id" />
|
||||
<div class="pt-2">
|
||||
@forelse ($deployments as $deployment)
|
||||
<livewire:project.application.get-deployments :deployment_uuid="data_get($deployment->properties, 'deployment_uuid')" :created_at="data_get($deployment, 'created_at')" :status="data_get($deployment->properties, 'status')" />
|
||||
@ -6,4 +8,4 @@
|
||||
<p>No deployments found.</p>
|
||||
@endforelse
|
||||
</div>
|
||||
</x-applications.layout>
|
||||
</x-layout>
|
||||
|
Loading…
x
Reference in New Issue
Block a user