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: order feat: add batch counter
Andras Bacsai174fc76fb87b
diff --git a/app/Actions/RemoteProcess/RunRemoteProcess.php b/app/Actions/RemoteProcess/RunRemoteProcess.phpindex 31247af891..ca433b4500 100644--- a/app/Actions/RemoteProcess/RunRemoteProcess.php+++ b/app/Actions/RemoteProcess/RunRemoteProcess.php@@ -4,6 +4,7 @@ namespace App\Actions\RemoteProcess;use App\Enums\ActivityTypes;use App\Enums\ProcessStatus;+use App\Jobs\DeployApplicationJob;use Illuminate\Process\ProcessResult;use Illuminate\Support\Facades\DB;use Illuminate\Support\Facades\Process;@@ -69,6 +70,15 @@ class RunRemoteProcessreturn $processResult;}+ protected function getLatestCounter(): int+ {+ $description = json_decode($this->activity->description, associative: true, flags: JSON_THROW_ON_ERROR);+ if ($description === null || count($description) === 0) {+ return 1;+ }+ return end($description)['order'] + 1;+ }+protected function getCommand(): string{$user = $this->activity->getExtraProperty('user');@@ -106,8 +116,9 @@ class RunRemoteProcess$outputStack[] = ['type' => $type,'output' => $output,- 'elapsed_time' => $this->elapsedTime(),- 'order' => $this->counter++,+ 'timestamp' => hrtime(true),+ 'batch' => DeployApplicationJob::$batch_counter,+ 'order' => $this->getLatestCounter(),];return json_encode($outputStack, flags: JSON_THROW_ON_ERROR);@@ -115,12 +126,13 @@ class RunRemoteProcesspublic static function decodeOutput(?Activity $activity = null): string{- if(is_null($activity)) {+ if (is_null($activity)) {return '';}try {- $decoded = json_decode(data_get($activity, 'description'),+ $decoded = json_decode(+ data_get($activity, 'description'),associative: true,flags: JSON_THROW_ON_ERROR);@@ -129,9 +141,9 @@ class RunRemoteProcess}return collect($decoded)- ->sortBy(fn($i) => $i['order'])- ->map(fn($i) => $i['output'])- ->implode("\n");+ ->sortBy(fn ($i) => $i['order'])+ ->map(fn ($i) => $i['output'])+ ->implode("");}/**diff --git a/app/Jobs/DeployApplicationJob.php b/app/Jobs/DeployApplicationJob.phpindex b77c5aeed1..ac93828a13 100644--- a/app/Jobs/DeployApplicationJob.php+++ b/app/Jobs/DeployApplicationJob.php@@ -33,6 +33,7 @@ class DeployApplicationJob implements ShouldQueueprotected Activity $activity;protected string $git_commit;protected string $workdir;+ public static int $batch_counter = 0;/*** Create a new job instance.@@ -93,14 +94,14 @@ class DeployApplicationJob implements ShouldQueue"echo -n 'Pulling latest version of the builder image (ghcr.io/coollabsio/coolify-builder)... '","docker run --pull=always -d --name {$this->deployment_uuid} --rm -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/coollabsio/coolify-builder >/dev/null 2>&1","echo 'Done.'",- ], 'docker_pull_builder_image');+ ]);// Import git repository$this->executeNow(["echo -n 'Importing {$this->application->git_repository}:{$this->application->git_branch} to {$this->workdir}... '",$this->gitImport(),"echo 'Done.'"- ], 'importing_git_repository');+ ]);// Get git commit$this->executeNow([$this->execute_in_builder("cd {$this->workdir} && git rev-parse HEAD")], 'commit_sha', hideFromOutput: true);@@ -256,6 +257,7 @@ class DeployApplicationJob implements ShouldQueueprivate function executeNow(array $command, string $propertyName = null, bool $hideFromOutput = false, $setStatus = false){+ static::$batch_counter++;$commandText = collect($command)->implode("\n");$this->activity->properties = $this->activity->properties->merge([