a ton 👷♂️
This commit is contained in:
@@ -2,10 +2,8 @@
|
||||
|
||||
namespace App\Http\Livewire\Project\Application;
|
||||
|
||||
use App\Jobs\ContainerStatusJob;
|
||||
use App\Jobs\DeployApplicationJob;
|
||||
use App\Jobs\ContainerStopJob;
|
||||
use App\Models\Application;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Livewire\Component;
|
||||
use Visus\Cuid2\Cuid2;
|
||||
|
||||
@@ -24,52 +22,37 @@ class Deploy extends Component
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->parameters = getParameters();
|
||||
$this->parameters = get_parameters();
|
||||
$this->application = Application::where('id', $this->applicationId)->first();
|
||||
$this->destination = $this->application->destination->getMorphClass()::where('id', $this->application->destination->id)->first();
|
||||
// dispatch(new ContainerStatusJob($this->application->uuid));
|
||||
}
|
||||
protected function setDeploymentUuid()
|
||||
protected function set_deployment_uuid()
|
||||
{
|
||||
// Create Deployment ID
|
||||
$this->deployment_uuid = new Cuid2(7);
|
||||
$this->parameters['deployment_uuid'] = $this->deployment_uuid;
|
||||
}
|
||||
protected function redirectToDeployment()
|
||||
public function deploy(bool $force = false)
|
||||
{
|
||||
return redirect()->route('project.application.deployment', $this->parameters);
|
||||
}
|
||||
public function start()
|
||||
{
|
||||
$this->setDeploymentUuid();
|
||||
$this->set_deployment_uuid();
|
||||
|
||||
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();
|
||||
queue_application_deployment(
|
||||
application: $this->application,
|
||||
metadata: [
|
||||
'deployment_uuid' => $this->deployment_uuid,
|
||||
'application_uuid' => $this->application->uuid,
|
||||
'force_rebuild' => $force,
|
||||
]
|
||||
);
|
||||
return redirect()->route('project.application.deployments', [
|
||||
'project_uuid' => $this->parameters['project_uuid'],
|
||||
'application_uuid' => $this->parameters['application_uuid'],
|
||||
'environment_name' => $this->parameters['environment_name'],
|
||||
]);
|
||||
}
|
||||
|
||||
public function stop()
|
||||
{
|
||||
instantRemoteProcess(["docker rm -f {$this->application->uuid}"], $this->destination->server);
|
||||
if ($this->application->status != 'exited') {
|
||||
$this->application->status = 'exited';
|
||||
$this->application->save();
|
||||
}
|
||||
dispatch(new ContainerStopJob($this->application->id, $this->destination->server));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user