An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
Fix server execution method parameter name
Andras Bacsai7fb9e672cf41
diff --git a/app/Jobs/ApplicationDeployDockerImageJob.php b/app/Jobs/ApplicationDeployDockerImageJob.phpindex dda5629c83..24526937ac 100644--- a/app/Jobs/ApplicationDeployDockerImageJob.php+++ b/app/Jobs/ApplicationDeployDockerImageJob.php@@ -33,17 +33,18 @@ class ApplicationDeployDockerImageJob implements ShouldQueue, ShouldBeEncryptedray('Deploying Docker Image');try {$applicationDeploymentQueue = ApplicationDeploymentQueue::find($this->applicationDeploymentQueueId);- $application = Application::find($applicationDeploymentQueue->application_id);$deploymentUuid = data_get($applicationDeploymentQueue, 'deployment_uuid');+ $pullRequestId = data_get($applicationDeploymentQueue, 'pull_request_id');++ $application = Application::find($applicationDeploymentQueue->application_id)->firstOrFail();+ $server = data_get($application->destination, 'server');+ $network = data_get($application->destination, 'network');+$dockerImage = data_get($application, 'docker_registry_image_name');$dockerImageTag = data_get($application, 'docker_registry_image_tag');- $productionImageName = str("{$dockerImage}:{$dockerImageTag}");- $destination = $application->destination->getMorphClass()::where('id', $application->destination->id)->first();- $pullRequestId = data_get($applicationDeploymentQueue, 'pull_request_id');- $server = data_get($destination, 'server');- $network = data_get($destination, 'network');+ $productionImageName = str("{$dockerImage}:{$dockerImageTag}");$containerName = generateApplicationContainerName($application, $pullRequestId);savePrivateKeyToFs($server);@@ -53,15 +54,11 @@ class ApplicationDeployDockerImageJob implements ShouldQueue, ShouldBeEncrypted$applicationDeploymentQueue->update(['status' => ApplicationDeploymentStatus::IN_PROGRESS->value,]);- $this->executeRemoteCommand(- server: $server,- logModel: $applicationDeploymentQueue,- commands: prepareHelperContainer($server, $network, $deploymentUuid)+ $server->executeRemoteCommand(+ commands: prepareHelperContainer($server, $network, $deploymentUuid),+ loggingModel: $applicationDeploymentQueue);-- $this->executeRemoteCommand(- server: $server,- logModel: $applicationDeploymentQueue,+ $server->executeRemoteCommand(commands: generateComposeFile(deploymentUuid: $deploymentUuid,server: $server,@@ -70,13 +67,16 @@ class ApplicationDeployDockerImageJob implements ShouldQueue, ShouldBeEncryptedcontainerName: $containerName,imageName: $productionImageName,pullRequestId: $pullRequestId- )+ ),+ loggingModel: $applicationDeploymentQueue);- $this->executeRemoteCommand(- server: $server,- logModel: $applicationDeploymentQueue,- commands: rollingUpdate(application: $application, deploymentUuid: $deploymentUuid)+ $server->executeRemoteCommand(+ commands: rollingUpdate(application: $application, deploymentUuid: $deploymentUuid),+ loggingModel: $applicationDeploymentQueue);+ $applicationDeploymentQueue->update([+ 'status' => ApplicationDeploymentStatus::FINISHED->value,+ ]);} catch (Throwable $e) {$this->executeRemoteCommand(server: $server,diff --git a/app/Models/Server.php b/app/Models/Server.phpindex 7d161d5f19..50e69f3b32 100644--- a/app/Models/Server.php+++ b/app/Models/Server.php@@ -392,7 +392,7 @@ class Server extends BaseModel{return instant_remote_process(["docker network create coolify --attachable >/dev/null 2>&1 || true"], $this, false);}- public function executeRemoteCommand(Collection $commands, ApplicationDeploymentQueue $logModel)+ public function executeRemoteCommand(Collection $commands, ApplicationDeploymentQueue $loggingModel){static::$batch_counter++;foreach ($commands as $command) {@@ -406,7 +406,7 @@ class Server extends BaseModel$saveOutput = data_get($command, 'saveOutput');$remoteCommand = generateSshCommand($this, $command);- $process = Process::timeout(3600)->idleTimeout(3600)->start($remoteCommand, function (string $type, string $output) use ($command, $hidden, $customOutputType, $logModel, $saveOutput) {+ $process = Process::timeout(3600)->idleTimeout(3600)->start($remoteCommand, function (string $type, string $output) use ($command, $hidden, $customOutputType, $loggingModel, $saveOutput) {$output = str($output)->trim();if ($output->startsWith('╔')) {$output = "\n" . $output;@@ -419,22 +419,22 @@ class Server extends BaseModel'hidden' => $hidden,'batch' => static::$batch_counter,];- if (!$logModel->logs) {+ if (!$loggingModel->logs) {$new_log_entry['order'] = 1;} else {$previous_logs = json_decode($this->log_model->logs, associative: true, flags: JSON_THROW_ON_ERROR);$new_log_entry['order'] = count($previous_logs) + 1;}- $previousLogs = json_decode($logModel->logs, associative: true, flags: JSON_THROW_ON_ERROR);+ $previousLogs = json_decode($loggingModel->logs, associative: true, flags: JSON_THROW_ON_ERROR);$newLogEntry['order'] = count($previousLogs) + 1;$previousLogs[] = $newLogEntry;- $logModel->logs = json_encode($previousLogs, flags: JSON_THROW_ON_ERROR);- $logModel->save();+ $loggingModel->logs = json_encode($previousLogs, flags: JSON_THROW_ON_ERROR);+ $loggingModel->save();if ($saveOutput) {$this->remoteCommandOutputs[$saveOutput] = str($output)->trim();}});- $logModel->update([+ $loggingModel->update(['current_process_id' => $process->id(),]);@@ -442,8 +442,8 @@ class Server extends BaseModelif ($processResult->exitCode() !== 0) {if (!$ignoreErrors) {$status = ApplicationDeploymentStatus::FAILED->value;- $logModel->status = $status;- $logModel->save();+ $loggingModel->status = $status;+ $loggingModel->save();throw new \RuntimeException($processResult->errorOutput());}}