From 88e407756dc1bbb7e141473a0b03d4db13efa596 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 8 Nov 2023 12:26:57 +0100 Subject: [PATCH 1/2] Update version numbers and database URLs --- .../Project/Database/Mariadb/General.php | 19 +++++++++++------- .../Project/Database/Mongodb/General.php | 20 ++++++++++++------- .../Project/Database/Mysql/General.php | 19 +++++++++++------- .../Project/Database/Postgresql/General.php | 11 +++++++--- .../Project/Database/Redis/General.php | 17 ++++++++++------ config/sentry.php | 2 +- config/version.php | 2 +- .../database/mariadb/general.blade.php | 7 ++++++- .../database/mongodb/general.blade.php | 7 ++++++- .../project/database/mysql/general.blade.php | 7 ++++++- .../database/postgresql/general.blade.php | 16 +++++++++++---- .../project/database/redis/general.blade.php | 13 ++++++++++-- versions.json | 2 +- 13 files changed, 100 insertions(+), 42 deletions(-) diff --git a/app/Http/Livewire/Project/Database/Mariadb/General.php b/app/Http/Livewire/Project/Database/Mariadb/General.php index 11b5fc42b..173e9290f 100644 --- a/app/Http/Livewire/Project/Database/Mariadb/General.php +++ b/app/Http/Livewire/Project/Database/Mariadb/General.php @@ -13,7 +13,8 @@ class General extends Component protected $listeners = ['refresh']; public StandaloneMariadb $database; - public string $db_url; + public ?string $db_url = null; + public ?string $db_url_public = null; protected $rules = [ 'database.name' => 'required', @@ -41,6 +42,14 @@ class General extends Component 'database.is_public' => 'Is Public', 'database.public_port' => 'Public Port', ]; + + public function mount() + { + $this->db_url = $this->database->getDbUrl(true); + if ($this->database->is_public) { + $this->db_url_public = $this->database->getDbUrl(); + } + } public function submit() { try { @@ -69,12 +78,13 @@ class General extends Component return; } StartDatabaseProxy::run($this->database); + $this->db_url_public = $this->database->getDbUrl(); $this->emit('success', 'Database is now publicly accessible.'); } else { StopDatabaseProxy::run($this->database); + $this->db_url_public = null; $this->emit('success', 'Database is no longer publicly accessible.'); } - $this->db_url = $this->database->getDbUrl(); $this->database->save(); } catch (\Throwable $e) { $this->database->is_public = !$this->database->is_public; @@ -86,11 +96,6 @@ class General extends Component $this->database->refresh(); } - public function mount() - { - $this->db_url = $this->database->getDbUrl(); - } - public function render() { return view('livewire.project.database.mariadb.general'); diff --git a/app/Http/Livewire/Project/Database/Mongodb/General.php b/app/Http/Livewire/Project/Database/Mongodb/General.php index ce0ff14ea..189f2632e 100644 --- a/app/Http/Livewire/Project/Database/Mongodb/General.php +++ b/app/Http/Livewire/Project/Database/Mongodb/General.php @@ -13,7 +13,8 @@ class General extends Component protected $listeners = ['refresh']; public StandaloneMongodb $database; - public string $db_url; + public ?string $db_url = null; + public ?string $db_url_public = null; protected $rules = [ 'database.name' => 'required', @@ -39,6 +40,15 @@ class General extends Component 'database.is_public' => 'Is Public', 'database.public_port' => 'Public Port', ]; + + public function mount() + { + $this->db_url = $this->database->getDbUrl(true); + if ($this->database->is_public) { + $this->db_url_public = $this->database->getDbUrl(); + } + } + public function submit() { try { @@ -70,12 +80,13 @@ class General extends Component return; } StartDatabaseProxy::run($this->database); + $this->db_url_public = $this->database->getDbUrl(); $this->emit('success', 'Database is now publicly accessible.'); } else { StopDatabaseProxy::run($this->database); + $this->db_url_public = null; $this->emit('success', 'Database is no longer publicly accessible.'); } - $this->db_url = $this->database->getDbUrl(); $this->database->save(); } catch (\Throwable $e) { $this->database->is_public = !$this->database->is_public; @@ -87,11 +98,6 @@ class General extends Component $this->database->refresh(); } - public function mount() - { - $this->db_url = $this->database->getDbUrl(); - } - public function render() { return view('livewire.project.database.mongodb.general'); diff --git a/app/Http/Livewire/Project/Database/Mysql/General.php b/app/Http/Livewire/Project/Database/Mysql/General.php index 416970ea9..cb1a063db 100644 --- a/app/Http/Livewire/Project/Database/Mysql/General.php +++ b/app/Http/Livewire/Project/Database/Mysql/General.php @@ -13,7 +13,8 @@ class General extends Component protected $listeners = ['refresh']; public StandaloneMysql $database; - public string $db_url; + public ?string $db_url = null; + public ?string $db_url_public = null; protected $rules = [ 'database.name' => 'required', @@ -41,6 +42,14 @@ class General extends Component 'database.is_public' => 'Is Public', 'database.public_port' => 'Public Port', ]; + + public function mount() + { + $this->db_url = $this->database->getDbUrl(true); + if ($this->database->is_public) { + $this->db_url_public = $this->database->getDbUrl(); + } + } public function submit() { try { @@ -69,12 +78,13 @@ class General extends Component return; } StartDatabaseProxy::run($this->database); + $this->db_url_public = $this->database->getDbUrl(); $this->emit('success', 'Database is now publicly accessible.'); } else { StopDatabaseProxy::run($this->database); + $this->db_url_public = null; $this->emit('success', 'Database is no longer publicly accessible.'); } - $this->db_url = $this->database->getDbUrl(); $this->database->save(); } catch (\Throwable $e) { $this->database->is_public = !$this->database->is_public; @@ -86,11 +96,6 @@ class General extends Component $this->database->refresh(); } - public function mount() - { - $this->db_url = $this->database->getDbUrl(); - } - public function render() { return view('livewire.project.database.mysql.general'); diff --git a/app/Http/Livewire/Project/Database/Postgresql/General.php b/app/Http/Livewire/Project/Database/Postgresql/General.php index 7872764e3..7292ec2b2 100644 --- a/app/Http/Livewire/Project/Database/Postgresql/General.php +++ b/app/Http/Livewire/Project/Database/Postgresql/General.php @@ -15,7 +15,8 @@ class General extends Component public StandalonePostgresql $database; public string $new_filename; public string $new_content; - public string $db_url; + public ?string $db_url = null; + public ?string $db_url_public = null; protected $listeners = ['refresh', 'save_init_script', 'delete_init_script']; @@ -49,7 +50,10 @@ class General extends Component ]; public function mount() { - $this->db_url = $this->database->getDbUrl(); + $this->db_url = $this->database->getDbUrl(true); + if ($this->database->is_public) { + $this->db_url_public = $this->database->getDbUrl(); + } } public function instantSave() { @@ -66,12 +70,13 @@ class General extends Component return; } StartDatabaseProxy::run($this->database); + $this->db_url_public = $this->database->getDbUrl(); $this->emit('success', 'Database is now publicly accessible.'); } else { StopDatabaseProxy::run($this->database); + $this->db_url_public = null; $this->emit('success', 'Database is no longer publicly accessible.'); } - $this->db_url = $this->database->getDbUrl(); $this->database->save(); } catch (\Throwable $e) { $this->database->is_public = !$this->database->is_public; diff --git a/app/Http/Livewire/Project/Database/Redis/General.php b/app/Http/Livewire/Project/Database/Redis/General.php index dd2e8151d..834a9f381 100644 --- a/app/Http/Livewire/Project/Database/Redis/General.php +++ b/app/Http/Livewire/Project/Database/Redis/General.php @@ -13,7 +13,8 @@ class General extends Component protected $listeners = ['refresh']; public StandaloneRedis $database; - public string $db_url; + public ?string $db_url = null; + public ?string $db_url_public = null; protected $rules = [ 'database.name' => 'required', @@ -35,6 +36,13 @@ class General extends Component 'database.is_public' => 'Is Public', 'database.public_port' => 'Public Port', ]; + public function mount() + { + $this->db_url = $this->database->getDbUrl(true); + if ($this->database->is_public) { + $this->db_url_public = $this->database->getDbUrl(); + } + } public function submit() { try { @@ -63,12 +71,13 @@ class General extends Component return; } StartDatabaseProxy::run($this->database); + $this->db_url_public = $this->database->getDbUrl(); $this->emit('success', 'Database is now publicly accessible.'); } else { StopDatabaseProxy::run($this->database); + $this->db_url_public = null; $this->emit('success', 'Database is no longer publicly accessible.'); } - $this->db_url = $this->database->getDbUrl(); $this->database->save(); } catch (\Throwable $e) { $this->database->is_public = !$this->database->is_public; @@ -80,10 +89,6 @@ class General extends Component $this->database->refresh(); } - public function mount() - { - $this->db_url = $this->database->getDbUrl(); - } public function render() { return view('livewire.project.database.redis.general'); diff --git a/config/sentry.php b/config/sentry.php index 180d98f99..b499fe319 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -7,7 +7,7 @@ return [ // The release version of your application // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')) - 'release' => '4.0.0-beta.114', + 'release' => '4.0.0-beta.115', // When left empty or `null` the Laravel environment will be used 'environment' => config('app.env'), diff --git a/config/version.php b/config/version.php index aee7423ea..4c86b6ee4 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ - + @if ($db_url_public) + + @endif diff --git a/resources/views/livewire/project/database/mongodb/general.blade.php b/resources/views/livewire/project/database/mongodb/general.blade.php index 51cb31d23..8aab8dd42 100644 --- a/resources/views/livewire/project/database/mongodb/general.blade.php +++ b/resources/views/livewire/project/database/mongodb/general.blade.php @@ -43,9 +43,14 @@ label="Public Port" /> - + @if ($db_url_public) + + @endif diff --git a/resources/views/livewire/project/database/mysql/general.blade.php b/resources/views/livewire/project/database/mysql/general.blade.php index 09a23a694..6db2fd8eb 100644 --- a/resources/views/livewire/project/database/mysql/general.blade.php +++ b/resources/views/livewire/project/database/mysql/general.blade.php @@ -49,9 +49,14 @@ label="Public Port" /> - + @if ($db_url_public) + + @endif diff --git a/resources/views/livewire/project/database/postgresql/general.blade.php b/resources/views/livewire/project/database/postgresql/general.blade.php index dfe64b993..368e55906 100644 --- a/resources/views/livewire/project/database/postgresql/general.blade.php +++ b/resources/views/livewire/project/database/postgresql/general.blade.php @@ -31,14 +31,15 @@
- +
@else -
Please verify these values. You can only modify them before the initial start. After that, you need to modify it in the database. +
Please verify these values. You can only modify them before the initial + start. After that, you need to modify it in the database.
@@ -62,7 +63,14 @@ label="Public Port" />
- + + @if ($db_url_public) + + @endif
diff --git a/resources/views/livewire/project/database/redis/general.blade.php b/resources/views/livewire/project/database/redis/general.blade.php index 1789d0c15..9f709b656 100644 --- a/resources/views/livewire/project/database/redis/general.blade.php +++ b/resources/views/livewire/project/database/redis/general.blade.php @@ -21,8 +21,17 @@ label="Public Port" />
- + + @if ($db_url_public) + + @endif - + diff --git a/versions.json b/versions.json index 7dcd59a4f..aeca3f8a1 100644 --- a/versions.json +++ b/versions.json @@ -4,7 +4,7 @@ "version": "3.12.36" }, "v4": { - "version": "4.0.0-beta.114" + "version": "4.0.0-beta.115" } } } From c78068466b0471dbf4e1913abd88410ff3dd89d3 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 8 Nov 2023 12:40:05 +0100 Subject: [PATCH 2/2] Add custom PostgreSQL configuration to StandalonePostgresql --- app/Actions/Database/StartPostgresql.php | 25 ++++++++++++++++ .../Project/Database/Postgresql/General.php | 2 ++ ...dd_custom_config_standalone_postgresql.php | 30 +++++++++++++++++++ .../database/postgresql/general.blade.php | 1 + 4 files changed, 58 insertions(+) create mode 100644 database/migrations/2023_11_08_112815_add_custom_config_standalone_postgresql.php diff --git a/app/Actions/Database/StartPostgresql.php b/app/Actions/Database/StartPostgresql.php index 46e410980..2dc9a38b0 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.php index 7292ec2b2..ebc69a1bc 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.php new file mode 100644 index 000000000..c583fb3ff --- /dev/null +++ b/database/migrations/2023_11_08_112815_add_custom_config_standalone_postgresql.php @@ -0,0 +1,30 @@ +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.php index 368e55906..3116620ea 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 +