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: raw compose make dirs fix: raw compose add coolify labels
Andras Bacsai0dd591a5ff56
diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.phpindex 8ecaacc981..0dedfd5968 100644--- a/app/Jobs/ApplicationDeploymentJob.php+++ b/app/Jobs/ApplicationDeploymentJob.php@@ -374,6 +374,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted$this->cleanup_git();$this->application->loadComposeFile(isInit: false);if ($this->application->settings->is_raw_compose_deployment_enabled) {+ $this->application->parseRawCompose();$yaml = $composeFile = $this->application->docker_compose_raw;} else {$composeFile = $this->application->parseCompose(pull_request_id: $this->pull_request_id);@@ -413,16 +414,33 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted]);}$this->write_deployment_configurations();+// Start compose file- if ($this->docker_compose_custom_start_command) {- $this->execute_remote_command(- [executeInDocker($this->deployment_uuid, "cd {$this->basedir} && {$this->docker_compose_custom_start_command}"), "hidden" => true],- );+ if ($this->application->settings->is_raw_compose_deployment_enabled) {+ if ($this->docker_compose_custom_start_command) {+ $this->execute_remote_command(+ ["cd {$this->basedir} && {$this->docker_compose_custom_start_command}", "hidden" => true],+ );+ } else {+ $server_workdir = $this->application->workdir();+ ray("SOURCE_COMMIT={$this->commit} docker compose --project-directory {$server_workdir} -f {$server_workdir}{$this->docker_compose_location} up -d");+ $this->execute_remote_command(+ ["SOURCE_COMMIT={$this->commit} docker compose --project-directory {$server_workdir} -f {$server_workdir}{$this->docker_compose_location} up -d", "hidden" => true],+ );+ }} else {- $this->execute_remote_command(- [executeInDocker($this->deployment_uuid, "SOURCE_COMMIT={$this->commit} docker compose --project-directory {$this->workdir} -f {$this->workdir}{$this->docker_compose_location} up -d"), "hidden" => true],- );+ if ($this->docker_compose_custom_start_command) {+ $this->execute_remote_command(+ [executeInDocker($this->deployment_uuid, "cd {$this->basedir} && {$this->docker_compose_custom_start_command}"), "hidden" => true],+ );+ } else {+ $this->execute_remote_command(+ [executeInDocker($this->deployment_uuid, "SOURCE_COMMIT={$this->commit} docker compose --project-directory {$this->workdir} -f {$this->workdir}{$this->docker_compose_location} up -d"), "hidden" => true],+ );+ }}++$this->application_deployment_queue->addLogEntry("New container started.");}private function deploy_dockerfile_buildpack()diff --git a/app/Livewire/Project/Application/General.php b/app/Livewire/Project/Application/General.phpindex b3c565fdd0..3279ff2d54 100644--- a/app/Livewire/Project/Application/General.php+++ b/app/Livewire/Project/Application/General.php@@ -263,7 +263,11 @@ class General extends Component}if ($this->application->build_pack === 'dockercompose') {$this->application->docker_compose_domains = json_encode($this->parsedServiceDomains);- $this->parsedServices = $this->application->parseCompose();+ if ($this->application->settings->is_raw_compose_deployment_enabled) {+ $this->application->parseRawCompose();+ } else {+ $this->parsedServices = $this->application->parseCompose();+ }}$this->application->custom_labels = base64_encode($this->customLabels);$this->application->save();diff --git a/app/Models/Application.php b/app/Models/Application.phpindex 4cb9412154..f6df1ca881 100644--- a/app/Models/Application.php+++ b/app/Models/Application.php@@ -9,6 +9,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;use Spatie\Activitylog\Models\Activity;use Illuminate\Support\Str;use RuntimeException;+use Symfony\Component\Yaml\Yaml;use Visus\Cuid2\Cuid2;class Application extends BaseModel@@ -476,6 +477,10 @@ class Application extends BaseModel}return false;}+ public function workdir()+ {+ return application_configuration_dir() . "/{$this->uuid}";+ }public function isLogDrainEnabled(){return data_get($this, 'settings.is_log_drain_enabled', false);@@ -710,6 +715,64 @@ class Application extends BaseModel];}}+ function parseRawCompose()+ {+ try {+ $yaml = Yaml::parse($this->docker_compose_raw);+ } catch (\Exception $e) {+ throw new \Exception($e->getMessage());+ }+ $services = data_get($yaml, 'services');+ $commands = collect([]);+ $services = collect($services)->map(function ($service) use ($commands) {+ $serviceVolumes = collect(data_get($service, 'volumes', []));+ if ($serviceVolumes->count() > 0) {+ foreach ($serviceVolumes as $volume) {+ $workdir = $this->workdir();+ $type = null;+ $source = null;+ if (is_string($volume)) {+ $source = Str::of($volume)->before(':');+ if ($source->startsWith('./') || $source->startsWith('/') || $source->startsWith('~')) {+ $type = Str::of('bind');+ }+ } else if (is_array($volume)) {+ $type = data_get_str($volume, 'type');+ $source = data_get_str($volume, 'source');+ }+ if ($type->value() === 'bind') {+ if ($source->value() === "/var/run/docker.sock") {+ continue;+ }+ if ($source->value() === '/tmp' || $source->value() === '/tmp/') {+ continue;+ }+ if ($source->startsWith('.')) {+ $source = $source->after('.');+ $source = $workdir . $source;+ }+ $commands->push("mkdir -p $source > /dev/null 2>&1 || true");+ }+ }+ }+ $labels = collect(data_get($service, 'labels', []));+ if (!$labels->contains('coolify.managed')) {+ $labels->push('coolify.managed=true');+ }+ if (!$labels->contains('coolify.applicationId')) {+ $labels->push('coolify.applicationId=' . $this->id);+ }+ if (!$labels->contains('coolify.type')) {+ $labels->push('coolify.type=application');+ }+ data_set($service, 'labels', $labels->toArray());+ return $service;+ });+ data_set($yaml, 'services', $services->toArray());+ $this->docker_compose_raw = Yaml::dump($yaml, 10, 2);++ instant_remote_process($commands, $this->destination->server, false);+ }function parseCompose(int $pull_request_id = 0){if ($this->docker_compose_raw) {diff --git a/app/Models/LocalFileVolume.php b/app/Models/LocalFileVolume.phpindex 3e032db0fe..a0447b5819 100644--- a/app/Models/LocalFileVolume.php+++ b/app/Models/LocalFileVolume.php@@ -3,7 +3,6 @@namespace App\Models;use Illuminate\Database\Eloquent\Factories\HasFactory;-use Illuminate\Support\Str;class LocalFileVolume extends BaseModel{diff --git a/resources/views/components/applications/links.blade.php b/resources/views/components/applications/links.blade.phpindex 92acb01a23..7f3bed2da4 100644--- a/resources/views/components/applications/links.blade.php+++ b/resources/views/components/applications/links.blade.php@@ -1,8 +1,10 @@<div class="group">- @if (data_get($application, 'fqdn') ||+ @if (+ (data_get($application, 'fqdn') ||collect(json_decode($this->application->docker_compose_domains))->count() > 0 ||data_get($application, 'previews', collect([]))->count() > 0 ||- data_get($application, 'ports_mappings_array'))+ data_get($application, 'ports_mappings_array')) &&+ data_get($application, 'settings.is_raw_compose_deployment_enabled') !== true)<label tabindex="0" class="flex items-center gap-2 cursor-pointer hover:text-white"> Open Application<x-chevron-down /></label>