Skip to content

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.

chore: prepare for PR

Andras Bacsai76a6960f4448
diff --git a/app/Actions/Database/StartKeydb.php b/app/Actions/Database/StartKeydb.php
index 58f3cda4ea..fe80a7d54c 100644
--- a/app/Actions/Database/StartKeydb.php
+++ b/app/Actions/Database/StartKeydb.php
@@ -207,6 +207,9 @@ class StartKeydb
if ($this->database->enable_ssl) {
$this->commands[] = "chown -R 999:999 $this->configuration_dir/ssl/server.key $this->configuration_dir/ssl/server.crt";
}
+ if (! is_null($this->database->keydb_conf) && ! empty($this->database->keydb_conf)) {
+ $this->commands[] = "chown 999:999 $this->configuration_dir/keydb.conf";
+ }
$this->commands[] = "docker stop -t 10 $container_name 2>/dev/null || true";
$this->commands[] = "docker rm -f $container_name 2>/dev/null || true";
$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml up -d";
diff --git a/app/Actions/Database/StartRedis.php b/app/Actions/Database/StartRedis.php
index 4e4f3ce53e..70df910544 100644
--- a/app/Actions/Database/StartRedis.php
+++ b/app/Actions/Database/StartRedis.php
@@ -204,6 +204,9 @@ class StartRedis
if ($this->database->enable_ssl) {
$this->commands[] = "chown -R 999:999 $this->configuration_dir/ssl/server.key $this->configuration_dir/ssl/server.crt";
}
+ if (! is_null($this->database->redis_conf) && ! empty($this->database->redis_conf)) {
+ $this->commands[] = "chown 999:999 $this->configuration_dir/redis.conf";
+ }
$this->commands[] = "docker stop -t 10 $container_name 2>/dev/null || true";
$this->commands[] = "docker rm -f $container_name 2>/dev/null || true";
$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml up -d";
diff --git a/tests/Unit/StartKeydbConfigPermissionTest.php b/tests/Unit/StartKeydbConfigPermissionTest.php
new file mode 100644
index 0000000000..dca3b0e8ce
--- /dev/null
+++ b/tests/Unit/StartKeydbConfigPermissionTest.php
@@ -0,0 +1,52 @@
+<?php
+
+use App\Actions\Database\StartKeydb;
+use App\Models\StandaloneKeydb;
+
+test('keydb config chown command is added when keydb_conf is set', function () {
+ $action = new StartKeydb;
+ $action->configuration_dir = '/data/coolify/databases/test-uuid';
+ $action->commands = [];
+
+ $database = Mockery::mock(StandaloneKeydb::class)->makePartial();
+ $database->shouldReceive('getAttribute')->with('keydb_conf')->andReturn('maxmemory 2gb');
+ $action->database = $database;
+
+ if (! is_null($action->database->keydb_conf) && ! empty($action->database->keydb_conf)) {
+ $action->commands[] = "chown 999:999 {$action->configuration_dir}/keydb.conf";
+ }
+
+ expect($action->commands)->toContain('chown 999:999 /data/coolify/databases/test-uuid/keydb.conf');
+});
+
+test('keydb config chown command is not added when keydb_conf is null', function () {
+ $action = new StartKeydb;
+ $action->configuration_dir = '/data/coolify/databases/test-uuid';
+ $action->commands = [];
+
+ $database = Mockery::mock(StandaloneKeydb::class)->makePartial();
+ $database->shouldReceive('getAttribute')->with('keydb_conf')->andReturn(null);
+ $action->database = $database;
+
+ if (! is_null($action->database->keydb_conf) && ! empty($action->database->keydb_conf)) {
+ $action->commands[] = "chown 999:999 {$action->configuration_dir}/keydb.conf";
+ }
+
+ expect($action->commands)->toBeEmpty();
+});
+
+test('keydb config chown command is not added when keydb_conf is empty', function () {
+ $action = new StartKeydb;
+ $action->configuration_dir = '/data/coolify/databases/test-uuid';
+ $action->commands = [];
+
+ $database = Mockery::mock(StandaloneKeydb::class)->makePartial();
+ $database->shouldReceive('getAttribute')->with('keydb_conf')->andReturn('');
+ $action->database = $database;
+
+ if (! is_null($action->database->keydb_conf) && ! empty($action->database->keydb_conf)) {
+ $action->commands[] = "chown 999:999 {$action->configuration_dir}/keydb.conf";
+ }
+
+ expect($action->commands)->toBeEmpty();
+});
diff --git a/tests/Unit/StartRedisConfigPermissionTest.php b/tests/Unit/StartRedisConfigPermissionTest.php
new file mode 100644
index 0000000000..77574287ea
--- /dev/null
+++ b/tests/Unit/StartRedisConfigPermissionTest.php
@@ -0,0 +1,53 @@
+<?php
+
+use App\Actions\Database\StartRedis;
+use App\Models\StandaloneRedis;
+
+test('redis config chown command is added when redis_conf is set', function () {
+ $action = new StartRedis;
+ $action->configuration_dir = '/data/coolify/databases/test-uuid';
+ $action->commands = [];
+
+ $database = Mockery::mock(StandaloneRedis::class)->makePartial();
+ $database->shouldReceive('getAttribute')->with('redis_conf')->andReturn('maxmemory 2gb');
+ $action->database = $database;
+
+ // Simulate the chown logic from handle()
+ if (! is_null($action->database->redis_conf) && ! empty($action->database->redis_conf)) {
+ $action->commands[] = "chown 999:999 {$action->configuration_dir}/redis.conf";
+ }
+
+ expect($action->commands)->toContain('chown 999:999 /data/coolify/databases/test-uuid/redis.conf');
+});
+
+test('redis config chown command is not added when redis_conf is null', function () {
+ $action = new StartRedis;
+ $action->configuration_dir = '/data/coolify/databases/test-uuid';
+ $action->commands = [];
+
+ $database = Mockery::mock(StandaloneRedis::class)->makePartial();
+ $database->shouldReceive('getAttribute')->with('redis_conf')->andReturn(null);
+ $action->database = $database;
+
+ if (! is_null($action->database->redis_conf) && ! empty($action->database->redis_conf)) {
+ $action->commands[] = "chown 999:999 {$action->configuration_dir}/redis.conf";
+ }
+
+ expect($action->commands)->toBeEmpty();
+});
+
+test('redis config chown command is not added when redis_conf is empty', function () {
+ $action = new StartRedis;
+ $action->configuration_dir = '/data/coolify/databases/test-uuid';
+ $action->commands = [];
+
+ $database = Mockery::mock(StandaloneRedis::class)->makePartial();
+ $database->shouldReceive('getAttribute')->with('redis_conf')->andReturn('');
+ $action->database = $database;
+
+ if (! is_null($action->database->redis_conf) && ! empty($action->database->redis_conf)) {
+ $action->commands[] = "chown 999:999 {$action->configuration_dir}/redis.conf";
+ }
+
+ expect($action->commands)->toBeEmpty();
+});