Merge pull request #1411 from coollabsio/next

v4.0.0-beta.115
This commit is contained in:
Andras Bacsai 2023-11-08 12:41:25 +01:00 committed by GitHub
commit 64cc0b63f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 158 additions and 42 deletions

View File

@ -32,6 +32,8 @@ class StartPostgresql
$volume_names = $this->generate_local_persistent_volumes_only_volume_names(); $volume_names = $this->generate_local_persistent_volumes_only_volume_names();
$environment_variables = $this->generate_environment_variables(); $environment_variables = $this->generate_environment_variables();
$this->generate_init_scripts(); $this->generate_init_scripts();
$this->add_custom_conf();
$docker_compose = [ $docker_compose = [
'version' => '3.8', 'version' => '3.8',
'services' => [ '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 = Yaml::dump($docker_compose, 10);
$docker_compose_base64 = base64_encode($docker_compose); $docker_compose_base64 = base64_encode($docker_compose);
$this->commands[] = "echo '{$docker_compose_base64}' | base64 -d > $this->configuration_dir/docker-compose.yml"; $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}"; $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}";
}
} }

View File

@ -13,7 +13,8 @@ class General extends Component
protected $listeners = ['refresh']; protected $listeners = ['refresh'];
public StandaloneMariadb $database; public StandaloneMariadb $database;
public string $db_url; public ?string $db_url = null;
public ?string $db_url_public = null;
protected $rules = [ protected $rules = [
'database.name' => 'required', 'database.name' => 'required',
@ -41,6 +42,14 @@ class General extends Component
'database.is_public' => 'Is Public', 'database.is_public' => 'Is Public',
'database.public_port' => 'Public Port', '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() public function submit()
{ {
try { try {
@ -69,12 +78,13 @@ class General extends Component
return; return;
} }
StartDatabaseProxy::run($this->database); StartDatabaseProxy::run($this->database);
$this->db_url_public = $this->database->getDbUrl();
$this->emit('success', 'Database is now publicly accessible.'); $this->emit('success', 'Database is now publicly accessible.');
} else { } else {
StopDatabaseProxy::run($this->database); StopDatabaseProxy::run($this->database);
$this->db_url_public = null;
$this->emit('success', 'Database is no longer publicly accessible.'); $this->emit('success', 'Database is no longer publicly accessible.');
} }
$this->db_url = $this->database->getDbUrl();
$this->database->save(); $this->database->save();
} catch (\Throwable $e) { } catch (\Throwable $e) {
$this->database->is_public = !$this->database->is_public; $this->database->is_public = !$this->database->is_public;
@ -86,11 +96,6 @@ class General extends Component
$this->database->refresh(); $this->database->refresh();
} }
public function mount()
{
$this->db_url = $this->database->getDbUrl();
}
public function render() public function render()
{ {
return view('livewire.project.database.mariadb.general'); return view('livewire.project.database.mariadb.general');

View File

@ -13,7 +13,8 @@ class General extends Component
protected $listeners = ['refresh']; protected $listeners = ['refresh'];
public StandaloneMongodb $database; public StandaloneMongodb $database;
public string $db_url; public ?string $db_url = null;
public ?string $db_url_public = null;
protected $rules = [ protected $rules = [
'database.name' => 'required', 'database.name' => 'required',
@ -39,6 +40,15 @@ class General extends Component
'database.is_public' => 'Is Public', 'database.is_public' => 'Is Public',
'database.public_port' => 'Public Port', '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() public function submit()
{ {
try { try {
@ -70,12 +80,13 @@ class General extends Component
return; return;
} }
StartDatabaseProxy::run($this->database); StartDatabaseProxy::run($this->database);
$this->db_url_public = $this->database->getDbUrl();
$this->emit('success', 'Database is now publicly accessible.'); $this->emit('success', 'Database is now publicly accessible.');
} else { } else {
StopDatabaseProxy::run($this->database); StopDatabaseProxy::run($this->database);
$this->db_url_public = null;
$this->emit('success', 'Database is no longer publicly accessible.'); $this->emit('success', 'Database is no longer publicly accessible.');
} }
$this->db_url = $this->database->getDbUrl();
$this->database->save(); $this->database->save();
} catch (\Throwable $e) { } catch (\Throwable $e) {
$this->database->is_public = !$this->database->is_public; $this->database->is_public = !$this->database->is_public;
@ -87,11 +98,6 @@ class General extends Component
$this->database->refresh(); $this->database->refresh();
} }
public function mount()
{
$this->db_url = $this->database->getDbUrl();
}
public function render() public function render()
{ {
return view('livewire.project.database.mongodb.general'); return view('livewire.project.database.mongodb.general');

View File

@ -13,7 +13,8 @@ class General extends Component
protected $listeners = ['refresh']; protected $listeners = ['refresh'];
public StandaloneMysql $database; public StandaloneMysql $database;
public string $db_url; public ?string $db_url = null;
public ?string $db_url_public = null;
protected $rules = [ protected $rules = [
'database.name' => 'required', 'database.name' => 'required',
@ -41,6 +42,14 @@ class General extends Component
'database.is_public' => 'Is Public', 'database.is_public' => 'Is Public',
'database.public_port' => 'Public Port', '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() public function submit()
{ {
try { try {
@ -69,12 +78,13 @@ class General extends Component
return; return;
} }
StartDatabaseProxy::run($this->database); StartDatabaseProxy::run($this->database);
$this->db_url_public = $this->database->getDbUrl();
$this->emit('success', 'Database is now publicly accessible.'); $this->emit('success', 'Database is now publicly accessible.');
} else { } else {
StopDatabaseProxy::run($this->database); StopDatabaseProxy::run($this->database);
$this->db_url_public = null;
$this->emit('success', 'Database is no longer publicly accessible.'); $this->emit('success', 'Database is no longer publicly accessible.');
} }
$this->db_url = $this->database->getDbUrl();
$this->database->save(); $this->database->save();
} catch (\Throwable $e) { } catch (\Throwable $e) {
$this->database->is_public = !$this->database->is_public; $this->database->is_public = !$this->database->is_public;
@ -86,11 +96,6 @@ class General extends Component
$this->database->refresh(); $this->database->refresh();
} }
public function mount()
{
$this->db_url = $this->database->getDbUrl();
}
public function render() public function render()
{ {
return view('livewire.project.database.mysql.general'); return view('livewire.project.database.mysql.general');

View File

@ -15,7 +15,8 @@ class General extends Component
public StandalonePostgresql $database; public StandalonePostgresql $database;
public string $new_filename; public string $new_filename;
public string $new_content; 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']; protected $listeners = ['refresh', 'save_init_script', 'delete_init_script'];
@ -27,6 +28,7 @@ class General extends Component
'database.postgres_db' => 'required', 'database.postgres_db' => 'required',
'database.postgres_initdb_args' => 'nullable', 'database.postgres_initdb_args' => 'nullable',
'database.postgres_host_auth_method' => 'nullable', 'database.postgres_host_auth_method' => 'nullable',
'database.postgres_conf' => 'nullable',
'database.init_scripts' => 'nullable', 'database.init_scripts' => 'nullable',
'database.image' => 'required', 'database.image' => 'required',
'database.ports_mappings' => 'nullable', 'database.ports_mappings' => 'nullable',
@ -41,6 +43,7 @@ class General extends Component
'database.postgres_db' => 'Postgres DB', 'database.postgres_db' => 'Postgres DB',
'database.postgres_initdb_args' => 'Postgres Initdb Args', 'database.postgres_initdb_args' => 'Postgres Initdb Args',
'database.postgres_host_auth_method' => 'Postgres Host Auth Method', 'database.postgres_host_auth_method' => 'Postgres Host Auth Method',
'database.postgres_conf' => 'Postgres Configuration',
'database.init_scripts' => 'Init Scripts', 'database.init_scripts' => 'Init Scripts',
'database.image' => 'Image', 'database.image' => 'Image',
'database.ports_mappings' => 'Port Mapping', 'database.ports_mappings' => 'Port Mapping',
@ -49,7 +52,10 @@ class General extends Component
]; ];
public function mount() 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() public function instantSave()
{ {
@ -66,12 +72,13 @@ class General extends Component
return; return;
} }
StartDatabaseProxy::run($this->database); StartDatabaseProxy::run($this->database);
$this->db_url_public = $this->database->getDbUrl();
$this->emit('success', 'Database is now publicly accessible.'); $this->emit('success', 'Database is now publicly accessible.');
} else { } else {
StopDatabaseProxy::run($this->database); StopDatabaseProxy::run($this->database);
$this->db_url_public = null;
$this->emit('success', 'Database is no longer publicly accessible.'); $this->emit('success', 'Database is no longer publicly accessible.');
} }
$this->db_url = $this->database->getDbUrl();
$this->database->save(); $this->database->save();
} catch (\Throwable $e) { } catch (\Throwable $e) {
$this->database->is_public = !$this->database->is_public; $this->database->is_public = !$this->database->is_public;

View File

@ -13,7 +13,8 @@ class General extends Component
protected $listeners = ['refresh']; protected $listeners = ['refresh'];
public StandaloneRedis $database; public StandaloneRedis $database;
public string $db_url; public ?string $db_url = null;
public ?string $db_url_public = null;
protected $rules = [ protected $rules = [
'database.name' => 'required', 'database.name' => 'required',
@ -35,6 +36,13 @@ class General extends Component
'database.is_public' => 'Is Public', 'database.is_public' => 'Is Public',
'database.public_port' => 'Public Port', '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() public function submit()
{ {
try { try {
@ -63,12 +71,13 @@ class General extends Component
return; return;
} }
StartDatabaseProxy::run($this->database); StartDatabaseProxy::run($this->database);
$this->db_url_public = $this->database->getDbUrl();
$this->emit('success', 'Database is now publicly accessible.'); $this->emit('success', 'Database is now publicly accessible.');
} else { } else {
StopDatabaseProxy::run($this->database); StopDatabaseProxy::run($this->database);
$this->db_url_public = null;
$this->emit('success', 'Database is no longer publicly accessible.'); $this->emit('success', 'Database is no longer publicly accessible.');
} }
$this->db_url = $this->database->getDbUrl();
$this->database->save(); $this->database->save();
} catch (\Throwable $e) { } catch (\Throwable $e) {
$this->database->is_public = !$this->database->is_public; $this->database->is_public = !$this->database->is_public;
@ -80,10 +89,6 @@ class General extends Component
$this->database->refresh(); $this->database->refresh();
} }
public function mount()
{
$this->db_url = $this->database->getDbUrl();
}
public function render() public function render()
{ {
return view('livewire.project.database.redis.general'); return view('livewire.project.database.redis.general');

View File

@ -7,7 +7,7 @@ return [
// The release version of your application // The release version of your application
// Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')) // 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 // When left empty or `null` the Laravel environment will be used
'environment' => config('app.env'), 'environment' => config('app.env'),

View File

@ -1,3 +1,3 @@
<?php <?php
return '4.0.0-beta.114'; return '4.0.0-beta.115';

View File

@ -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();
});
}
};

View File

@ -49,9 +49,14 @@
label="Public Port" /> label="Public Port" />
<x-forms.checkbox instantSave id="database.is_public" label="Accessible over the internet" /> <x-forms.checkbox instantSave id="database.is_public" label="Accessible over the internet" />
</div> </div>
<x-forms.input label="MariaDB URL" <x-forms.input label="MariaDB URL (internal)"
helper="If you change the user/password/port, this could be different. This is with the default values." helper="If you change the user/password/port, this could be different. This is with the default values."
type="password" readonly wire:model="db_url" /> type="password" readonly wire:model="db_url" />
@if ($db_url_public)
<x-forms.input label="MariaDB URL (public)"
helper="If you change the user/password/port, this could be different. This is with the default values."
type="password" readonly wire:model="db_url_public" />
@endif
</div> </div>
<x-forms.textarea label="Custom MariaDB Configuration" rows="10" id="database.mariadb_conf" /> <x-forms.textarea label="Custom MariaDB Configuration" rows="10" id="database.mariadb_conf" />
</form> </form>

View File

@ -43,9 +43,14 @@
label="Public Port" /> label="Public Port" />
<x-forms.checkbox instantSave id="database.is_public" label="Accessible over the internet" /> <x-forms.checkbox instantSave id="database.is_public" label="Accessible over the internet" />
</div> </div>
<x-forms.input label="Mongo URL" <x-forms.input label="Mongo URL (internal)"
helper="If you change the user/password/port, this could be different. This is with the default values." helper="If you change the user/password/port, this could be different. This is with the default values."
type="password" readonly wire:model="db_url" /> type="password" readonly wire:model="db_url" />
@if ($db_url_public)
<x-forms.input label="Mongo URL (public)"
helper="If you change the user/password/port, this could be different. This is with the default values."
type="password" readonly wire:model="db_url_public" />
@endif
</div> </div>
<x-forms.textarea label="Custom MongoDB Configuration" rows="10" id="database.mongo_conf" /> <x-forms.textarea label="Custom MongoDB Configuration" rows="10" id="database.mongo_conf" />
</form> </form>

View File

@ -49,9 +49,14 @@
label="Public Port" /> label="Public Port" />
<x-forms.checkbox instantSave id="database.is_public" label="Accessible over the internet" /> <x-forms.checkbox instantSave id="database.is_public" label="Accessible over the internet" />
</div> </div>
<x-forms.input label="MySQL URL" <x-forms.input label="MySQL URL (internal)"
helper="If you change the user/password/port, this could be different. This is with the default values." helper="If you change the user/password/port, this could be different. This is with the default values."
type="password" readonly wire:model="db_url" /> type="password" readonly wire:model="db_url" />
@if ($db_url_public)
<x-forms.input label="MySQL URL (public)"
helper="If you change the user/password/port, this could be different. This is with the default values."
type="password" readonly wire:model="db_url_public" />
@endif
</div> </div>
<x-forms.textarea label="Custom Mysql Configuration" rows="10" id="database.mysql_conf" /> <x-forms.textarea label="Custom Mysql Configuration" rows="10" id="database.mysql_conf" />
</form> </form>

View File

@ -31,14 +31,15 @@
<div class="flex gap-2"> <div class="flex gap-2">
<x-forms.input label="Initial Username" id="database.postgres_username" placeholder="If empty: postgres" <x-forms.input label="Initial Username" id="database.postgres_username" placeholder="If empty: postgres"
readonly helper="You can only change this in the database." /> readonly helper="You can only change this in the database." />
<x-forms.input label="Initial Password" id="database.postgres_password" type="password" required readonly <x-forms.input label="Initial Password" id="database.postgres_password" type="password" required
helper="You can only change this in the database." /> readonly helper="You can only change this in the database." />
<x-forms.input label="Initial Database" id="database.postgres_db" <x-forms.input label="Initial Database" id="database.postgres_db"
placeholder="If empty, it will be the same as Username." readonly placeholder="If empty, it will be the same as Username." readonly
helper="You can only change this in the database." /> helper="You can only change this in the database." />
</div> </div>
@else @else
<div class="pt-8 text-warning">Please verify these values. You can only modify them before the initial start. After that, you need to modify it in the database. <div class="pt-8 text-warning">Please verify these values. You can only modify them before the initial
start. After that, you need to modify it in the database.
</div> </div>
<div class="flex gap-2 pb-8"> <div class="flex gap-2 pb-8">
<x-forms.input label="Username" id="database.postgres_user" placeholder="If empty: postgres" /> <x-forms.input label="Username" id="database.postgres_user" placeholder="If empty: postgres" />
@ -62,8 +63,16 @@
label="Public Port" /> label="Public Port" />
<x-forms.checkbox instantSave id="database.is_public" label="Accessible over the internet" /> <x-forms.checkbox instantSave id="database.is_public" label="Accessible over the internet" />
</div> </div>
<x-forms.input label="Postgres URL" helper="If you change the user/password/port, this could be different. This is with the default values." type="password" readonly wire:model="db_url" /> <x-forms.input label="Postgres URL (internal)"
helper="If you change the user/password/port, this could be different. This is with the default values."
type="password" readonly wire:model="db_url" />
@if ($db_url_public)
<x-forms.input label="Postgres URL (public)"
helper="If you change the user/password/port, this could be different. This is with the default values."
type="password" readonly wire:model="db_url_public" />
@endif
</div> </div>
<x-forms.textarea label="Custom PostgreSQL Configuration" rows="10" id="database.postgres_conf" />
</form> </form>
<div class="pb-16"> <div class="pb-16">
<div class="flex gap-2 pt-4 pb-2"> <div class="flex gap-2 pt-4 pb-2">

View File

@ -21,8 +21,17 @@
label="Public Port" /> label="Public Port" />
<x-forms.checkbox instantSave id="database.is_public" label="Accessible over the internet" /> <x-forms.checkbox instantSave id="database.is_public" label="Accessible over the internet" />
</div> </div>
<x-forms.input label="Redis URL" helper="If you change the user/password/port, this could be different. This is with the default values." type="password" readonly wire:model="db_url" /> <x-forms.input label="Redis URL (internal)"
helper="If you change the user/password/port, this could be different. This is with the default values."
type="password" readonly wire:model="db_url" />
@if ($db_url_public)
<x-forms.input label="Redis URL (public)"
helper="If you change the user/password/port, this could be different. This is with the default values."
type="password" readonly wire:model="db_url_public" />
@endif
</div> </div>
<x-forms.textarea helper="<a target='_blank' class='text-white underline' href='https://raw.githubusercontent.com/redis/redis/7.2/redis.conf'>Redis Default Configuration</a>" label="Custom Redis Configuration" rows="10" id="database.redis_conf" /> <x-forms.textarea
helper="<a target='_blank' class='text-white underline' href='https://raw.githubusercontent.com/redis/redis/7.2/redis.conf'>Redis Default Configuration</a>"
label="Custom Redis Configuration" rows="10" id="database.redis_conf" />
</form> </form>
</div> </div>

View File

@ -4,7 +4,7 @@
"version": "3.12.36" "version": "3.12.36"
}, },
"v4": { "v4": {
"version": "4.0.0-beta.114" "version": "4.0.0-beta.115"
} }
} }
} }