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
feat: add custom redis conf
Andras Bacsai8f9949160c20
diff --git a/app/Actions/Database/StartRedis.php b/app/Actions/Database/StartRedis.phpindex 5752408694..fe02b113e9 100644--- a/app/Actions/Database/StartRedis.php+++ b/app/Actions/Database/StartRedis.php@@ -20,6 +20,9 @@ class StartRedispublic function handle(Server $server, StandaloneRedis $database){$this->database = $database;++ $startCommand = "redis-server --requirepass {$this->database->redis_password} --appendonly yes";+$container_name = $this->database->uuid;$this->configuration_dir = database_configuration_dir() . '/' . $container_name;@@ -31,12 +34,14 @@ class StartRedis$persistent_storages = $this->generate_local_persistent_volumes();$volume_names = $this->generate_local_persistent_volumes_only_volume_names();$environment_variables = $this->generate_environment_variables();+ $this->add_custom_redis();+$docker_compose = ['version' => '3.8','services' => [$container_name => ['image' => $this->database->image,- 'command' => "redis-server --requirepass {$this->database->redis_password} --appendonly yes",+ 'command' => $startCommand,'container_name' => $container_name,'environment' => $environment_variables,'restart' => RESTART_MODE,@@ -80,16 +85,15 @@ class StartRedisif (count($volume_names) > 0) {$docker_compose['volumes'] = $volume_names;}- // if (count($this->init_scripts) > 0) {- // foreach ($this->init_scripts as $init_script) {- // $docker_compose['services'][$container_name]['volumes'][] = [- // 'type' => 'bind',- // 'source' => $init_script,- // 'target' => '/docker-entrypoint-initdb.d/' . basename($init_script),- // 'read_only' => true,- // ];- // }- // }+ if (!is_null($this->database->redis_conf)) {+ $docker_compose['services'][$container_name]['volumes'][] = [+ 'type' => 'bind',+ 'source' => $this->configuration_dir . '/redis.conf',+ 'target' => '/usr/local/etc/redis/redis.conf',+ 'read_only' => true,+ ];+ $docker_compose['services'][$container_name]['command'] = $startCommand . ' /usr/local/etc/redis/redis.conf';+ }$docker_compose = Yaml::dump($docker_compose, 10);$docker_compose_base64 = base64_encode($docker_compose);$this->commands[] = "echo '{$docker_compose_base64}' | base64 -d > $this->configuration_dir/docker-compose.yml";@@ -141,4 +145,15 @@ class StartRedisreturn $environment_variables->all();}+ private function add_custom_redis()+ {+ if (is_null($this->database->redis_conf)) {+ return;+ }+ $filename = 'redis.conf';+ $content = $this->database->redis_conf;+ $content_base64 = base64_encode($content);+ $this->commands[] = "echo '{$content_base64}' | base64 -d > $this->configuration_dir/{$filename}";++ }}diff --git a/app/Http/Livewire/Project/Database/Redis/General.php b/app/Http/Livewire/Project/Database/Redis/General.phpindex 446d720c06..c8e15062a2 100644--- a/app/Http/Livewire/Project/Database/Redis/General.php+++ b/app/Http/Livewire/Project/Database/Redis/General.php@@ -16,6 +16,7 @@ class General extends Componentprotected $rules = ['database.name' => 'required','database.description' => 'nullable',+ 'database.redis_conf' => 'nullable','database.redis_password' => 'required','database.image' => 'required','database.ports_mappings' => 'nullable',@@ -25,7 +26,8 @@ class General extends Componentprotected $validationAttributes = ['database.name' => 'Name','database.description' => 'Description',- 'database.redis_password' => 'Postgres User',+ 'database.redis_conf' => 'Redis Configuration',+ 'database.redis_password' => 'Redis Password','database.image' => 'Image','database.ports_mappings' => 'Port Mapping','database.is_public' => 'Is Public',@@ -34,6 +36,9 @@ class General extends Componentpublic function submit() {try {$this->validate();+ if ($this->database->redis_conf === "") {+ $this->database->redis_conf = null;+ }$this->database->save();$this->emit('success', 'Database updated successfully.');} catch (Exception $e) {diff --git a/resources/views/livewire/project/database/redis/general.blade.php b/resources/views/livewire/project/database/redis/general.blade.phpindex 952e48bef9..a8a44b2517 100644--- a/resources/views/livewire/project/database/redis/general.blade.php+++ b/resources/views/livewire/project/database/redis/general.blade.php@@ -23,5 +23,6 @@</div><x-forms.input label="Redis URL" readonly wire:model="db_url" /></div>+ <x-forms.textarea label="Custom Redis Configuration" rows="10" id="database.redis_conf" /></form></div>