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
Add custom PostgreSQL configuration to StandalonePostgresql
Andras Bacsaic78068466b04
diff --git a/app/Actions/Database/StartPostgresql.php b/app/Actions/Database/StartPostgresql.phpindex 46e4109801..2dc9a38b0b 100644--- a/app/Actions/Database/StartPostgresql.php+++ b/app/Actions/Database/StartPostgresql.php@@ -32,6 +32,8 @@ class StartPostgresql$volume_names = $this->generate_local_persistent_volumes_only_volume_names();$environment_variables = $this->generate_environment_variables();$this->generate_init_scripts();+ $this->add_custom_conf();+$docker_compose = ['version' => '3.8','services' => [@@ -96,6 +98,19 @@ class StartPostgresql];}}+ if (!is_null($this->database->postgres_conf)) {+ $docker_compose['services'][$container_name]['volumes'][] = [+ 'type' => 'bind',+ 'source' => $this->configuration_dir . '/custom-postgres.conf',+ 'target' => '/etc/postgresql/postgresql.conf',+ 'read_only' => true,+ ];+ $docker_compose['services'][$container_name]['command'] = [+ 'postgres',+ '-c',+ 'config_file=/etc/postgresql/postgresql.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";@@ -171,4 +186,14 @@ class StartPostgresql$this->init_scripts[] = "$this->configuration_dir/docker-entrypoint-initdb.d/{$filename}";}}+ private function add_custom_conf()+ {+ if (is_null($this->database->postgres_conf)) {+ return;+ }+ $filename = 'custom-postgres.conf';+ $content = $this->database->postgres_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/Postgresql/General.php b/app/Http/Livewire/Project/Database/Postgresql/General.phpindex 7292ec2b21..ebc69a1bcf 100644--- a/app/Http/Livewire/Project/Database/Postgresql/General.php+++ b/app/Http/Livewire/Project/Database/Postgresql/General.php@@ -28,6 +28,7 @@ class General extends Component'database.postgres_db' => 'required','database.postgres_initdb_args' => 'nullable','database.postgres_host_auth_method' => 'nullable',+ 'database.postgres_conf' => 'nullable','database.init_scripts' => 'nullable','database.image' => 'required','database.ports_mappings' => 'nullable',@@ -42,6 +43,7 @@ class General extends Component'database.postgres_db' => 'Postgres DB','database.postgres_initdb_args' => 'Postgres Initdb Args','database.postgres_host_auth_method' => 'Postgres Host Auth Method',+ 'database.postgres_conf' => 'Postgres Configuration','database.init_scripts' => 'Init Scripts','database.image' => 'Image','database.ports_mappings' => 'Port Mapping',diff --git a/database/migrations/2023_11_08_112815_add_custom_config_standalone_postgresql.php b/database/migrations/2023_11_08_112815_add_custom_config_standalone_postgresql.phpnew file mode 100644index 0000000000..c583fb3ff7--- /dev/null+++ b/database/migrations/2023_11_08_112815_add_custom_config_standalone_postgresql.php@@ -0,0 +1,30 @@+<?php++use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\Schema\Blueprint;+use Illuminate\Support\Facades\Schema;++return new class extends Migration+{+ /**+ * Run the migrations.+ */+ public function up(): void+ {+ Schema::table('standalone_postgresqls', function (Blueprint $table) {+ $table->longText('postgres_conf')->nullable();+ $table->string('image')->default('postgres:16-alpine')->change();+ });+ }++ /**+ * Reverse the migrations.+ */+ public function down(): void+ {+ Schema::table('standalone_postgresqls', function (Blueprint $table) {+ $table->dropColumn('postgres_conf');+ $table->string('image')->default('postgres:15-alpine')->change();+ });+ }+};diff --git a/resources/views/livewire/project/database/postgresql/general.blade.php b/resources/views/livewire/project/database/postgresql/general.blade.phpindex 368e559061..3116620eaa 100644--- a/resources/views/livewire/project/database/postgresql/general.blade.php+++ b/resources/views/livewire/project/database/postgresql/general.blade.php@@ -72,6 +72,7 @@type="password" readonly wire:model="db_url_public" />@endif</div>+ <x-forms.textarea label="Custom PostgreSQL Configuration" rows="10" id="database.postgres_conf" /></form><div class="pb-16"><div class="flex gap-2 pt-4 pb-2">