diff --git a/app/Http/Livewire/Application/Heading.php b/app/Http/Livewire/Application/Heading.php new file mode 100644 index 000000000..619d4b8ba --- /dev/null +++ b/app/Http/Livewire/Application/Heading.php @@ -0,0 +1,71 @@ +parameters = getRouteParameters(); + } + + public function check_status() + { + dispatch_sync(new ApplicationContainerStatusJob( + application: $this->application, + container_name: generate_container_name($this->application->uuid), + )); + $this->application->refresh(); + } + public function deploy(bool $force_rebuild = false) + { + $this->setDeploymentUuid(); + queue_application_deployment( + application_id: $this->application->id, + deployment_uuid: $this->deploymentUuid, + force_rebuild: $force_rebuild, + ); + return redirect()->route('project.application.deployment', [ + 'project_uuid' => $this->parameters['project_uuid'], + 'application_uuid' => $this->parameters['application_uuid'], + 'deployment_uuid' => $this->deploymentUuid, + 'environment_name' => $this->parameters['environment_name'], + ]); + } + public function force_deploy_with_debug() + { + if ($this->application->settings->is_debug_enabled == false) { + $this->application->settings->is_debug_enabled = true; + $this->application->settings->save(); + } + $this->deploy(); + } + public function force_deploy_without_cache() + { + $this->deploy(force_rebuild: true); + } + public function stop() + { + remote_process( + ["docker rm -f {$this->application->uuid}"], + $this->application->destination->server + ); + $this->application->status = 'stopped'; + $this->application->save(); + } + protected function setDeploymentUuid() + { + $this->deploymentUuid = new Cuid2(7); + $this->parameters['deployment_uuid'] = $this->deploymentUuid; + } +} diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index f38cf8463..416340565 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -143,15 +143,15 @@ class ApplicationDeploymentJob implements ShouldQueue $this->execute_now([ "echo -n 'Pulling latest version of the builder image (ghcr.io/coollabsio/coolify-builder)... '", ]); - if (isDev()) { - $this->execute_now([ - "docker run -d --name {$this->deployment_uuid} --rm -v /var/run/docker.sock:/var/run/docker.sock coolify-builder", - ], isDebuggable: true); - } else { - $this->execute_now([ - "docker run --pull=always -d --name {$this->deployment_uuid} --rm -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/coollabsio/coolify-builder", - ], isDebuggable: true); - } + // if (isDev()) { + // $this->execute_now([ + // "docker run -d --name {$this->deployment_uuid} --rm -v /var/run/docker.sock:/var/run/docker.sock coolify-builder", + // ], isDebuggable: true); + // } else { + $this->execute_now([ + "docker run --pull=always -d --name {$this->deployment_uuid} --rm -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/coollabsio/coolify-builder", + ], isDebuggable: true); + // } $this->execute_now([ "echo 'Done.'" ]); @@ -300,22 +300,19 @@ COPY --from=$this->build_image_name /app/{$this->application->publish_directory} public function failed(Throwable $exception): void { - ray($exception); $this->next(ProcessStatus::ERROR->value); } private function next(string $status) { - if (!Str::of($this->application_deployment_queue->status)->startsWith('cancelled')) { - ray('Next Status: ' . $status)->green(); - $this->application_deployment_queue->update([ - 'status' => $status, - ]); - $this->activity->properties = $this->activity->properties->merge([ - 'status' => $status, - ]); - $this->activity->save(); - } + ray('Next Status: ' . $status)->green(); + $this->application_deployment_queue->update([ + 'status' => $status, + ]); + $this->activity->properties = $this->activity->properties->merge([ + 'status' => $status, + ]); + $this->activity->save(); if ($this->pull_request_id) { dispatch(new ApplicationPullRequestUpdateJob( application_id: $this->application->id, diff --git a/app/Models/ApplicationDeploymentQueue.php b/app/Models/ApplicationDeploymentQueue.php index 474c38cc8..39642813a 100644 --- a/app/Models/ApplicationDeploymentQueue.php +++ b/app/Models/ApplicationDeploymentQueue.php @@ -2,9 +2,7 @@ namespace App\Models; -use Illuminate\Contracts\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; -use Spatie\SchemalessAttributes\Casts\SchemalessAttributes; class ApplicationDeploymentQueue extends Model { diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index cc22fad99..872480a6e 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -26,7 +26,8 @@ services: - REDIS_PASSWORD - SSL_MODE=off - PHP_PM_CONTROL=dynamic - - PHP_PM_START_SERVERS=5 + - PHP_PM_START_SERVERS=1 + - PHP_PM_MIN_SPARE_SERVERS=1 - PHP_PM_MAX_SPARE_SERVERS=10 ports: - "${APP_PORT:-8000}:80" diff --git a/resources/views/livewire/project/application/deploy.blade.php b/resources/views/components/applications/actions.blade.php similarity index 95% rename from resources/views/livewire/project/application/deploy.blade.php rename to resources/views/components/applications/actions.blade.php index dda1e9a9a..d762a5360 100644 --- a/resources/views/livewire/project/application/deploy.blade.php +++ b/resources/views/components/applications/actions.blade.php @@ -1,4 +1,4 @@ -
+