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
chore: improve code quality suggested by code rabbit
peaklabs-dev225f24e65074
diff --git a/app/Actions/Database/StartDragonfly.php b/app/Actions/Database/StartDragonfly.phpindex 99bb5fa899..882ed3c2ec 100644--- a/app/Actions/Database/StartDragonfly.php+++ b/app/Actions/Database/StartDragonfly.php@@ -36,9 +36,7 @@ class StartDragonflyif (! $this->database->enable_ssl) {$this->commands[] = "rm -rf $this->configuration_dir/ssl";- SslCertificate::where('resource_type', $this->database->getMorphClass())- ->where('resource_id', $this->database->id)- ->delete();+ $this->database->sslCertificates()->delete();$this->database->fileStorages()->where('resource_type', $this->database->getMorphClass())->where('resource_id', $this->database->id)@@ -59,9 +57,7 @@ class StartDragonfly$server = $this->database->destination->server;$caCert = SslCertificate::where('server_id', $server->id)->where('is_ca_certificate', true)->first();- $this->ssl_certificate = SslCertificate::where('resource_type', $this->database->getMorphClass())- ->where('resource_id', $this->database->id)- ->first();+ $this->ssl_certificate = $this->database->sslCertificates()->first();if (! $this->ssl_certificate) {$this->commands[] = "echo 'No SSL certificate found, generating new SSL certificate for this database.'";diff --git a/app/Actions/Database/StartKeydb.php b/app/Actions/Database/StartKeydb.phpindex 8ec076dd2c..311b5094a1 100644--- a/app/Actions/Database/StartKeydb.php+++ b/app/Actions/Database/StartKeydb.php@@ -37,9 +37,7 @@ class StartKeydbif (! $this->database->enable_ssl) {$this->commands[] = "rm -rf $this->configuration_dir/ssl";- SslCertificate::where('resource_type', $this->database->getMorphClass())- ->where('resource_id', $this->database->id)- ->delete();+ $this->database->sslCertificates()->delete();$this->database->fileStorages()->where('resource_type', $this->database->getMorphClass())->where('resource_id', $this->database->id)@@ -60,9 +58,7 @@ class StartKeydb$server = $this->database->destination->server;$caCert = SslCertificate::where('server_id', $server->id)->where('is_ca_certificate', true)->first();- $this->ssl_certificate = SslCertificate::where('resource_type', $this->database->getMorphClass())- ->where('resource_id', $this->database->id)- ->first();+ $this->ssl_certificate = $this->database->sslCertificates()->first();if (! $this->ssl_certificate) {$this->commands[] = "echo 'No SSL certificate found, generating new SSL certificate for this database.'";diff --git a/app/Actions/Database/StartMariadb.php b/app/Actions/Database/StartMariadb.phpindex 87185d0644..14df9b017b 100644--- a/app/Actions/Database/StartMariadb.php+++ b/app/Actions/Database/StartMariadb.php@@ -37,9 +37,7 @@ class StartMariadbif (! $this->database->enable_ssl) {$this->commands[] = "rm -rf $this->configuration_dir/ssl";- SslCertificate::where('resource_type', $this->database->getMorphClass())- ->where('resource_id', $this->database->id)- ->delete();+ $this->database->sslCertificates()->delete();$this->database->fileStorages()->where('resource_type', $this->database->getMorphClass())@@ -61,7 +59,7 @@ class StartMariadb$server = $this->database->destination->server;$caCert = SslCertificate::where('server_id', $server->id)->where('is_ca_certificate', true)->first();- $this->ssl_certificate = SslCertificate::where('resource_type', $this->database->getMorphClass())->where('resource_id', $this->database->id)->first();+ $this->ssl_certificate = $this->database->sslCertificates()->first();if (! $this->ssl_certificate) {$this->commands[] = "echo 'No SSL certificate found, generating new SSL certificate for this database.'";diff --git a/app/Actions/Database/StartMongodb.php b/app/Actions/Database/StartMongodb.phpindex 250cb321d7..3ea8287ac4 100644--- a/app/Actions/Database/StartMongodb.php+++ b/app/Actions/Database/StartMongodb.php@@ -42,9 +42,7 @@ class StartMongodbif (! $this->database->enable_ssl) {$this->commands[] = "rm -rf $this->configuration_dir/ssl";- SslCertificate::where('resource_type', $this->database->getMorphClass())- ->where('resource_id', $this->database->id)- ->delete();+ $this->database->sslCertificates()->delete();$this->database->fileStorages()->where('resource_type', $this->database->getMorphClass())@@ -65,7 +63,7 @@ class StartMongodb$server = $this->database->destination->server;$caCert = SslCertificate::where('server_id', $server->id)->where('is_ca_certificate', true)->first();- $this->ssl_certificate = SslCertificate::where('resource_type', $this->database->getMorphClass())->where('resource_id', $this->database->id)->first();+ $this->ssl_certificate = $this->database->sslCertificates()->first();if (! $this->ssl_certificate) {$this->commands[] = "echo 'No SSL certificate found, generating new SSL certificate for this database.'";diff --git a/app/Actions/Database/StartMysql.php b/app/Actions/Database/StartMysql.phpindex 2a9e37f9cb..a2e08c3163 100644--- a/app/Actions/Database/StartMysql.php+++ b/app/Actions/Database/StartMysql.php@@ -37,9 +37,7 @@ class StartMysqlif (! $this->database->enable_ssl) {$this->commands[] = "rm -rf $this->configuration_dir/ssl";- SslCertificate::where('resource_type', $this->database->getMorphClass())- ->where('resource_id', $this->database->id)- ->delete();+ $this->database->sslCertificates()->delete();$this->database->fileStorages()->where('resource_type', $this->database->getMorphClass())@@ -61,7 +59,7 @@ class StartMysql$server = $this->database->destination->server;$caCert = SslCertificate::where('server_id', $server->id)->where('is_ca_certificate', true)->first();- $this->ssl_certificate = SslCertificate::where('resource_type', $this->database->getMorphClass())->where('resource_id', $this->database->id)->first();+ $this->ssl_certificate = $this->database->sslCertificates()->first();if (! $this->ssl_certificate) {$this->commands[] = "echo 'No SSL certificate found, generating new SSL certificate for this database.'";diff --git a/app/Actions/Database/StartPostgresql.php b/app/Actions/Database/StartPostgresql.phpindex 8f4bcb0d93..97e565ec80 100644--- a/app/Actions/Database/StartPostgresql.php+++ b/app/Actions/Database/StartPostgresql.php@@ -42,9 +42,7 @@ class StartPostgresqlif (! $this->database->enable_ssl) {$this->commands[] = "rm -rf $this->configuration_dir/ssl";- SslCertificate::where('resource_type', $this->database->getMorphClass())- ->where('resource_id', $this->database->id)- ->delete();+ $this->database->sslCertificates()->delete();$this->database->fileStorages()->where('resource_type', $this->database->getMorphClass())@@ -66,7 +64,7 @@ class StartPostgresql$server = $this->database->destination->server;$caCert = SslCertificate::where('server_id', $server->id)->where('is_ca_certificate', true)->first();- $this->ssl_certificate = SslCertificate::where('resource_type', $this->database->getMorphClass())->where('resource_id', $this->database->id)->first();+ $this->ssl_certificate = $this->database->sslCertificates()->first();if (! $this->ssl_certificate) {$this->commands[] = "echo 'No SSL certificate found, generating new SSL certificate for this database.'";diff --git a/app/Actions/Database/StartRedis.php b/app/Actions/Database/StartRedis.phpindex edc7e0ccef..9e7a2a0849 100644--- a/app/Actions/Database/StartRedis.php+++ b/app/Actions/Database/StartRedis.php@@ -37,9 +37,7 @@ class StartRedisif (! $this->database->enable_ssl) {$this->commands[] = "rm -rf $this->configuration_dir/ssl";- SslCertificate::where('resource_type', $this->database->getMorphClass())- ->where('resource_id', $this->database->id)- ->delete();+ $this->database->sslCertificates()->delete();$this->database->fileStorages()->where('resource_type', $this->database->getMorphClass())->where('resource_id', $this->database->id)@@ -60,7 +58,7 @@ class StartRedis$server = $this->database->destination->server;$caCert = SslCertificate::where('server_id', $server->id)->where('is_ca_certificate', true)->first();- $this->ssl_certificate = SslCertificate::where('resource_type', $this->database->getMorphClass())->where('resource_id', $this->database->id)->first();+ $this->ssl_certificate = $this->database->sslCertificates()->first();if (! $this->ssl_certificate) {$this->commands[] = "echo 'No SSL certificate found, generating new SSL certificate for this database.'";diff --git a/app/Actions/Server/InstallDocker.php b/app/Actions/Server/InstallDocker.phpindex bbb3ea0660..5410b1cbd0 100644--- a/app/Actions/Server/InstallDocker.php+++ b/app/Actions/Server/InstallDocker.php@@ -25,7 +25,7 @@ class InstallDockercommonName: 'Coolify CA Certificate',serverId: $server->id,isCaCertificate: true,- validityDays: 15 * 365+ validityDays: 10 * 365);$caCertPath = config('constants.coolify.base_config_path').'/ssl/';diff --git a/app/Jobs/RegenerateSslCertJob.php b/app/Jobs/RegenerateSslCertJob.phpindex 3e4bf90706..0570227b62 100644--- a/app/Jobs/RegenerateSslCertJob.php+++ b/app/Jobs/RegenerateSslCertJob.php@@ -17,6 +17,10 @@ class RegenerateSslCertJob implements ShouldQueue{use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;+ public $tries = 3;++ public $backoff = 60;+public function __construct(protected ?Team $team = null,protected ?int $server_id = null,@@ -37,17 +41,13 @@ class RegenerateSslCertJob implements ShouldQueue$query->where('is_ca_certificate', false);- $certificates = $query->get();-- if ($certificates->isEmpty()) {- return;- }-$regenerated = collect();- foreach ($certificates as $certificate) {+ $query->cursor()->each(function ($certificate) use ($regenerated) {try {- $caCert = SslCertificate::where('server_id', $certificate->server_id)->where('is_ca_certificate', true)->first();+ $caCert = SslCertificate::where('server_id', $certificate->server_id)+ ->where('is_ca_certificate', true)+ ->first();SSLHelper::generateSslCertificate(commonName: $certificate->common_name,@@ -64,7 +64,7 @@ class RegenerateSslCertJob implements ShouldQueue} catch (\Exception $e) {Log::error('Failed to regenerate SSL certificate: '.$e->getMessage());}- }+ });if ($regenerated->isNotEmpty()) {$this->team?->notify(new SslExpirationNotification($regenerated));diff --git a/app/Livewire/Project/Database/Dragonfly/General.php b/app/Livewire/Project/Database/Dragonfly/General.phpindex bd04e4d382..51f8b5a662 100644--- a/app/Livewire/Project/Database/Dragonfly/General.php+++ b/app/Livewire/Project/Database/Dragonfly/General.php@@ -8,6 +8,7 @@ use App\Helpers\SslHelper;use App\Models\Server;use App\Models\SslCertificate;use App\Models\StandaloneDragonfly;+use Carbon\Carbon;use Exception;use Illuminate\Support\Facades\Auth;use Livewire\Attributes\Validate;@@ -52,7 +53,7 @@ class General extends Component#[Validate(['nullable', 'boolean'])]public bool $isLogDrainEnabled = false;- public $certificateValidUntil = null;+ public ?Carbon $certificateValidUntil = null;#[Validate(['nullable', 'boolean'])]public bool $enable_ssl = false;@@ -72,9 +73,7 @@ class General extends Component$this->syncData();$this->server = data_get($this->database, 'destination.server');- $existingCert = SslCertificate::where('resource_type', $this->database->getMorphClass())- ->where('resource_id', $this->database->id)- ->first();+ $existingCert = $this->database->sslCertificates()->first();if ($existingCert) {$this->certificateValidUntil = $existingCert->valid_until;@@ -205,10 +204,7 @@ class General extends Componentpublic function regenerateSslCertificate(){try {- $existingCert = SslCertificate::where('resource_type', $this->database->getMorphClass())- ->where('resource_id', $this->database->id)- ->where('server_id', $this->server->id)- ->first();+ $existingCert = $this->database->sslCertificates()->first();if (! $existingCert) {$this->dispatch('error', 'No existing SSL certificate found for this database.');diff --git a/app/Livewire/Project/Database/Keydb/General.php b/app/Livewire/Project/Database/Keydb/General.phpindex fd77373434..213b0d2d33 100644--- a/app/Livewire/Project/Database/Keydb/General.php+++ b/app/Livewire/Project/Database/Keydb/General.php@@ -8,6 +8,7 @@ use App\Helpers\SslHelper;use App\Models\Server;use App\Models\SslCertificate;use App\Models\StandaloneKeydb;+use Carbon\Carbon;use Exception;use Illuminate\Support\Facades\Auth;use Livewire\Attributes\Validate;@@ -55,7 +56,7 @@ class General extends Component#[Validate(['nullable', 'boolean'])]public bool $isLogDrainEnabled = false;- public $certificateValidUntil = null;+ public ?Carbon $certificateValidUntil = null;#[Validate(['boolean'])]public bool $enable_ssl = false;@@ -75,9 +76,7 @@ class General extends Component$this->syncData();$this->server = data_get($this->database, 'destination.server');- $existingCert = SslCertificate::where('resource_type', $this->database->getMorphClass())- ->where('resource_id', $this->database->id)- ->first();+ $existingCert = $this->database->sslCertificates()->first();if ($existingCert) {$this->certificateValidUntil = $existingCert->valid_until;@@ -210,10 +209,7 @@ class General extends Componentpublic function regenerateSslCertificate(){try {- $existingCert = SslCertificate::where('resource_type', $this->database->getMorphClass())- ->where('resource_id', $this->database->id)- ->where('server_id', $this->server->id)- ->first();+ $existingCert = $this->database->sslCertificates()->first();if (! $existingCert) {$this->dispatch('error', 'No existing SSL certificate found for this database.');diff --git a/app/Livewire/Project/Database/Mariadb/General.php b/app/Livewire/Project/Database/Mariadb/General.phpindex a963e0ca33..b0c4f5d3ed 100644--- a/app/Livewire/Project/Database/Mariadb/General.php+++ b/app/Livewire/Project/Database/Mariadb/General.php@@ -8,6 +8,7 @@ use App\Helpers\SslHelper;use App\Models\Server;use App\Models\SslCertificate;use App\Models\StandaloneMariadb;+use Carbon\Carbon;use Exception;use Livewire\Component;@@ -23,7 +24,7 @@ class General extends Componentpublic ?string $db_url_public = null;- public $certificateValidUntil = null;+ public ?Carbon $certificateValidUntil = null;protected $rules = ['database.name' => 'required',@@ -64,9 +65,7 @@ class General extends Component$this->db_url_public = $this->database->external_db_url;$this->server = data_get($this->database, 'destination.server');- $existingCert = SslCertificate::where('resource_type', $this->database->getMorphClass())- ->where('resource_id', $this->database->id)- ->first();+ $existingCert = $this->database->sslCertificates()->first();if ($existingCert) {$this->certificateValidUntil = $existingCert->valid_until;@@ -155,10 +154,7 @@ class General extends Componentpublic function regenerateSslCertificate(){try {- $existingCert = SslCertificate::where('resource_type', $this->database->getMorphClass())- ->where('resource_id', $this->database->id)- ->where('server_id', $this->server->id)- ->first();+ $existingCert = $this->database->sslCertificates()->first();if (! $existingCert) {$this->dispatch('error', 'No existing SSL certificate found for this database.');diff --git a/app/Livewire/Project/Database/Mongodb/General.php b/app/Livewire/Project/Database/Mongodb/General.phpindex 526aae9eaf..28be1c69d3 100644--- a/app/Livewire/Project/Database/Mongodb/General.php+++ b/app/Livewire/Project/Database/Mongodb/General.php@@ -8,6 +8,7 @@ use App\Helpers\SslHelper;use App\Models\Server;use App\Models\SslCertificate;use App\Models\StandaloneMongodb;+use Carbon\Carbon;use Exception;use Livewire\Component;@@ -23,7 +24,7 @@ class General extends Componentpublic ?string $db_url_public = null;- public $certificateValidUntil = null;+ public ?Carbon $certificateValidUntil = null;protected $rules = ['database.name' => 'required',@@ -64,9 +65,7 @@ class General extends Component$this->db_url_public = $this->database->external_db_url;$this->server = data_get($this->database, 'destination.server');- $existingCert = SslCertificate::where('resource_type', $this->database->getMorphClass())- ->where('resource_id', $this->database->id)- ->first();+ $existingCert = $this->database->sslCertificates()->first();if ($existingCert) {$this->certificateValidUntil = $existingCert->valid_until;@@ -159,10 +158,7 @@ class General extends Componentpublic function regenerateSslCertificate(){try {- $existingCert = SslCertificate::where('resource_type', $this->database->getMorphClass())- ->where('resource_id', $this->database->id)- ->where('server_id', $this->server->id)- ->first();+ $existingCert = $this->database->sslCertificates()->first();if (! $existingCert) {$this->dispatch('error', 'No existing SSL certificate found for this database.');diff --git a/app/Livewire/Project/Database/Mysql/General.php b/app/Livewire/Project/Database/Mysql/General.phpindex ad19db2a35..3e164d8859 100644--- a/app/Livewire/Project/Database/Mysql/General.php+++ b/app/Livewire/Project/Database/Mysql/General.php@@ -8,6 +8,7 @@ use App\Helpers\SslHelper;use App\Models\Server;use App\Models\SslCertificate;use App\Models\StandaloneMysql;+use Carbon\Carbon;use Exception;use Livewire\Component;@@ -23,7 +24,7 @@ class General extends Componentpublic ?string $db_url_public = null;- public $certificateValidUntil = null;+ public ?Carbon $certificateValidUntil = null;protected $rules = ['database.name' => 'required',@@ -66,9 +67,7 @@ class General extends Component$this->db_url_public = $this->database->external_db_url;$this->server = data_get($this->database, 'destination.server');- $existingCert = SslCertificate::where('resource_type', $this->database->getMorphClass())- ->where('resource_id', $this->database->id)- ->first();+ $existingCert = $this->database->sslCertificates()->first();if ($existingCert) {$this->certificateValidUntil = $existingCert->valid_until;@@ -158,10 +157,7 @@ class General extends Componentpublic function regenerateSslCertificate(){try {- $existingCert = SslCertificate::where('resource_type', $this->database->getMorphClass())- ->where('resource_id', $this->database->id)- ->where('server_id', $this->server->id)- ->first();+ $existingCert = $this->database->sslCertificates()->first();if (! $existingCert) {$this->dispatch('error', 'No existing SSL certificate found for this database.');diff --git a/app/Livewire/Project/Database/Postgresql/General.php b/app/Livewire/Project/Database/Postgresql/General.phpindex f5ea25865a..881c74d534 100644--- a/app/Livewire/Project/Database/Postgresql/General.php+++ b/app/Livewire/Project/Database/Postgresql/General.php@@ -8,6 +8,7 @@ use App\Helpers\SslHelper;use App\Models\Server;use App\Models\SslCertificate;use App\Models\StandalonePostgresql;+use Carbon\Carbon;use Exception;use Livewire\Component;@@ -25,7 +26,7 @@ class General extends Componentpublic ?string $db_url_public = null;- public $certificateValidUntil = null;+ public ?Carbon $certificateValidUntil = null;public function getListeners(){@@ -81,9 +82,7 @@ class General extends Component$this->db_url_public = $this->database->external_db_url;$this->server = data_get($this->database, 'destination.server');- $existingCert = SslCertificate::where('resource_type', $this->database->getMorphClass())- ->where('resource_id', $this->database->id)- ->first();+ $existingCert = $this->database->sslCertificates()->first();if ($existingCert) {$this->certificateValidUntil = $existingCert->valid_until;@@ -122,10 +121,7 @@ class General extends Componentpublic function regenerateSslCertificate(){try {- $existingCert = SslCertificate::where('resource_type', $this->database->getMorphClass())- ->where('resource_id', $this->database->id)- ->where('server_id', $this->server->id)- ->first();+ $existingCert = $this->database->sslCertificates()->first();if (! $existingCert) {$this->dispatch('error', 'No existing SSL certificate found for this database.');diff --git a/app/Livewire/Project/Database/Redis/General.php b/app/Livewire/Project/Database/Redis/General.phpindex ea896e2943..a3916277d3 100644--- a/app/Livewire/Project/Database/Redis/General.php+++ b/app/Livewire/Project/Database/Redis/General.php@@ -8,6 +8,7 @@ use App\Helpers\SslHelper;use App\Models\Server;use App\Models\SslCertificate;use App\Models\StandaloneRedis;+use Carbon\Carbon;use Exception;use Livewire\Component;@@ -32,7 +33,7 @@ class General extends Componentpublic ?string $db_url_public = null;- public $certificateValidUntil = null;+ public ?Carbon $certificateValidUntil = null;protected $rules = ['database.name' => 'required',@@ -67,9 +68,7 @@ class General extends Component{$this->server = data_get($this->database, 'destination.server');$this->refreshView();- $existingCert = SslCertificate::where('resource_type', $this->database->getMorphClass())- ->where('resource_id', $this->database->id)- ->first();+ $existingCert = $this->database->sslCertificates()->first();if ($existingCert) {$this->certificateValidUntil = $existingCert->valid_until;@@ -163,10 +162,7 @@ class General extends Componentpublic function regenerateSslCertificate(){try {- $existingCert = SslCertificate::where('resource_type', $this->database->getMorphClass())- ->where('resource_id', $this->database->id)- ->where('server_id', $this->server->id)- ->first();+ $existingCert = $this->database->sslCertificates()->first();if (! $existingCert) {$this->dispatch('error', 'No existing SSL certificate found for this database.');diff --git a/app/Livewire/Server/Advanced.php b/app/Livewire/Server/Advanced.phpindex 497ec697ef..b2b8b15183 100644--- a/app/Livewire/Server/Advanced.php+++ b/app/Livewire/Server/Advanced.php@@ -6,6 +6,7 @@ use App\Helpers\SslHelper;use App\Jobs\RegenerateSslCertJob;use App\Models\Server;use App\Models\SslCertificate;+use Carbon\Carbon;use Livewire\Attributes\Validate;use Livewire\Component;@@ -19,7 +20,7 @@ class Advanced extends Componentpublic $certificateContent = '';- public $certificateValidUntil = null;+ public ?Carbon $certificateValidUntil = null;public array $parameters = [];@@ -99,7 +100,7 @@ class Advanced extends ComponentcommonName: 'Coolify CA Certificate',serverId: $this->server->id,isCaCertificate: true,- validityDays: 15 * 365+ validityDays: 10 * 365);$this->loadCaCertificate();diff --git a/app/Models/StandaloneClickhouse.php b/app/Models/StandaloneClickhouse.phpindex 2f86c20600..bc1f9b4b37 100644--- a/app/Models/StandaloneClickhouse.php+++ b/app/Models/StandaloneClickhouse.php@@ -223,7 +223,12 @@ class StandaloneClickhouse extends BaseModelprotected function internalDbUrl(): Attribute{return new Attribute(- get: fn () => "clickhouse://{$this->clickhouse_admin_user}:{$this->clickhouse_admin_password}@{$this->uuid}:9000/{$this->clickhouse_db}",+ get: function () {+ $encodedUser = rawurlencode($this->clickhouse_admin_user);+ $encodedPass = rawurlencode($this->clickhouse_admin_password);++ return "clickhouse://{$encodedUser}:{$encodedPass}@{$this->uuid}:9000/{$this->clickhouse_db}";+ },);}@@ -232,7 +237,10 @@ class StandaloneClickhouse extends BaseModelreturn new Attribute(get: function () {if ($this->is_public && $this->public_port) {- return "clickhouse://{$this->clickhouse_admin_user}:{$this->clickhouse_admin_password}@{$this->destination->server->getIp}:{$this->public_port}/{$this->clickhouse_db}";+ $encodedUser = rawurlencode($this->clickhouse_admin_user);+ $encodedPass = rawurlencode($this->clickhouse_admin_password);++ return "clickhouse://{$encodedUser}:{$encodedPass}@{$this->destination->server->getIp}:{$this->public_port}/{$this->clickhouse_db}";}return null;diff --git a/app/Models/StandaloneDragonfly.php b/app/Models/StandaloneDragonfly.phpindex 3aaedfc52d..a14c5e3788 100644--- a/app/Models/StandaloneDragonfly.php+++ b/app/Models/StandaloneDragonfly.php@@ -226,7 +226,8 @@ class StandaloneDragonfly extends BaseModelget: function () {$scheme = $this->enable_ssl ? 'rediss' : 'redis';$port = $this->enable_ssl ? 6380 : 6379;- $url = "{$scheme}://:{$this->dragonfly_password}@{$this->uuid}:{$port}/0";+ $encodedPass = rawurlencode($this->dragonfly_password);+ $url = "{$scheme}://:{$encodedPass}@{$this->uuid}:{$port}/0";if ($this->enable_ssl && $this->ssl_mode === 'verify-ca') {$url .= '?cacert=/etc/ssl/certs/coolify-ca.crt';@@ -243,7 +244,8 @@ class StandaloneDragonfly extends BaseModelget: function () {if ($this->is_public && $this->public_port) {$scheme = $this->enable_ssl ? 'rediss' : 'redis';- $url = "{$scheme}://:{$this->dragonfly_password}@{$this->destination->server->getIp}:{$this->public_port}/0";+ $encodedPass = rawurlencode($this->dragonfly_password);+ $url = "{$scheme}://:{$encodedPass}@{$this->destination->server->getIp}:{$this->public_port}/0";if ($this->enable_ssl && $this->ssl_mode === 'verify-ca') {$url .= '?cacert=/etc/ssl/certs/coolify-ca.crt';diff --git a/app/Models/StandaloneKeydb.php b/app/Models/StandaloneKeydb.phpindex af95d58e57..2d3aea7554 100644--- a/app/Models/StandaloneKeydb.php+++ b/app/Models/StandaloneKeydb.php@@ -226,7 +226,8 @@ class StandaloneKeydb extends BaseModelget: function () {$scheme = $this->enable_ssl ? 'rediss' : 'redis';$port = $this->enable_ssl ? 6380 : 6379;- $url = "{$scheme}://:{$this->keydb_password}@{$this->uuid}:{$port}/0";+ $encodedPass = rawurlencode($this->keydb_password);+ $url = "{$scheme}://:{$encodedPass}@{$this->uuid}:{$port}/0";if ($this->enable_ssl && $this->ssl_mode === 'verify-ca') {$url .= '?cacert=/etc/ssl/certs/coolify-ca.crt';@@ -243,7 +244,8 @@ class StandaloneKeydb extends BaseModelget: function () {if ($this->is_public && $this->public_port) {$scheme = $this->enable_ssl ? 'rediss' : 'redis';- $url = "{$scheme}://:{$this->keydb_password}@{$this->destination->server->getIp}:{$this->public_port}/0";+ $encodedPass = rawurlencode($this->keydb_password);+ $url = "{$scheme}://:{$encodedPass}@{$this->destination->server->getIp}:{$this->public_port}/0";if ($this->enable_ssl && $this->ssl_mode === 'verify-ca') {$url .= '?cacert=/etc/ssl/certs/coolify-ca.crt';diff --git a/app/Models/StandaloneMariadb.php b/app/Models/StandaloneMariadb.phpindex 523fde3c52..7549ace3e4 100644--- a/app/Models/StandaloneMariadb.php+++ b/app/Models/StandaloneMariadb.php@@ -218,7 +218,12 @@ class StandaloneMariadb extends BaseModelprotected function internalDbUrl(): Attribute{return new Attribute(- get: fn () => "mysql://{$this->mariadb_user}:{$this->mariadb_password}@{$this->uuid}:3306/{$this->mariadb_database}",+ get: function () {+ $encodedUser = rawurlencode($this->mariadb_user);+ $encodedPass = rawurlencode($this->mariadb_password);++ return "mysql://{$encodedUser}:{$encodedPass}@{$this->uuid}:3306/{$this->mariadb_database}";+ },);}@@ -227,7 +232,10 @@ class StandaloneMariadb extends BaseModelreturn new Attribute(get: function () {if ($this->is_public && $this->public_port) {- return "mysql://{$this->mariadb_user}:{$this->mariadb_password}@{$this->destination->server->getIp}:{$this->public_port}/{$this->mariadb_database}";+ $encodedUser = rawurlencode($this->mariadb_user);+ $encodedPass = rawurlencode($this->mariadb_password);++ return "mysql://{$encodedUser}:{$encodedPass}@{$this->destination->server->getIp}:{$this->public_port}/{$this->mariadb_database}";}return null;diff --git a/app/Models/StandaloneMongodb.php b/app/Models/StandaloneMongodb.phpindex 0367b8650c..1b181e7d58 100644--- a/app/Models/StandaloneMongodb.php+++ b/app/Models/StandaloneMongodb.php@@ -244,13 +244,14 @@ class StandaloneMongodb extends BaseModel{return new Attribute(get: function () {- $url = "mongodb://{$this->mongo_initdb_root_username}:{$this->mongo_initdb_root_password}@{$this->uuid}:27017/?directConnection=true";+ $encodedUser = rawurlencode($this->mongo_initdb_root_username);+ $encodedPass = rawurlencode($this->mongo_initdb_root_password);+ $url = "mongodb://{$encodedUser}:{$encodedPass}@{$this->uuid}:27017/?directConnection=true";if ($this->enable_ssl) {$url .= '&tls=true';if (in_array($this->ssl_mode, ['verify-full'])) {$url .= '&tlsCAFile=/etc/ssl/certs/coolify-ca.crt';}-}return $url;@@ -263,7 +264,9 @@ class StandaloneMongodb extends BaseModelreturn new Attribute(get: function () {if ($this->is_public && $this->public_port) {- $url = "mongodb://{$this->mongo_initdb_root_username}:{$this->mongo_initdb_root_password}@{$this->destination->server->getIp}:{$this->public_port}/?directConnection=true";+ $encodedUser = rawurlencode($this->mongo_initdb_root_username);+ $encodedPass = rawurlencode($this->mongo_initdb_root_password);+ $url = "mongodb://{$encodedUser}:{$encodedPass}@{$this->destination->server->getIp}:{$this->public_port}/?directConnection=true";if ($this->enable_ssl) {$url .= '&tls=true';if (in_array($this->ssl_mode, ['verify-full'])) {diff --git a/app/Models/StandaloneMysql.php b/app/Models/StandaloneMysql.phpindex cf45df5780..dbb5b1ae60 100644--- a/app/Models/StandaloneMysql.php+++ b/app/Models/StandaloneMysql.php@@ -225,7 +225,9 @@ class StandaloneMysql extends BaseModel{return new Attribute(get: function () {- $url = "mysql://{$this->mysql_user}:{$this->mysql_password}@{$this->uuid}:3306/{$this->mysql_database}";+ $encodedUser = rawurlencode($this->mysql_user);+ $encodedPass = rawurlencode($this->mysql_password);+ $url = "mysql://{$encodedUser}:{$encodedPass}@{$this->uuid}:3306/{$this->mysql_database}";if ($this->enable_ssl) {$url .= "?ssl-mode={$this->ssl_mode}";if (in_array($this->ssl_mode, ['VERIFY_CA', 'VERIFY_IDENTITY'])) {@@ -243,7 +245,9 @@ class StandaloneMysql extends BaseModelreturn new Attribute(get: function () {if ($this->is_public && $this->public_port) {- $url = "mysql://{$this->mysql_user}:{$this->mysql_password}@{$this->destination->server->getIp}:{$this->public_port}/{$this->mysql_database}";+ $encodedUser = rawurlencode($this->mysql_user);+ $encodedPass = rawurlencode($this->mysql_password);+ $url = "mysql://{$encodedUser}:{$encodedPass}@{$this->destination->server->getIp}:{$this->public_port}/{$this->mysql_database}";if ($this->enable_ssl) {$url .= "?ssl-mode={$this->ssl_mode}";if (in_array($this->ssl_mode, ['VERIFY_CA', 'VERIFY_IDENTITY'])) {diff --git a/app/Models/StandalonePostgresql.php b/app/Models/StandalonePostgresql.phpindex 51b9d2c318..a74d567a0a 100644--- a/app/Models/StandalonePostgresql.php+++ b/app/Models/StandalonePostgresql.php@@ -220,7 +220,9 @@ class StandalonePostgresql extends BaseModel{return new Attribute(get: function () {- $url = "postgres://{$this->postgres_user}:{$this->postgres_password}@{$this->uuid}:5432/{$this->postgres_db}";+ $encodedUser = rawurlencode($this->postgres_user);+ $encodedPass = rawurlencode($this->postgres_password);+ $url = "postgres://{$encodedUser}:{$encodedPass}@{$this->uuid}:5432/{$this->postgres_db}";if ($this->enable_ssl) {$url .= "?sslmode={$this->ssl_mode}";if (in_array($this->ssl_mode, ['verify-ca', 'verify-full'])) {@@ -238,7 +240,9 @@ class StandalonePostgresql extends BaseModelreturn new Attribute(get: function () {if ($this->is_public && $this->public_port) {- $url = "postgres://{$this->postgres_user}:{$this->postgres_password}@{$this->destination->server->getIp}:{$this->public_port}/{$this->postgres_db}";+ $encodedUser = rawurlencode($this->postgres_user);+ $encodedPass = rawurlencode($this->postgres_password);+ $url = "postgres://{$encodedUser}:{$encodedPass}@{$this->destination->server->getIp}:{$this->public_port}/{$this->postgres_db}";if ($this->enable_ssl) {$url .= "?sslmode={$this->ssl_mode}";if (in_array($this->ssl_mode, ['verify-ca', 'verify-full'])) {diff --git a/app/Models/StandaloneRedis.php b/app/Models/StandaloneRedis.phpindex 2b565aa4ff..b40d8bb9d3 100644--- a/app/Models/StandaloneRedis.php+++ b/app/Models/StandaloneRedis.php@@ -221,10 +221,11 @@ class StandaloneRedis extends BaseModelreturn new Attribute(get: function () {$redis_version = $this->getRedisVersion();- $username_part = version_compare($redis_version, '6.0', '>=') ? "{$this->redis_username}:" : '';+ $username_part = version_compare($redis_version, '6.0', '>=') ? rawurlencode($this->redis_username).':' : '';+ $encodedPass = rawurlencode($this->redis_password);$scheme = $this->enable_ssl ? 'rediss' : 'redis';$port = $this->enable_ssl ? 6380 : 6379;- $url = "{$scheme}://{$username_part}{$this->redis_password}@{$this->uuid}:{$port}/0";+ $url = "{$scheme}://{$username_part}{$encodedPass}@{$this->uuid}:{$port}/0";if ($this->enable_ssl && $this->ssl_mode === 'verify-ca') {$url .= '?cacert=/etc/ssl/certs/coolify-ca.crt';@@ -241,9 +242,10 @@ class StandaloneRedis extends BaseModelget: function () {if ($this->is_public && $this->public_port) {$redis_version = $this->getRedisVersion();- $username_part = version_compare($redis_version, '6.0', '>=') ? "{$this->redis_username}:" : '';+ $username_part = version_compare($redis_version, '6.0', '>=') ? rawurlencode($this->redis_username).':' : '';+ $encodedPass = rawurlencode($this->redis_password);$scheme = $this->enable_ssl ? 'rediss' : 'redis';- $url = "{$scheme}://{$username_part}{$this->redis_password}@{$this->destination->server->getIp}:{$this->public_port}/0";+ $url = "{$scheme}://{$username_part}{$encodedPass}@{$this->destination->server->getIp}:{$this->public_port}/0";if ($this->enable_ssl && $this->ssl_mode === 'verify-ca') {$url .= '?cacert=/etc/ssl/certs/coolify-ca.crt';diff --git a/database/migrations/2025_01_30_125223_encrypt_local_file_volumes_fields.php b/database/migrations/2025_01_30_125223_encrypt_local_file_volumes_fields.phpindex f29cdaa238..c6b4f85141 100644--- a/database/migrations/2025_01_30_125223_encrypt_local_file_volumes_fields.php+++ b/database/migrations/2025_01_30_125223_encrypt_local_file_volumes_fields.php@@ -19,18 +19,21 @@ return new class extends Migration});if (DB::table('local_file_volumes')->exists()) {- $volumes = DB::table('local_file_volumes')->get();- foreach ($volumes as $volume) {- try {- DB::table('local_file_volumes')->where('id', $volume->id)->update([- 'fs_path' => $volume->fs_path ? Crypt::encryptString($volume->fs_path) : null,- 'mount_path' => $volume->mount_path ? Crypt::encryptString($volume->mount_path) : null,- 'content' => $volume->content ? Crypt::encryptString($volume->content) : null,- ]);- } catch (\Exception $e) {- Log::error('Error encrypting local file volume fields: '.$e->getMessage());- }- }+ DB::table('local_file_volumes')+ ->orderBy('id')+ ->chunk(100, function ($volumes) {+ foreach ($volumes as $volume) {+ try {+ DB::table('local_file_volumes')->where('id', $volume->id)->update([+ 'fs_path' => $volume->fs_path ? Crypt::encryptString($volume->fs_path) : null,+ 'mount_path' => $volume->mount_path ? Crypt::encryptString($volume->mount_path) : null,+ 'content' => $volume->content ? Crypt::encryptString($volume->content) : null,+ ]);+ } catch (\Exception $e) {+ Log::error('Error encrypting local file volume fields: '.$e->getMessage());+ }+ }+ });}}@@ -46,18 +49,21 @@ return new class extends Migration});if (DB::table('local_file_volumes')->exists()) {- $volumes = DB::table('local_file_volumes')->get();- foreach ($volumes as $volume) {- try {- DB::table('local_file_volumes')->where('id', $volume->id)->update([- 'fs_path' => $volume->fs_path ? Crypt::decryptString($volume->fs_path) : null,- 'mount_path' => $volume->mount_path ? Crypt::decryptString($volume->mount_path) : null,- 'content' => $volume->content ? Crypt::decryptString($volume->content) : null,- ]);- } catch (\Exception $e) {- Log::error('Error decrypting local file volume fields: '.$e->getMessage());- }- }+ DB::table('local_file_volumes')+ ->orderBy('id')+ ->chunk(100, function ($volumes) {+ foreach ($volumes as $volume) {+ try {+ DB::table('local_file_volumes')->where('id', $volume->id)->update([+ 'fs_path' => $volume->fs_path ? Crypt::decryptString($volume->fs_path) : null,+ 'mount_path' => $volume->mount_path ? Crypt::decryptString($volume->mount_path) : null,+ 'content' => $volume->content ? Crypt::decryptString($volume->content) : null,+ ]);+ } catch (\Exception $e) {+ Log::error('Error decrypting local file volume fields: '.$e->getMessage());+ }+ }+ });}}};diff --git a/database/seeders/CaSslCertSeeder.php b/database/seeders/CaSslCertSeeder.phpindex b869ff96a2..09f6cc9840 100644--- a/database/seeders/CaSslCertSeeder.php+++ b/database/seeders/CaSslCertSeeder.php@@ -20,7 +20,7 @@ class CaSslCertSeeder extends SeedercommonName: 'Coolify CA Certificate',serverId: $server->id,isCaCertificate: true,- validityDays: 15 * 365+ validityDays: 10 * 365);} else {$caCert = $existingCaCert;