move files around
This commit is contained in:
84
app/Http/Livewire/Project/Application/Deploy.php
Normal file
84
app/Http/Livewire/Project/Application/Deploy.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Project\Application;
|
||||
|
||||
use App\Jobs\DeployApplicationJob;
|
||||
use App\Models\Application;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Livewire\Component;
|
||||
use Visus\Cuid2\Cuid2;
|
||||
|
||||
class Deploy extends Component
|
||||
{
|
||||
public string $applicationId;
|
||||
public $activity;
|
||||
public $status;
|
||||
public Application $application;
|
||||
public $destination;
|
||||
public array $parameters;
|
||||
|
||||
protected string $deployment_uuid;
|
||||
protected array $command = [];
|
||||
protected $source;
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->parameters = Route::current()->parameters();
|
||||
$this->application = Application::find($this->applicationId)->first();
|
||||
$this->destination = $this->application->destination->getMorphClass()::where('id', $this->application->destination->id)->first();
|
||||
}
|
||||
protected function setDeploymentUuid()
|
||||
{
|
||||
// Create Deployment ID
|
||||
$this->deployment_uuid = new Cuid2(7);
|
||||
$this->parameters['deployment_uuid'] = $this->deployment_uuid;
|
||||
}
|
||||
protected function redirectToDeployment()
|
||||
{
|
||||
return redirect()->route('project.application.deployment', $this->parameters);
|
||||
}
|
||||
public function start()
|
||||
{
|
||||
$this->setDeploymentUuid();
|
||||
|
||||
dispatch(new DeployApplicationJob(
|
||||
deployment_uuid: $this->deployment_uuid,
|
||||
application_uuid: $this->application->uuid,
|
||||
force_rebuild: false,
|
||||
));
|
||||
|
||||
return $this->redirectToDeployment();
|
||||
}
|
||||
public function forceRebuild()
|
||||
{
|
||||
$this->setDeploymentUuid();
|
||||
|
||||
dispatch(new DeployApplicationJob(
|
||||
deployment_uuid: $this->deployment_uuid,
|
||||
application_uuid: $this->application->uuid,
|
||||
force_rebuild: true,
|
||||
));
|
||||
|
||||
return $this->redirectToDeployment();
|
||||
}
|
||||
|
||||
public function stop()
|
||||
{
|
||||
runRemoteCommandSync($this->destination->server, ["docker stop -t 0 {$this->application->uuid} >/dev/null 2>&1"]);
|
||||
$this->application->status = 'stopped';
|
||||
$this->application->save();
|
||||
}
|
||||
public function kill()
|
||||
{
|
||||
runRemoteCommandSync($this->destination->server, ["docker rm -f {$this->application->uuid}"]);
|
||||
if ($this->application->status != 'exited') {
|
||||
$this->application->status = 'exited';
|
||||
$this->application->save();
|
||||
}
|
||||
}
|
||||
|
||||
public function pollingStatus()
|
||||
{
|
||||
$this->application->refresh();
|
||||
}
|
||||
}
|
||||
10
app/Http/Livewire/Project/Application/Destination.php
Normal file
10
app/Http/Livewire/Project/Application/Destination.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Project\Application;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
class Destination extends Component
|
||||
{
|
||||
public $destination;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Project\Application;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
class EnvironmentVariables extends Component
|
||||
{
|
||||
public array $envs = [];
|
||||
}
|
||||
74
app/Http/Livewire/Project/Application/General.php
Normal file
74
app/Http/Livewire/Project/Application/General.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Project\Application;
|
||||
|
||||
use App\Models\Application;
|
||||
use Livewire\Component;
|
||||
|
||||
class General extends Component
|
||||
{
|
||||
public string $applicationId;
|
||||
|
||||
public Application $application;
|
||||
public string $name;
|
||||
public string|null $fqdn;
|
||||
public string $git_repository;
|
||||
public string $git_branch;
|
||||
public string|null $git_commit_sha;
|
||||
public string $build_pack;
|
||||
|
||||
public bool $is_git_submodules_allowed;
|
||||
public bool $is_git_lfs_allowed;
|
||||
public bool $is_debug;
|
||||
public bool $is_previews;
|
||||
public bool $is_bot;
|
||||
public bool $is_custom_ssl;
|
||||
public bool $is_http2;
|
||||
public bool $is_auto_deploy;
|
||||
public bool $is_dual_cert;
|
||||
|
||||
protected $rules = [
|
||||
'application.name' => 'required|min:6',
|
||||
'application.fqdn' => 'nullable',
|
||||
'application.git_repository' => 'required',
|
||||
'application.git_branch' => 'required',
|
||||
'application.git_commit_sha' => 'nullable',
|
||||
'application.build_pack' => 'required',
|
||||
'application.base_directory' => 'required',
|
||||
'application.publish_directory' => 'nullable',
|
||||
'application.ports_exposes' => 'nullable',
|
||||
];
|
||||
public function instantSave()
|
||||
{
|
||||
// @TODO: find another way
|
||||
$this->application->settings->is_git_submodules_allowed = $this->is_git_submodules_allowed;
|
||||
$this->application->settings->is_git_lfs_allowed = $this->is_git_lfs_allowed;
|
||||
$this->application->settings->is_debug = $this->is_debug;
|
||||
$this->application->settings->is_previews = $this->is_previews;
|
||||
$this->application->settings->is_bot = $this->is_bot;
|
||||
$this->application->settings->is_custom_ssl = $this->is_custom_ssl;
|
||||
$this->application->settings->is_http2 = $this->is_http2;
|
||||
$this->application->settings->is_auto_deploy = $this->is_auto_deploy;
|
||||
$this->application->settings->is_dual_cert = $this->is_dual_cert;
|
||||
$this->application->settings->save();
|
||||
}
|
||||
public function mount()
|
||||
{
|
||||
$this->application = Application::find($this->applicationId)->with('destination', 'settings')->first();
|
||||
$this->is_git_submodules_allowed = $this->application->settings->is_git_submodules_allowed;
|
||||
$this->is_git_lfs_allowed = $this->application->settings->is_git_lfs_allowed;
|
||||
$this->is_debug = $this->application->settings->is_debug;
|
||||
$this->is_previews = $this->application->settings->is_previews;
|
||||
$this->is_bot = $this->application->settings->is_bot;
|
||||
$this->is_custom_ssl = $this->application->settings->is_custom_ssl;
|
||||
$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;
|
||||
|
||||
}
|
||||
public function submit()
|
||||
{
|
||||
$this->validate();
|
||||
$this->application->save();
|
||||
}
|
||||
}
|
||||
19
app/Http/Livewire/Project/Application/GetDeployments.php
Normal file
19
app/Http/Livewire/Project/Application/GetDeployments.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Project\Application;
|
||||
|
||||
use Livewire\Component;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
|
||||
class GetDeployments extends Component
|
||||
{
|
||||
public string $deployment_uuid;
|
||||
public string $created_at;
|
||||
public string $status;
|
||||
public function polling()
|
||||
{
|
||||
$activity = Activity::where('properties->deployment_uuid', '=', $this->deployment_uuid)->first();
|
||||
$this->created_at = $activity->created_at;
|
||||
$this->status = data_get($activity, 'properties.status');
|
||||
}
|
||||
}
|
||||
27
app/Http/Livewire/Project/Application/PollDeployment.php
Normal file
27
app/Http/Livewire/Project/Application/PollDeployment.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Project\Application;
|
||||
|
||||
use Livewire\Component;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
|
||||
class PollDeployment extends Component
|
||||
{
|
||||
public $activity;
|
||||
public $isKeepAliveOn = true;
|
||||
public $deployment_uuid;
|
||||
|
||||
public function polling()
|
||||
{
|
||||
if ( is_null($this->activity) && isset($this->deployment_uuid)) {
|
||||
$this->activity = Activity::where('properties->deployment_uuid', '=', $this->deployment_uuid)
|
||||
->first();
|
||||
} else {
|
||||
$this->activity?->refresh();
|
||||
}
|
||||
|
||||
if (data_get($this->activity, 'properties.status') == 'finished' || data_get($this->activity, 'properties.status') == 'failed' ) {
|
||||
$this->isKeepAliveOn = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
22
app/Http/Livewire/Project/Application/Source.php
Normal file
22
app/Http/Livewire/Project/Application/Source.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Project\Application;
|
||||
|
||||
use App\Models\Application;
|
||||
use Livewire\Component;
|
||||
|
||||
class Source extends Component
|
||||
{
|
||||
public $applicationId;
|
||||
public Application $application;
|
||||
|
||||
protected $rules = [
|
||||
'application.git_repository' => 'required',
|
||||
'application.git_branch' => 'required',
|
||||
'application.git_commit_sha' => 'nullable',
|
||||
];
|
||||
public function mount()
|
||||
{
|
||||
$this->application = Application::find($this->applicationId)->first();
|
||||
}
|
||||
}
|
||||
11
app/Http/Livewire/Project/Application/Storages.php
Normal file
11
app/Http/Livewire/Project/Application/Storages.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Project\Application;
|
||||
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Livewire\Component;
|
||||
|
||||
class Storages extends Component
|
||||
{
|
||||
public Collection $storages;
|
||||
}
|
||||
Reference in New Issue
Block a user