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.

feat: mysql, mariadb

Andras Bacsaif801bb98cd11
diff --git a/app/Actions/Database/StartDatabaseProxy.php b/app/Actions/Database/StartDatabaseProxy.php
index 15009019da..ffc91b86a8 100644
--- a/app/Actions/Database/StartDatabaseProxy.php
+++ b/app/Actions/Database/StartDatabaseProxy.php
@@ -2,7 +2,9 @@
namespace App\Actions\Database;
+use App\Models\StandaloneMariadb;
use App\Models\StandaloneMongodb;
+use App\Models\StandaloneMysql;
use App\Models\StandalonePostgresql;
use App\Models\StandaloneRedis;
use Lorisleiva\Actions\Concerns\AsAction;
@@ -12,7 +14,7 @@ class StartDatabaseProxy
{
use AsAction;
- public function handle(StandaloneRedis|StandalonePostgresql|StandaloneMongodb $database)
+ public function handle(StandaloneRedis|StandalonePostgresql|StandaloneMongodb|StandaloneMysql|StandaloneMariadb $database)
{
$internalPort = null;
if ($database->getMorphClass() === 'App\Models\StandaloneRedis') {
@@ -21,6 +23,10 @@ class StartDatabaseProxy
$internalPort = 5432;
} else if ($database->getMorphClass() === 'App\Models\StandaloneMongodb') {
$internalPort = 27017;
+ } else if ($database->getMorphClass() === 'App\Models\StandaloneMysql') {
+ $internalPort = 3306;
+ } else if ($database->getMorphClass() === 'App\Models\StandaloneMariadb') {
+ $internalPort = 3306;
}
$containerName = "{$database->uuid}-proxy";
$configuration_dir = database_proxy_dir($database->uuid);
diff --git a/app/Actions/Database/StartMariadb.php b/app/Actions/Database/StartMariadb.php
new file mode 100644
index 0000000000..75fd69adcb
--- /dev/null
+++ b/app/Actions/Database/StartMariadb.php
@@ -0,0 +1,158 @@
+<?php
+
+namespace App\Actions\Database;
+
+use App\Models\StandaloneMariadb;
+use Illuminate\Support\Str;
+use Symfony\Component\Yaml\Yaml;
+use Lorisleiva\Actions\Concerns\AsAction;
+
+class StartMariadb
+{
+ use AsAction;
+
+ public StandaloneMariadb $database;
+ public array $commands = [];
+ public string $configuration_dir;
+
+ public function handle(StandaloneMariadb $database)
+ {
+ $this->database = $database;
+
+ $container_name = $this->database->uuid;
+ $this->configuration_dir = database_configuration_dir() . '/' . $container_name;
+
+ $this->commands = [
+ "echo '####### Starting {$database->name}.'",
+ "mkdir -p $this->configuration_dir",
+ ];
+
+ $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_mysql();
+ $docker_compose = [
+ 'version' => '3.8',
+ 'services' => [
+ $container_name => [
+ 'image' => $this->database->image,
+ 'container_name' => $container_name,
+ 'environment' => $environment_variables,
+ 'restart' => RESTART_MODE,
+ 'networks' => [
+ $this->database->destination->network,
+ ],
+ 'labels' => [
+ 'coolify.managed' => 'true',
+ ],
+ 'healthcheck' => [
+ 'test' => ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"],
+ 'interval' => '5s',
+ 'timeout' => '5s',
+ 'retries' => 10,
+ 'start_period' => '5s'
+ ],
+ 'mem_limit' => $this->database->limits_memory,
+ 'memswap_limit' => $this->database->limits_memory_swap,
+ 'mem_swappiness' => $this->database->limits_memory_swappiness,
+ 'mem_reservation' => $this->database->limits_memory_reservation,
+ 'cpus' => $this->database->limits_cpus,
+ 'cpuset' => $this->database->limits_cpuset,
+ 'cpu_shares' => $this->database->limits_cpu_shares,
+ ]
+ ],
+ 'networks' => [
+ $this->database->destination->network => [
+ 'external' => true,
+ 'name' => $this->database->destination->network,
+ 'attachable' => true,
+ ]
+ ]
+ ];
+ if (count($this->database->ports_mappings_array) > 0) {
+ $docker_compose['services'][$container_name]['ports'] = $this->database->ports_mappings_array;
+ }
+ if (count($persistent_storages) > 0) {
+ $docker_compose['services'][$container_name]['volumes'] = $persistent_storages;
+ }
+ if (count($volume_names) > 0) {
+ $docker_compose['volumes'] = $volume_names;
+ }
+ if (!is_null($this->database->mariadb_conf)) {
+ $docker_compose['services'][$container_name]['volumes'][] = [
+ 'type' => 'bind',
+ 'source' => $this->configuration_dir . '/custom-config.cnf',
+ 'target' => '/etc/mysql/conf.d/custom-config.cnf',
+ 'read_only' => true,
+ ];
+ }
+ $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";
+ $readme = generate_readme_file($this->database->name, now());
+ $this->commands[] = "echo '{$readme}' > $this->configuration_dir/README.md";
+ $this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml up -d";
+ $this->commands[] = "echo '####### {$database->name} started.'";
+ return remote_process($this->commands, $database->destination->server);
+ }
+
+ private function generate_local_persistent_volumes()
+ {
+ $local_persistent_volumes = [];
+ foreach ($this->database->persistentStorages as $persistentStorage) {
+ $volume_name = $persistentStorage->host_path ?? $persistentStorage->name;
+ $local_persistent_volumes[] = $volume_name . ':' . $persistentStorage->mount_path;
+ }
+ return $local_persistent_volumes;
+ }
+
+ private function generate_local_persistent_volumes_only_volume_names()
+ {
+ $local_persistent_volumes_names = [];
+ foreach ($this->database->persistentStorages as $persistentStorage) {
+ if ($persistentStorage->host_path) {
+ continue;
+ }
+ $name = $persistentStorage->name;
+ $local_persistent_volumes_names[$name] = [
+ 'name' => $name,
+ 'external' => false,
+ ];
+ }
+ return $local_persistent_volumes_names;
+ }
+
+ private function generate_environment_variables()
+ {
+ $environment_variables = collect();
+ foreach ($this->database->runtime_environment_variables as $env) {
+ $environment_variables->push("$env->key=$env->value");
+ }
+
+ if ($environment_variables->filter(fn ($env) => Str::of($env)->contains('MARIADB_ROOT_PASSWORD'))->isEmpty()) {
+ $environment_variables->push("MARIADB_ROOT_PASSWORD={$this->database->mariadb_root_password}");
+ }
+
+ if ($environment_variables->filter(fn ($env) => Str::of($env)->contains('MARIADB_DATABASE'))->isEmpty()) {
+ $environment_variables->push("MARIADB_DATABASE={$this->database->mariadb_database}");
+ }
+
+ if ($environment_variables->filter(fn ($env) => Str::of($env)->contains('MARIADB_USER'))->isEmpty()) {
+ $environment_variables->push("MARIADB_USER={$this->database->mariadb_user}");
+ }
+ if ($environment_variables->filter(fn ($env) => Str::of($env)->contains('MARIADB_PASSWORD'))->isEmpty()) {
+ $environment_variables->push("MARIADB_PASSWORD={$this->database->mariadb_password}");
+ }
+ return $environment_variables->all();
+ }
+ private function add_custom_mysql()
+ {
+ if (is_null($this->database->mariadb_conf)) {
+ return;
+ }
+ $filename = 'custom-config.cnf';
+ $content = $this->database->mariadb_conf;
+ $content_base64 = base64_encode($content);
+ $this->commands[] = "echo '{$content_base64}' | base64 -d > $this->configuration_dir/{$filename}";
+ }
+}
diff --git a/app/Actions/Database/StartMysql.php b/app/Actions/Database/StartMysql.php
new file mode 100644
index 0000000000..8ee0db6e96
--- /dev/null
+++ b/app/Actions/Database/StartMysql.php
@@ -0,0 +1,158 @@
+<?php
+
+namespace App\Actions\Database;
+
+use App\Models\StandaloneMysql;
+use Illuminate\Support\Str;
+use Symfony\Component\Yaml\Yaml;
+use Lorisleiva\Actions\Concerns\AsAction;
+
+class StartMysql
+{
+ use AsAction;
+
+ public StandaloneMysql $database;
+ public array $commands = [];
+ public string $configuration_dir;
+
+ public function handle(StandaloneMysql $database)
+ {
+ $this->database = $database;
+
+ $container_name = $this->database->uuid;
+ $this->configuration_dir = database_configuration_dir() . '/' . $container_name;
+
+ $this->commands = [
+ "echo '####### Starting {$database->name}.'",
+ "mkdir -p $this->configuration_dir",
+ ];
+
+ $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_mysql();
+ $docker_compose = [
+ 'version' => '3.8',
+ 'services' => [
+ $container_name => [
+ 'image' => $this->database->image,
+ 'container_name' => $container_name,
+ 'environment' => $environment_variables,
+ 'restart' => RESTART_MODE,
+ 'networks' => [
+ $this->database->destination->network,
+ ],
+ 'labels' => [
+ 'coolify.managed' => 'true',
+ ],
+ 'healthcheck' => [
+ 'test' => ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p{$this->database->mysql_root_password}"],
+ 'interval' => '5s',
+ 'timeout' => '5s',
+ 'retries' => 10,
+ 'start_period' => '5s'
+ ],
+ 'mem_limit' => $this->database->limits_memory,
+ 'memswap_limit' => $this->database->limits_memory_swap,
+ 'mem_swappiness' => $this->database->limits_memory_swappiness,
+ 'mem_reservation' => $this->database->limits_memory_reservation,
+ 'cpus' => $this->database->limits_cpus,
+ 'cpuset' => $this->database->limits_cpuset,
+ 'cpu_shares' => $this->database->limits_cpu_shares,
+ ]
+ ],
+ 'networks' => [
+ $this->database->destination->network => [
+ 'external' => true,
+ 'name' => $this->database->destination->network,
+ 'attachable' => true,
+ ]
+ ]
+ ];
+ if (count($this->database->ports_mappings_array) > 0) {
+ $docker_compose['services'][$container_name]['ports'] = $this->database->ports_mappings_array;
+ }
+ if (count($persistent_storages) > 0) {
+ $docker_compose['services'][$container_name]['volumes'] = $persistent_storages;
+ }
+ if (count($volume_names) > 0) {
+ $docker_compose['volumes'] = $volume_names;
+ }
+ if (!is_null($this->database->mysql_conf)) {
+ $docker_compose['services'][$container_name]['volumes'][] = [
+ 'type' => 'bind',
+ 'source' => $this->configuration_dir . '/custom-config.cnf',
+ 'target' => '/etc/mysql/conf.d/custom-config.cnf',
+ 'read_only' => true,
+ ];
+ }
+ $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";
+ $readme = generate_readme_file($this->database->name, now());
+ $this->commands[] = "echo '{$readme}' > $this->configuration_dir/README.md";
+ $this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml up -d";
+ $this->commands[] = "echo '####### {$database->name} started.'";
+ return remote_process($this->commands, $database->destination->server);
+ }
+
+ private function generate_local_persistent_volumes()
+ {
+ $local_persistent_volumes = [];
+ foreach ($this->database->persistentStorages as $persistentStorage) {
+ $volume_name = $persistentStorage->host_path ?? $persistentStorage->name;
+ $local_persistent_volumes[] = $volume_name . ':' . $persistentStorage->mount_path;
+ }
+ return $local_persistent_volumes;
+ }
+
+ private function generate_local_persistent_volumes_only_volume_names()
+ {
+ $local_persistent_volumes_names = [];
+ foreach ($this->database->persistentStorages as $persistentStorage) {
+ if ($persistentStorage->host_path) {
+ continue;
+ }
+ $name = $persistentStorage->name;
+ $local_persistent_volumes_names[$name] = [
+ 'name' => $name,
+ 'external' => false,
+ ];
+ }
+ return $local_persistent_volumes_names;
+ }
+
+ private function generate_environment_variables()
+ {
+ $environment_variables = collect();
+ foreach ($this->database->runtime_environment_variables as $env) {
+ $environment_variables->push("$env->key=$env->value");
+ }
+
+ if ($environment_variables->filter(fn ($env) => Str::of($env)->contains('MYSQL_ROOT_PASSWORD'))->isEmpty()) {
+ $environment_variables->push("MYSQL_ROOT_PASSWORD={$this->database->mysql_root_password}");
+ }
+
+ if ($environment_variables->filter(fn ($env) => Str::of($env)->contains('MYSQL_DATABASE'))->isEmpty()) {
+ $environment_variables->push("MYSQL_DATABASE={$this->database->mysql_database}");
+ }
+
+ if ($environment_variables->filter(fn ($env) => Str::of($env)->contains('MYSQL_USER'))->isEmpty()) {
+ $environment_variables->push("MYSQL_USER={$this->database->mysql_user}");
+ }
+ if ($environment_variables->filter(fn ($env) => Str::of($env)->contains('MYSQL_PASSWORD'))->isEmpty()) {
+ $environment_variables->push("MYSQL_PASSWORD={$this->database->mysql_password}");
+ }
+ return $environment_variables->all();
+ }
+ private function add_custom_mysql()
+ {
+ if (is_null($this->database->mysql_conf)) {
+ return;
+ }
+ $filename = 'custom-config.cnf';
+ $content = $this->database->mysql_conf;
+ $content_base64 = base64_encode($content);
+ $this->commands[] = "echo '{$content_base64}' | base64 -d > $this->configuration_dir/{$filename}";
+ }
+}
diff --git a/app/Actions/Database/StopDatabase.php b/app/Actions/Database/StopDatabase.php
index 7e3f5f4c2f..4f6a8c6c2c 100644
--- a/app/Actions/Database/StopDatabase.php
+++ b/app/Actions/Database/StopDatabase.php
@@ -2,7 +2,9 @@
namespace App\Actions\Database;
+use App\Models\StandaloneMariadb;
use App\Models\StandaloneMongodb;
+use App\Models\StandaloneMysql;
use App\Models\StandalonePostgresql;
use App\Models\StandaloneRedis;
use Lorisleiva\Actions\Concerns\AsAction;
@@ -11,7 +13,7 @@ class StopDatabase
{
use AsAction;
- public function handle(StandaloneRedis|StandalonePostgresql|StandaloneMongodb $database)
+ public function handle(StandaloneRedis|StandalonePostgresql|StandaloneMongodb|StandaloneMysql|StandaloneMariadb $database)
{
$server = $database->destination->server;
instant_remote_process(
diff --git a/app/Actions/Database/StopDatabaseProxy.php b/app/Actions/Database/StopDatabaseProxy.php
index 840e8ed561..d52d1961cc 100644
--- a/app/Actions/Database/StopDatabaseProxy.php
+++ b/app/Actions/Database/StopDatabaseProxy.php
@@ -2,7 +2,9 @@
namespace App\Actions\Database;
+use App\Models\StandaloneMariadb;
use App\Models\StandaloneMongodb;
+use App\Models\StandaloneMysql;
use App\Models\StandalonePostgresql;
use App\Models\StandaloneRedis;
use Lorisleiva\Actions\Concerns\AsAction;
@@ -11,7 +13,7 @@ class StopDatabaseProxy
{
use AsAction;
- public function handle(StandaloneRedis|StandalonePostgresql|StandaloneMongodb $database)
+ public function handle(StandaloneRedis|StandalonePostgresql|StandaloneMongodb|StandaloneMysql|StandaloneMariadb $database)
{
instant_remote_process(["docker rm -f {$database->uuid}-proxy"], $database->destination->server);
$database->is_public = false;
diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php
index 1d1a5b14ed..0e3983f7e8 100644
--- a/app/Http/Controllers/ProjectController.php
+++ b/app/Http/Controllers/ProjectController.php
@@ -63,8 +63,12 @@ class ProjectController extends Controller
$database = create_standalone_postgresql($environment->id, $destination_uuid);
} else if ($type->value() === 'redis') {
$database = create_standalone_redis($environment->id, $destination_uuid);
- } else if ($type->value() === 'mongodb') {
+ } else if ($type->value() === 'mongodb') {
$database = create_standalone_mongodb($environment->id, $destination_uuid);
+ } else if ($type->value() === 'mysql') {
+ $database = create_standalone_mysql($environment->id, $destination_uuid);
+ }else if ($type->value() === 'mariadb') {
+ $database = create_standalone_mariadb($environment->id, $destination_uuid);
}
return redirect()->route('project.database.configuration', [
'project_uuid' => $project->uuid,
@@ -72,7 +76,7 @@ class ProjectController extends Controller
'database_uuid' => $database->uuid,
]);
}
- if ($type->startsWith('one-click-service-') && !is_null( (int)$server_id)) {
+ if ($type->startsWith('one-click-service-') && !is_null((int)$server_id)) {
$oneClickServiceName = $type->after('one-click-service-')->value();
$oneClickService = data_get($services, "$oneClickServiceName.compose");
$oneClickDotEnvs = data_get($services, "$oneClickServiceName.envs", null);
diff --git a/app/Http/Livewire/Project/CloneProject.php b/app/Http/Livewire/Project/CloneProject.php
index e12138d106..735bbc0da7 100644
--- a/app/Http/Livewire/Project/CloneProject.php
+++ b/app/Http/Livewire/Project/CloneProject.php
@@ -117,6 +117,10 @@ class CloneProject extends Component
$payload['standalone_redis_id'] = $newDatabase->id;
} else if ($database->type() === 'standalone_mongodb') {
$payload['standalone_mongodb_id'] = $newDatabase->id;
+ } else if ($database->type() === 'standalone_mysql') {
+ $payload['standalone_mysql_id'] = $newDatabase->id;
+ }else if ($database->type() === 'standalone_mariadb') {
+ $payload['standalone_mariadb_id'] = $newDatabase->id;
}
$newEnvironmentVariable = $environmentVarible->replicate()->fill($payload);
$newEnvironmentVariable->save();
diff --git a/app/Http/Livewire/Project/Database/BackupExecution.php b/app/Http/Livewire/Project/Database/BackupExecution.php
deleted file mode 100644
index 2f9d7dcb54..0000000000
--- a/app/Http/Livewire/Project/Database/BackupExecution.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-
-namespace App\Http\Livewire\Project\Database;
-
-use App\Models\ScheduledDatabaseBackupExecution;
-use Livewire\Component;
-
-class BackupExecution extends Component
-{
- public ScheduledDatabaseBackupExecution $execution;
-
- public function download()
- {
- }
-
- public function delete(): void
- {
- delete_backup_locally($this->execution->filename, $this->execution->scheduledDatabaseBackup->database->destination->server);
- $this->execution->delete();
- $this->emit('success', 'Backup deleted successfully.');
- $this->emit('refreshBackupExecutions');
- }
-}
diff --git a/app/Http/Livewire/Project/Database/BackupExecutions.php b/app/Http/Livewire/Project/Database/BackupExecutions.php
index 93da317f71..2f808d9926 100644
--- a/app/Http/Livewire/Project/Database/BackupExecutions.php
+++ b/app/Http/Livewire/Project/Database/BackupExecutions.php
@@ -8,8 +8,21 @@ class BackupExecutions extends Component
{
public $backup;
public $executions;
- protected $listeners = ['refreshBackupExecutions'];
+ public $setDeletableBackup;
+ protected $listeners = ['refreshBackupExecutions', 'deleteBackup'];
+ public function deleteBackup($exeuctionId)
+ {
+ $execution = $this->backup->executions()->where('id', $exeuctionId)->first();
+ if (is_null($execution)) {
+ $this->emit('error', 'Backup execution not found.');
+ return;
+ }
+ delete_backup_locally($execution->filename, $execution->scheduledDatabaseBackup->database->destination->server);
+ $execution->delete();
+ $this->emit('success', 'Backup deleted successfully.');
+ $this->emit('refreshBackupExecutions');
+ }
public function refreshBackupExecutions(): void
{
$this->executions = $this->backup->executions;
diff --git a/app/Http/Livewire/Project/Database/CreateScheduledBackup.php b/app/Http/Livewire/Project/Database/CreateScheduledBackup.php
index ac34e93bdd..f804c389df 100644
--- a/app/Http/Livewire/Project/Database/CreateScheduledBackup.php
+++ b/app/Http/Livewire/Project/Database/CreateScheduledBackup.php
@@ -48,6 +48,10 @@ class CreateScheduledBackup extends Component
];
if ($this->database->type() === 'standalone-postgresql') {
$payload['databases_to_backup'] = $this->database->postgres_db;
+ } else if ($this->database->type() === 'standalone-mysql') {
+ $payload['databases_to_backup'] = $this->database->mysql_database;
+ }else if ($this->database->type() === 'standalone-mariadb') {
+ $payload['databases_to_backup'] = $this->database->mariadb_database;
}
ScheduledDatabaseBackup::create($payload);
$this->emit('refreshScheduledBackups');
diff --git a/app/Http/Livewire/Project/Database/Heading.php b/app/Http/Livewire/Project/Database/Heading.php
index 6045e2b7f6..7b14e53687 100644
--- a/app/Http/Livewire/Project/Database/Heading.php
+++ b/app/Http/Livewire/Project/Database/Heading.php
@@ -2,7 +2,9 @@
namespace App\Http\Livewire\Project\Database;
+use App\Actions\Database\StartMariadb;
use App\Actions\Database\StartMongodb;
+use App\Actions\Database\StartMysql;
use App\Actions\Database\StartPostgresql;
use App\Actions\Database\StartRedis;
use App\Actions\Database\StopDatabase;
@@ -49,14 +51,18 @@ class Heading extends Component
if ($this->database->type() === 'standalone-postgresql') {
$activity = StartPostgresql::run($this->database);
$this->emit('newMonitorActivity', $activity->id);
- }
- if ($this->database->type() === 'standalone-redis') {
+ } else if ($this->database->type() === 'standalone-redis') {
$activity = StartRedis::run($this->database);
$this->emit('newMonitorActivity', $activity->id);
- }
- if ($this->database->type() === 'standalone-mongodb') {
+ } else if ($this->database->type() === 'standalone-mongodb') {
$activity = StartMongodb::run($this->database);
$this->emit('newMonitorActivity', $activity->id);
+ } else if ($this->database->type() === 'standalone-mysql') {
+ $activity = StartMysql::run($this->database);
+ $this->emit('newMonitorActivity', $activity->id);
+ } else if ($this->database->type() === 'standalone-mariadb') {
+ $activity = StartMariadb::run($this->database);
+ $this->emit('newMonitorActivity', $activity->id);
}
}
}
diff --git a/app/Http/Livewire/Project/Database/Mariadb/General.php b/app/Http/Livewire/Project/Database/Mariadb/General.php
new file mode 100644
index 0000000000..4d04371d06
--- /dev/null
+++ b/app/Http/Livewire/Project/Database/Mariadb/General.php
@@ -0,0 +1,95 @@
+<?php
+
+namespace App\Http\Livewire\Project\Database\Mariadb;
+
+use App\Actions\Database\StartDatabaseProxy;
+use App\Actions\Database\StopDatabaseProxy;
+use App\Models\StandaloneMariadb;
+use Exception;
+use Livewire\Component;
+
+class General extends Component
+{
+ protected $listeners = ['refresh'];
+
+ public StandaloneMariadb $database;
+ public string $db_url;
+
+ protected $rules = [
+ 'database.name' => 'required',
+ 'database.description' => 'nullable',
+ 'database.mariadb_root_password' => 'required',
+ 'database.mariadb_user' => 'required',
+ 'database.mariadb_password' => 'required',
+ 'database.mariadb_database' => 'required',
+ 'database.mariadb_conf' => 'nullable',
+ 'database.image' => 'required',
+ 'database.ports_mappings' => 'nullable',
+ 'database.is_public' => 'nullable|boolean',
+ 'database.public_port' => 'nullable|integer',
+ ];
+ protected $validationAttributes = [
+ 'database.name' => 'Name',
+ 'database.description' => 'Description',
+ 'database.mariadb_root_password' => 'Root Password',
+ 'database.mariadb_user' => 'User',
+ 'database.mariadb_password' => 'Password',
+ 'database.mariadb_database' => 'Database',
+ 'database.mariadb_conf' => 'MariaDB Configuration',
+ 'database.image' => 'Image',
+ 'database.ports_mappings' => 'Port Mapping',
+ 'database.is_public' => 'Is Public',
+ 'database.public_port' => 'Public Port',
+ ];
+ public function submit()
+ {
+ try {
+ $this->validate();
+ $this->database->save();
+ $this->emit('success', 'Database updated successfully.');
+ } catch (Exception $e) {
+ return handleError($e, $this);
+ }
+ }
+ public function instantSave()
+ {
+ try {
+ if ($this->database->is_public && !$this->database->public_port) {
+ $this->emit('error', 'Public port is required.');
+ $this->database->is_public = false;
+ return;
+ }
+ if ($this->database->is_public) {
+ if (!str($this->database->status)->startsWith('running')) {
+ $this->emit('error', 'Database must be started to be publicly accessible.');
+ $this->database->is_public = false;
+ return;
+ }
+ StartDatabaseProxy::run($this->database);
+ $this->emit('success', 'Database is now publicly accessible.');
+ } else {
+ StopDatabaseProxy::run($this->database);
+ $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;
+ return handleError($e, $this);
+ }
+ }
+ public function refresh(): void
+ {
+ $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 e0fc3c2776..2e6bed4a44 100644
--- a/app/Http/Livewire/Project/Database/Mongodb/General.php
+++ b/app/Http/Livewire/Project/Database/Mongodb/General.php
@@ -39,7 +39,8 @@ class General extends Component
'database.is_public' => 'Is Public',
'database.public_port' => 'Public Port',
];
- public function submit() {
+ public function submit()
+ {
try {
$this->validate();
if ($this->database->mongo_conf === "") {
@@ -60,7 +61,11 @@ class General extends Component
return;
}
if ($this->database->is_public) {
- $this->emit('success', 'Starting TCP proxy...');
+ if (!str($this->database->status)->startsWith('running')) {
+ $this->emit('error', 'Database must be started to be publicly accessible.');
+ $this->database->is_public = false;
+ return;
+ }
StartDatabaseProxy::run($this->database);
$this->emit('success', 'Database is now publicly accessible.');
} else {
@@ -69,7 +74,7 @@ class General extends Component
}
$this->db_url = $this->database->getDbUrl();
$this->database->save();
- } catch(\Throwable $e) {
+ } catch (\Throwable $e) {
$this->database->is_public = !$this->database->is_public;
return handleError($e, $this);
}
diff --git a/app/Http/Livewire/Project/Database/Mysql/General.php b/app/Http/Livewire/Project/Database/Mysql/General.php
new file mode 100644
index 0000000000..ca7eb6ebe3
--- /dev/null
+++ b/app/Http/Livewire/Project/Database/Mysql/General.php
@@ -0,0 +1,95 @@
+<?php
+
+namespace App\Http\Livewire\Project\Database\Mysql;
+
+use App\Actions\Database\StartDatabaseProxy;
+use App\Actions\Database\StopDatabaseProxy;
+use App\Models\StandaloneMysql;
+use Exception;
+use Livewire\Component;
+
+class General extends Component
+{
+ protected $listeners = ['refresh'];
+
+ public StandaloneMysql $database;
+ public string $db_url;
+
+ protected $rules = [
+ 'database.name' => 'required',
+ 'database.description' => 'nullable',
+ 'database.mysql_root_password' => 'required',
+ 'database.mysql_user' => 'required',
+ 'database.mysql_password' => 'required',
+ 'database.mysql_database' => 'required',
+ 'database.mysql_conf' => 'nullable',
+ 'database.image' => 'required',
+ 'database.ports_mappings' => 'nullable',
+ 'database.is_public' => 'nullable|boolean',
+ 'database.public_port' => 'nullable|integer',
+ ];
+ protected $validationAttributes = [
+ 'database.name' => 'Name',
+ 'database.description' => 'Description',
+ 'database.mysql_root_password' => 'Root Password',
+ 'database.mysql_user' => 'User',
+ 'database.mysql_password' => 'Password',
+ 'database.mysql_database' => 'Database',
+ 'database.mysql_conf' => 'MySQL Configuration',
+ 'database.image' => 'Image',
+ 'database.ports_mappings' => 'Port Mapping',
+ 'database.is_public' => 'Is Public',
+ 'database.public_port' => 'Public Port',
+ ];
+ public function submit()
+ {
+ try {
+ $this->validate();
+ $this->database->save();
+ $this->emit('success', 'Database updated successfully.');
+ } catch (Exception $e) {
+ return handleError($e, $this);
+ }
+ }
+ public function instantSave()
+ {
+ try {
+ if ($this->database->is_public && !$this->database->public_port) {
+ $this->emit('error', 'Public port is required.');
+ $this->database->is_public = false;
+ return;
+ }
+ if ($this->database->is_public) {
+ if (!str($this->database->status)->startsWith('running')) {
+ $this->emit('error', 'Database must be started to be publicly accessible.');
+ $this->database->is_public = false;
+ return;
+ }
+ StartDatabaseProxy::run($this->database);
+ $this->emit('success', 'Database is now publicly accessible.');
+ } else {
+ StopDatabaseProxy::run($this->database);
+ $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;
+ return handleError($e, $this);
+ }
+ }
+ public function refresh(): void
+ {
+ $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 df1f0da85d..4e3bda418b 100644
--- a/app/Http/Livewire/Project/Database/Postgresql/General.php
+++ b/app/Http/Livewire/Project/Database/Postgresql/General.php
@@ -60,7 +60,11 @@ class General extends Component
return;
}
if ($this->database->is_public) {
- $this->emit('success', 'Starting TCP proxy...');
+ if (!str($this->database->status)->startsWith('running')) {
+ $this->emit('error', 'Database must be started to be publicly accessible.');
+ $this->database->is_public = false;
+ return;
+ }
StartDatabaseProxy::run($this->database);
$this->emit('success', 'Database is now publicly accessible.');
} else {
@@ -69,11 +73,10 @@ class General extends Component
}
$this->db_url = $this->database->getDbUrl();
$this->database->save();
- } catch(\Throwable $e) {
+ } catch (\Throwable $e) {
$this->database->is_public = !$this->database->is_public;
return handleError($e, $this);
}
-
}
public function save_init_script($script)
{
diff --git a/app/Http/Livewire/Project/Database/Redis/General.php b/app/Http/Livewire/Project/Database/Redis/General.php
index 6f33ae30a9..dd2e8151da 100644
--- a/app/Http/Livewire/Project/Database/Redis/General.php
+++ b/app/Http/Livewire/Project/Database/Redis/General.php
@@ -35,7 +35,8 @@ class General extends Component
'database.is_public' => 'Is Public',
'database.public_port' => 'Public Port',
];
- public function submit() {
+ public function submit()
+ {
try {
$this->validate();
if ($this->database->redis_conf === "") {
@@ -56,7 +57,11 @@ class General extends Component
return;
}
if ($this->database->is_public) {
- $this->emit('success', 'Starting TCP proxy...');
+ if (!str($this->database->status)->startsWith('running')) {
+ $this->emit('error', 'Database must be started to be publicly accessible.');
+ $this->database->is_public = false;
+ return;
+ }
StartDatabaseProxy::run($this->database);
$this->emit('success', 'Database is now publicly accessible.');
} else {
@@ -65,7 +70,7 @@ class General extends Component
}
$this->db_url = $this->database->getDbUrl();
$this->database->save();
- } catch(\Throwable $e) {
+ } catch (\Throwable $e) {
$this->database->is_public = !$this->database->is_public;
return handleError($e, $this);
}
diff --git a/app/Http/Livewire/Project/Shared/EnvironmentVariable/All.php b/app/Http/Livewire/Project/Shared/EnvironmentVariable/All.php
index f453b4bf3c..9b714a5901 100644
--- a/app/Http/Livewire/Project/Shared/EnvironmentVariable/All.php
+++ b/app/Http/Livewire/Project/Shared/EnvironmentVariable/All.php
@@ -81,6 +81,12 @@ class All extends Component
case 'standalone-mongodb':
$environment->standalone_mongodb_id = $this->resource->id;
break;
+ case 'standalone-mysql':
+ $environment->standalone_mysql_id = $this->resource->id;
+ break;
+ case 'standalone-mariadb':
+ $environment->standalone_mariadb_id = $this->resource->id;
+ break;
case 'service':
$environment->service_id = $this->resource->id;
break;
diff --git a/app/Http/Livewire/Project/Shared/Logs.php b/app/Http/Livewire/Project/Shared/Logs.php
index 80cdf82c4b..2b0561800d 100644
--- a/app/Http/Livewire/Project/Shared/Logs.php
+++ b/app/Http/Livewire/Project/Shared/Logs.php
@@ -5,7 +5,9 @@ namespace App\Http\Livewire\Project\Shared;
use App\Models\Application;
use App\Models\Server;
use App\Models\Service;
+use App\Models\StandaloneMariadb;
use App\Models\StandaloneMongodb;
+use App\Models\StandaloneMysql;
use App\Models\StandalonePostgresql;
use App\Models\StandaloneRedis;
use Livewire\Component;
@@ -13,7 +15,7 @@ use Livewire\Component;
class Logs extends Component
{
public ?string $type = null;
- public Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb $resource;
+ public Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb $resource;
public Server $server;
public ?string $container = null;
public $parameters;
@@ -41,11 +43,16 @@ class Logs extends Component
if (is_null($resource)) {
$resource = StandaloneMongodb::where('uuid', $this->parameters['database_uuid'])->first();
if (is_null($resource)) {
- abort(404);
+ $resource = StandaloneMysql::where('uuid', $this->parameters['database_uuid'])->first();
+ if (is_null($resource)) {
+ $resource = StandaloneMariadb::where('uuid', $this->parameters['database_uuid'])->first();
+ if (is_null($resource)) {
+ abort(404);
+ }
+ }
}
}
}
-
$this->resource = $resource;
$this->status = $this->resource->status;
$this->server = $this->resource->destination->server;
diff --git a/app/Jobs/DatabaseBackupJob.php b/app/Jobs/DatabaseBackupJob.php
index d73474018a..da660c4490 100644
--- a/app/Jobs/DatabaseBackupJob.php
+++ b/app/Jobs/DatabaseBackupJob.php
@@ -6,7 +6,9 @@ use App\Models\S3Storage;
use App\Models\ScheduledDatabaseBackup;
use App\Models\ScheduledDatabaseBackupExecution;
use App\Models\Server;
+use App\Models\StandaloneMariadb;
use App\Models\StandaloneMongodb;
+use App\Models\StandaloneMysql;
use App\Models\StandalonePostgresql;
use App\Models\Team;
use App\Notifications\Database\BackupFailed;
@@ -28,7 +30,7 @@ class DatabaseBackupJob implements ShouldQueue, ShouldBeEncrypted
public ?Team $team = null;
public Server $server;
public ScheduledDatabaseBackup $backup;
- public StandalonePostgresql|StandaloneMongodb $database;
+ public StandalonePostgresql|StandaloneMongodb|StandaloneMysql|StandaloneMariadb $database;
public ?string $container_name = null;
public ?ScheduledDatabaseBackupExecution $backup_log = null;
@@ -75,6 +77,10 @@ class DatabaseBackupJob implements ShouldQueue, ShouldBeEncrypted
$databasesToBackup = [$this->database->postgres_db];
} else if ($databaseType === 'standalone-mongodb') {
$databasesToBackup = ['*'];
+ } else if ($databaseType === 'standalone-mysql') {
+ $databasesToBackup = [$this->database->mysql_database];
+ } else if ($databaseType === 'standalone-mariadb') {
+ $databasesToBackup = [$this->database->mariadb_database];
} else {
return;
}
@@ -88,6 +94,14 @@ class DatabaseBackupJob implements ShouldQueue, ShouldBeEncrypted
$databasesToBackup = explode('|', $databasesToBackup);
$databasesToBackup = array_map('trim', $databasesToBackup);
ray($databasesToBackup);
+ } else if ($databaseType === 'standalone-mysql') {
+ // Format: db1,db2,db3
+ $databasesToBackup = explode(',', $databasesToBackup);
+ $databasesToBackup = array_map('trim', $databasesToBackup);
+ } else if ($databaseType === 'standalone-mariadb') {
+ // Format: db1,db2,db3
+ $databasesToBackup = explode(',', $databasesToBackup);
+ $databasesToBackup = array_map('trim', $databasesToBackup);
} else {
return;
}
@@ -124,7 +138,6 @@ class DatabaseBackupJob implements ShouldQueue, ShouldBeEncrypted
} else {
$databaseName = $database;
}
- ray($databaseName);
}
$this->backup_file = "/mongo-dump-$databaseName-" . Carbon::now()->timestamp . ".tar.gz";
$this->backup_location = $this->backup_dir . $this->backup_file;
@@ -134,6 +147,24 @@ class DatabaseBackupJob implements ShouldQueue, ShouldBeEncrypted
'scheduled_database_backup_id' => $this->backup->id,
]);
$this->backup_standalone_mongodb($database);
+ } else if ($databaseType === 'standalone-mysql') {
+ $this->backup_file = "/mysql-dump-$database-" . Carbon::now()->timestamp . ".dmp";
+ $this->backup_location = $this->backup_dir . $this->backup_file;
+ $this->backup_log = ScheduledDatabaseBackupExecution::create([
+ 'database_name' => $database,
+ 'filename' => $this->backup_location,
+ 'scheduled_database_backup_id' => $this->backup->id,
+ ]);
+ $this->backup_standalone_mysql($database);
+ } else if ($databaseType === 'standalone-mariadb') {
+ $this->backup_file = "/mariadb-dump-$database-" . Carbon::now()->timestamp . ".dmp";
+ $this->backup_location = $this->backup_dir . $this->backup_file;
+ $this->backup_log = ScheduledDatabaseBackupExecution::create([
+ 'database_name' => $database,
+ 'filename' => $this->backup_location,
+ 'scheduled_database_backup_id' => $this->backup->id,
+ ]);
+ $this->backup_standalone_mariadb($database);
} else {
throw new \Exception('Unsupported database type');
}
@@ -218,7 +249,42 @@ class DatabaseBackupJob implements ShouldQueue, ShouldBeEncrypted
throw $e;
}
}
-
+ private function backup_standalone_mysql(string $database): void
+ {
+ try {
+ $commands[] = "mkdir -p " . $this->backup_dir;
+ $commands[] = "docker exec $this->container_name mysqldump -u root -p{$this->database->mysql_root_password} $database > $this->backup_location";
+ ray($commands);
+ $this->backup_output = instant_remote_process($commands, $this->server);
+ $this->backup_output = trim($this->backup_output);
+ if ($this->backup_output === '') {
+ $this->backup_output = null;
+ }
+ ray('Backup done for ' . $this->container_name . ' at ' . $this->server->name . ':' . $this->backup_location);
+ } catch (\Throwable $e) {
+ $this->add_to_backup_output($e->getMessage());
+ ray('Backup failed for ' . $this->container_name . ' at ' . $this->server->name . ':' . $this->backup_location . '\n\nError:' . $e->getMessage());
+ throw $e;
+ }
+ }
+ private function backup_standalone_mariadb(string $database): void
+ {
+ try {
+ $commands[] = "mkdir -p " . $this->backup_dir;
+ $commands[] = "docker exec $this->container_name mariadb-dump -u root -p{$this->database->mariadb_root_password} $database > $this->backup_location";
+ ray($commands);
+ $this->backup_output = instant_remote_process($commands, $this->server);
+ $this->backup_output = trim($this->backup_output);
+ if ($this->backup_output === '') {
+ $this->backup_output = null;
+ }
+ ray('Backup done for ' . $this->container_name . ' at ' . $this->server->name . ':' . $this->backup_location);
+ } catch (\Throwable $e) {
+ $this->add_to_backup_output($e->getMessage());
+ ray('Backup failed for ' . $this->container_name . ' at ' . $this->server->name . ':' . $this->backup_location . '\n\nError:' . $e->getMessage());
+ throw $e;
+ }
+ }
private function add_to_backup_output($output): void
{
if ($this->backup_output) {
diff --git a/app/Jobs/StopResourceJob.php b/app/Jobs/StopResourceJob.php
index 721f7f6989..76c5588b83 100644
--- a/app/Jobs/StopResourceJob.php
+++ b/app/Jobs/StopResourceJob.php
@@ -7,7 +7,9 @@ use App\Actions\Database\StopDatabase;
use App\Actions\Service\StopService;
use App\Models\Application;
use App\Models\Service;
+use App\Models\StandaloneMariadb;
use App\Models\StandaloneMongodb;
+use App\Models\StandaloneMysql;
use App\Models\StandalonePostgresql;
use App\Models\StandaloneRedis;
use Illuminate\Bus\Queueable;
@@ -21,7 +23,7 @@ class StopResourceJob implements ShouldQueue, ShouldBeEncrypted
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
- public function __construct(public Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb $resource)
+ public function __construct(public Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb $resource)
{
}
@@ -45,6 +47,12 @@ class StopResourceJob implements ShouldQueue, ShouldBeEncrypted
case 'standalone-mongodb':
StopDatabase::run($this->resource);
break;
+ case 'standalone-mysql':
+ StopDatabase::run($this->resource);
+ break;
+ case 'standalone-mariadb':
+ StopDatabase::run($this->resource);
+ break;
case 'service':
StopService::run($this->resource);
break;
diff --git a/app/Models/Environment.php b/app/Models/Environment.php
index 55dbeee945..430a02cdbc 100644
--- a/app/Models/Environment.php
+++ b/app/Models/Environment.php
@@ -34,13 +34,23 @@ class Environment extends Model
{
return $this->hasMany(StandaloneMongodb::class);
}
+ public function mysqls()
+ {
+ return $this->hasMany(StandaloneMysql::class);
+ }
+ public function mariadbs()
+ {
+ return $this->hasMany(StandaloneMariadb::class);
+ }
public function databases()
{
$postgresqls = $this->postgresqls;
$redis = $this->redis;
$mongodbs = $this->mongodbs;
- return $postgresqls->concat($redis)->concat($mongodbs);
+ $mysqls = $this->mysqls;
+ $mariadbs = $this->mariadbs;
+ return $postgresqls->concat($redis)->concat($mongodbs)->concat($mysqls)->concat($mariadbs);
}
public function project()
diff --git a/app/Models/Project.php b/app/Models/Project.php
index a910348b4f..1668d40598 100644
--- a/app/Models/Project.php
+++ b/app/Models/Project.php
@@ -56,4 +56,16 @@ class Project extends BaseModel
{
return $this->hasManyThrough(StandaloneRedis::class, Environment::class);
}
+ public function mongodbs()
+ {
+ return $this->hasManyThrough(StandaloneMongodb::class, Environment::class);
+ }
+ public function mysqls()
+ {
+ return $this->hasMany(StandaloneMysql::class, Environment::class);
+ }
+ public function mariadbs()
+ {
+ return $this->hasMany(StandaloneMariadb::class, Environment::class);
+ }
}
diff --git a/app/Models/Server.php b/app/Models/Server.php
index 7ff517ef63..11be557646 100644
--- a/app/Models/Server.php
+++ b/app/Models/Server.php
@@ -122,10 +122,12 @@ class Server extends BaseModel
public function databases()
{
return $this->destinations()->map(function ($standaloneDocker) {
- $postgresqls = data_get($standaloneDocker,'postgresqls',collect([]));
- $redis = data_get($standaloneDocker,'redis',collect([]));
- $mongodbs = data_get($standaloneDocker,'mongodbs',collect([]));
- return $postgresqls->concat($redis)->concat($mongodbs);
+ $postgresqls = data_get($standaloneDocker, 'postgresqls', collect([]));
+ $redis = data_get($standaloneDocker, 'redis', collect([]));
+ $mongodbs = data_get($standaloneDocker, 'mongodbs', collect([]));
+ $mysqls = data_get($standaloneDocker, 'mysqls', collect([]));
+ $mariadbs = data_get($standaloneDocker, 'mariadbs', collect([]));
+ return $postgresqls->concat($redis)->concat($mongodbs)->concat($mysqls)->concat($mariadbs);
})->flatten();
}
public function applications()
@@ -258,7 +260,8 @@ class Server extends BaseModel
$this->settings->save();
return true;
}
- public function validateCoolifyNetwork() {
+ public function validateCoolifyNetwork()
+ {
return instant_remote_process(["docker network create coolify --attachable >/dev/null 2>&1 || true"], $this, false);
}
}
diff --git a/app/Models/StandaloneDocker.php b/app/Models/StandaloneDocker.php
index 9e70b7514f..277a250c93 100644
--- a/app/Models/StandaloneDocker.php
+++ b/app/Models/StandaloneDocker.php
@@ -24,6 +24,14 @@ class StandaloneDocker extends BaseModel
{
return $this->morphMany(StandaloneMongodb::class, 'destination');
}
+ public function mysqls()
+ {
+ return $this->morphMany(StandaloneMysql::class, 'destination');
+ }
+ public function mariadbs()
+ {
+ return $this->morphMany(StandaloneMariadb::class, 'destination');
+ }
public function server()
{
@@ -35,6 +43,16 @@ class StandaloneDocker extends BaseModel
return $this->morphMany(Service::class, 'destination');
}
+ public function databases()
+ {
+ $postgresqls = $this->postgresqls;
+ $redis = $this->redis;
+ $mongodbs = $this->mongodbs;
+ $mysqls = $this->mysqls;
+ $mariadbs = $this->mariadbs;
+ return $postgresqls->concat($redis)->concat($mongodbs)->concat($mysqls)->concat($mariadbs);
+ }
+
public function attachedTo()
{
return $this->applications?->count() > 0 || $this->databases?->count() > 0;
diff --git a/app/Models/StandaloneMariadb.php b/app/Models/StandaloneMariadb.php
new file mode 100644
index 0000000000..5e721857bc
--- /dev/null
+++ b/app/Models/StandaloneMariadb.php
@@ -0,0 +1,106 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Casts\Attribute;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\HasMany;
+
+class StandaloneMariadb extends BaseModel
+{
+ use HasFactory;
+
+ protected $guarded = [];
+ protected $casts = [
+ 'mariadb_password' => 'encrypted',
+ ];
+
+ protected static function booted()
+ {
+ static::created(function ($database) {
+ LocalPersistentVolume::create([
+ 'name' => 'mariadb-data-' . $database->uuid,
+ 'mount_path' => '/var/lib/mysql',
+ 'host_path' => null,
+ 'resource_id' => $database->id,
+ 'resource_type' => $database->getMorphClass(),
+ 'is_readonly' => true
+ ]);
+ });
+ static::deleting(function ($database) {
+ $storages = $database->persistentStorages()->get();
+ foreach ($storages as $storage) {
+ instant_remote_process(["docker volume rm -f $storage->name"], $database->destination->server, false);
+ }
+ $database->scheduledBackups()->delete();
+ $database->persistentStorages()->delete();
+ $database->environment_variables()->delete();
+ });
+ }
+ public function type(): string
+ {
+ return 'standalone-mariadb';
+ }
+
+ public function portsMappings(): Attribute
+ {
+ return Attribute::make(
+ set: fn ($value) => $value === "" ? null : $value,
+ );
+ }
+
+ public function portsMappingsArray(): Attribute
+ {
+ return Attribute::make(
+ get: fn () => is_null($this->ports_mappings)
+ ? []
+ : explode(',', $this->ports_mappings),
+
+ );
+ }
+
+ public function getDbUrl(bool $useInternal = false): string
+ {
+ if ($this->is_public && !$useInternal) {
+ return "mysql://{$this->mariadb_user}:{$this->mariadb_password}@{$this->destination->server->getIp}:{$this->public_port}/{$this->mariadb_database}";
+ } else {
+ return "mysql://{$this->mariadb_user}:{$this->mariadb_password}@{$this->uuid}:3306/{$this->mariadb_database}";
+ }
+ }
+
+ public function environment()
+ {
+ return $this->belongsTo(Environment::class);
+ }
+
+ public function fileStorages()
+ {
+ return $this->morphMany(LocalFileVolume::class, 'resource');
+ }
+
+ public function destination()
+ {
+ return $this->morphTo();
+ }
+
+ public function environment_variables(): HasMany
+ {
+ return $this->hasMany(EnvironmentVariable::class);
+ }
+
+ public function runtime_environment_variables(): HasMany
+ {
+ return $this->hasMany(EnvironmentVariable::class);
+ }
+
+ public function persistentStorages()
+ {
+ return $this->morphMany(LocalPersistentVolume::class, 'resource');
+ }
+
+ public function scheduledBackups()
+ {
+ return $this->morphMany(ScheduledDatabaseBackup::class, 'database');
+ }
+}
diff --git a/app/Models/StandaloneMysql.php b/app/Models/StandaloneMysql.php
new file mode 100644
index 0000000000..53a797d49c
--- /dev/null
+++ b/app/Models/StandaloneMysql.php
@@ -0,0 +1,106 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Casts\Attribute;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Relations\HasMany;
+
+class StandaloneMysql extends BaseModel
+{
+ use HasFactory;
+
+ protected $guarded = [];
+ protected $casts = [
+ 'mysql_password' => 'encrypted',
+ 'mysql_root_password' => 'encrypted',
+ ];
+
+ protected static function booted()
+ {
+ static::created(function ($database) {
+ LocalPersistentVolume::create([
+ 'name' => 'mysql-data-' . $database->uuid,
+ 'mount_path' => '/var/lib/mysql',
+ 'host_path' => null,
+ 'resource_id' => $database->id,
+ 'resource_type' => $database->getMorphClass(),
+ 'is_readonly' => true
+ ]);
+ });
+ static::deleting(function ($database) {
+ $storages = $database->persistentStorages()->get();
+ foreach ($storages as $storage) {
+ instant_remote_process(["docker volume rm -f $storage->name"], $database->destination->server, false);
+ }
+ $database->scheduledBackups()->delete();
+ $database->persistentStorages()->delete();
+ $database->environment_variables()->delete();
+ });
+ }
+ public function type(): string
+ {
+ return 'standalone-mysql';
+ }
+
+ public function portsMappings(): Attribute
+ {
+ return Attribute::make(
+ set: fn ($value) => $value === "" ? null : $value,
+ );
+ }
+
+ public function portsMappingsArray(): Attribute
+ {
+ return Attribute::make(
+ get: fn () => is_null($this->ports_mappings)
+ ? []
+ : explode(',', $this->ports_mappings),
+
+ );
+ }
+
+ public function getDbUrl(bool $useInternal = false): string
+ {
+ if ($this->is_public && !$useInternal) {
+ return "mysql://{$this->mysql_user}:{$this->mysql_password}@{$this->destination->server->getIp}:{$this->public_port}/{$this->mysql_database}";
+ } else {
+ return "mysql://{$this->mysql_user}:{$this->mysql_password}@{$this->uuid}:3306/{$this->mysql_database}";
+ }
+ }
+
+ public function environment()
+ {
+ return $this->belongsTo(Environment::class);
+ }
+
+ public function fileStorages()
+ {
+ return $this->morphMany(LocalFileVolume::class, 'resource');
+ }
+
+ public function destination()
+ {
+ return $this->morphTo();
+ }
+
+ public function environment_variables(): HasMany
+ {
+ return $this->hasMany(EnvironmentVariable::class);
+ }
+
+ public function runtime_environment_variables(): HasMany
+ {
+ return $this->hasMany(EnvironmentVariable::class);
+ }
+
+ public function persistentStorages()
+ {
+ return $this->morphMany(LocalPersistentVolume::class, 'resource');
+ }
+
+ public function scheduledBackups()
+ {
+ return $this->morphMany(ScheduledDatabaseBackup::class, 'database');
+ }
+}
diff --git a/app/Models/StandalonePostgresql.php b/app/Models/StandalonePostgresql.php
index 3a0432180a..bbfabbf677 100644
--- a/app/Models/StandalonePostgresql.php
+++ b/app/Models/StandalonePostgresql.php
@@ -46,8 +46,6 @@ class StandalonePostgresql extends BaseModel
);
}
- // Normal Deployments
-
public function portsMappingsArray(): Attribute
{
return Attribute::make(
diff --git a/bootstrap/helpers/constants.php b/bootstrap/helpers/constants.php
index 586ba531d5..10c1353d38 100644
--- a/bootstrap/helpers/constants.php
+++ b/bootstrap/helpers/constants.php
@@ -1,6 +1,6 @@
<?php
-const DATABASE_TYPES = ['postgresql','redis', 'mongodb'];
+const DATABASE_TYPES = ['postgresql', 'redis', 'mongodb', 'mysql', 'mariadb'];
const VALID_CRON_STRINGS = [
'every_minute' => '* * * * *',
'hourly' => '0 * * * *',
diff --git a/bootstrap/helpers/databases.php b/bootstrap/helpers/databases.php
index 0c5c8898ea..007c414bd4 100644
--- a/bootstrap/helpers/databases.php
+++ b/bootstrap/helpers/databases.php
@@ -2,7 +2,9 @@
use App\Models\Server;
use App\Models\StandaloneDocker;
+use App\Models\StandaloneMariadb;
use App\Models\StandaloneMongodb;
+use App\Models\StandaloneMysql;
use App\Models\StandalonePostgresql;
use App\Models\StandaloneRedis;
use Visus\Cuid2\Cuid2;
@@ -58,6 +60,36 @@ function create_standalone_mongodb($environment_id, $destination_uuid): Standalo
'destination_type' => $destination->getMorphClass(),
]);
}
+function create_standalone_mysql($environment_id, $destination_uuid): StandaloneMysql
+{
+ $destination = StandaloneDocker::where('uuid', $destination_uuid)->first();
+ if (!$destination) {
+ throw new Exception('Destination not found');
+ }
+ return StandaloneMysql::create([
+ 'name' => generate_database_name('mysql'),
+ 'mysql_root_password' => \Illuminate\Support\Str::password(symbols: false),
+ 'mysql_password' => \Illuminate\Support\Str::password(symbols: false),
+ 'environment_id' => $environment_id,
+ 'destination_id' => $destination->id,
+ 'destination_type' => $destination->getMorphClass(),
+ ]);
+}
+function create_standalone_mariadb($environment_id, $destination_uuid): StandaloneMariadb
+{
+ $destination = StandaloneDocker::where('uuid', $destination_uuid)->first();
+ if (!$destination) {
+ throw new Exception('Destination not found');
+ }
+ return StandaloneMariadb::create([
+ 'name' => generate_database_name('mariadb'),
+ 'mariadb_root_password' => \Illuminate\Support\Str::password(symbols: false),
+ 'mariadb_password' => \Illuminate\Support\Str::password(symbols: false),
+ 'environment_id' => $environment_id,
+ 'destination_id' => $destination->id,
+ 'destination_type' => $destination->getMorphClass(),
+ ]);
+}
/**
* Delete file locally on the filesystem.
diff --git a/database/migrations/2023_10_24_103548_create_standalone_mysqls_table.php b/database/migrations/2023_10_24_103548_create_standalone_mysqls_table.php
new file mode 100644
index 0000000000..2b069424a1
--- /dev/null
+++ b/database/migrations/2023_10_24_103548_create_standalone_mysqls_table.php
@@ -0,0 +1,57 @@
+<?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::create('standalone_mysqls', function (Blueprint $table) {
+ $table->id();
+ $table->string('uuid')->unique();
+ $table->string('name');
+ $table->string('description')->nullable();
+
+ $table->text('mysql_root_password');
+ $table->string('mysql_user')->default('mysql');
+ $table->text('mysql_password');
+ $table->string('mysql_database')->default('default');
+ $table->longText('mysql_conf')->nullable();
+
+ $table->string('status')->default('exited');
+
+ $table->string('image')->default('mysql:8');
+ $table->boolean('is_public')->default(false);
+ $table->integer('public_port')->nullable();
+ $table->text('ports_mappings')->nullable();
+
+ $table->string('limits_memory')->default("0");
+ $table->string('limits_memory_swap')->default("0");
+ $table->integer('limits_memory_swappiness')->default(60);
+ $table->string('limits_memory_reservation')->default("0");
+
+ $table->string('limits_cpus')->default("0");
+ $table->string('limits_cpuset')->nullable()->default("0");
+ $table->integer('limits_cpu_shares')->default(1024);
+
+ $table->timestamp('started_at')->nullable();
+ $table->morphs('destination');
+
+ $table->foreignId('environment_id')->nullable();
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::dropIfExists('standalone_mysqls');
+ }
+};
diff --git a/database/migrations/2023_10_24_120523_create_standalone_mariadbs_table.php b/database/migrations/2023_10_24_120523_create_standalone_mariadbs_table.php
new file mode 100644
index 0000000000..4d7b89f4cb
--- /dev/null
+++ b/database/migrations/2023_10_24_120523_create_standalone_mariadbs_table.php
@@ -0,0 +1,57 @@
+<?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::create('standalone_mariadbs', function (Blueprint $table) {
+ $table->id();
+ $table->string('uuid')->unique();
+ $table->string('name');
+ $table->string('description')->nullable();
+
+ $table->text('mariadb_root_password');
+ $table->string('mariadb_user')->default('mariadb');
+ $table->text('mariadb_password');
+ $table->string('mariadb_database')->default('default');
+ $table->longText('mariadb_conf')->nullable();
+
+ $table->string('status')->default('exited');
+
+ $table->string('image')->default('mariadb:11');
+ $table->boolean('is_public')->default(false);
+ $table->integer('public_port')->nullable();
+ $table->text('ports_mappings')->nullable();
+
+ $table->string('limits_memory')->default("0");
+ $table->string('limits_memory_swap')->default("0");
+ $table->integer('limits_memory_swappiness')->default(60);
+ $table->string('limits_memory_reservation')->default("0");
+
+ $table->string('limits_cpus')->default("0");
+ $table->string('limits_cpuset')->nullable()->default("0");
+ $table->integer('limits_cpu_shares')->default(1024);
+
+ $table->timestamp('started_at')->nullable();
+ $table->morphs('destination');
+
+ $table->foreignId('environment_id')->nullable();
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::dropIfExists('standalone_mariadbs');
+ }
+};
diff --git a/database/migrations/2023_10_24_120524_add_standalone_mysql_to_environment_variables_table.php b/database/migrations/2023_10_24_120524_add_standalone_mysql_to_environment_variables_table.php
new file mode 100644
index 0000000000..a511e9b21c
--- /dev/null
+++ b/database/migrations/2023_10_24_120524_add_standalone_mysql_to_environment_variables_table.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('environment_variables', function (Blueprint $table) {
+ $table->foreignId('standalone_mysql_id')->nullable();
+ $table->foreignId('standalone_mariadb_id')->nullable();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::table('environment_variables', function (Blueprint $table) {
+ $table->dropColumn('standalone_mysql_id');
+ $table->dropColumn('standalone_mariadb_id');
+ });
+ }
+};
diff --git a/resources/views/components/databases/navbar.blade.php b/resources/views/components/databases/navbar.blade.php
index 64dc1d2886..ecf4ca5739 100644
--- a/resources/views/components/databases/navbar.blade.php
+++ b/resources/views/components/databases/navbar.blade.php
@@ -7,7 +7,11 @@
href="{{ route('project.database.logs', $parameters) }}">
<button>Logs</button>
</a>
- @if ($database->getMorphClass() === 'App\Models\StandalonePostgresql' || $database->getMorphClass() === 'App\Models\StandaloneMongodb')
+ @if (
+ $database->getMorphClass() === 'App\Models\StandalonePostgresql' ||
+ $database->getMorphClass() === 'App\Models\StandaloneMongodb' ||
+ $database->getMorphClass() === 'App\Models\StandaloneMysql' ||
+ $database->getMorphClass() === 'App\Models\StandaloneMariadb')
<a class="{{ request()->routeIs('project.database.backups.all') ? 'text-white' : '' }}"
href="{{ route('project.database.backups.all', $parameters) }}">
<button>Backups</button>
diff --git a/resources/views/livewire/project/database/backup-edit.blade.php b/resources/views/livewire/project/database/backup-edit.blade.php
index 7d634a37b1..0542ee087d 100644
--- a/resources/views/livewire/project/database/backup-edit.blade.php
+++ b/resources/views/livewire/project/database/backup-edit.blade.php
@@ -35,6 +35,14 @@
<x-forms.input label="Databases To Include"
helper="A list of databases to backup. You can specify which collection(s) per database to exclude from the backup. Empty will include all databases and collections.<br><br>Example:<br><br>database1:collection1,collection2|database2:collection3,collection4<br><br> database1 will include all collections except collection1 and collection2. <br>database2 will include all collections except collection3 and collection4.<br><br>Another Example:<br><br>database1:collection1|database2<br><br> database1 will include all collections except collection1.<br>database2 will include ALL collections."
id="backup.databases_to_backup" />
+ @elseif($backup->database_type === 'App\Models\StandaloneMysql')
+ <x-forms.input label="Databases To Backup"
+ helper="Comma separated list of databases to backup. Empty will include the default one."
+ id="backup.databases_to_backup" />
+ @elseif($backup->database_type === 'App\Models\StandaloneMariadb')
+ <x-forms.input label="Databases To Backup"
+ helper="Comma separated list of databases to backup. Empty will include the default one."
+ id="backup.databases_to_backup" />
@endif
</div>
<div class="flex gap-2">
diff --git a/resources/views/livewire/project/database/backup-execution.blade.php b/resources/views/livewire/project/database/backup-execution.blade.php
deleted file mode 100644
index cf306858d8..0000000000
--- a/resources/views/livewire/project/database/backup-execution.blade.php
+++ /dev/null
@@ -1,8 +0,0 @@
-<div class="flex gap-2">
- <div class="flex-1"></div>
-
- {{-- @if (data_get($execution, 'status') !== 'failed') --}}
- {{-- <x-forms.button class="bg-coollabs-100 hover:bg-coollabs" wire:click="download">Download</x-forms.button> --}}
- {{-- @endif --}}
- <x-forms.button isError wire:click="delete">Delete</x-forms.button>
-</div>
diff --git a/resources/views/livewire/project/database/backup-executions.blade.php b/resources/views/livewire/project/database/backup-executions.blade.php
index 30af9e93e5..7b0a2ca51a 100644
--- a/resources/views/livewire/project/database/backup-executions.blade.php
+++ b/resources/views/livewire/project/database/backup-executions.blade.php
@@ -1,9 +1,10 @@
<div class="flex flex-col-reverse gap-2">
@forelse($executions as $execution)
- <form class="flex flex-col p-2 border-dotted border-1 bg-coolgray-300" @class([
- 'border-green-500' => data_get($execution, 'status') === 'success',
- 'border-red-500' => data_get($execution, 'status') === 'failed',
- ])>
+ <form wire:key="{{ data_get($execution, 'id') }}" class="flex flex-col p-2 border-dotted border-1 bg-coolgray-300"
+ @class([
+ 'border-green-500' => data_get($execution, 'status') === 'success',
+ 'border-red-500' => data_get($execution, 'status') === 'failed',
+ ])>
<div>Database: {{ data_get($execution, 'database_name', 'N/A') }}</div>
<div>Status: {{ data_get($execution, 'status') }}</div>
<div>Started At: {{ data_get($execution, 'created_at') }}</div>
@@ -14,9 +15,24 @@
kB / {{ round((int) data_get($execution, 'size') / 1024 / 1024, 3) }} MB
</div>
<div>Location: {{ data_get($execution, 'filename', 'N/A') }}</div>
- <livewire:project.database.backup-execution :execution="$execution" :wire:key="$execution->id" />
+ <div class="flex gap-2">
+ <div class="flex-1"></div>
+
+ {{-- @if (data_get($execution, 'status') !== 'failed') --}}
+ {{-- <x-forms.button class="bg-coollabs-100 hover:bg-coollabs" wire:click="download">Download</x-forms.button> --}}
+ {{-- @endif --}}
+ <x-forms.button isError onclick="sure({{ data_get($execution, 'id') }})">Delete</x-forms.button>
+ </div>
</form>
@empty
<div>No executions found.</div>
@endforelse
+ <script>
+ function sure($id) {
+ const sure = confirm('Are you sure you want to delete this backup?');
+ if (sure) {
+ Livewire.emit('deleteBackup', $id);
+ }
+ }
+ </script>
</div>
diff --git a/resources/views/livewire/project/database/mariadb/general.blade.php b/resources/views/livewire/project/database/mariadb/general.blade.php
new file mode 100644
index 0000000000..6b0205cbe6
--- /dev/null
+++ b/resources/views/livewire/project/database/mariadb/general.blade.php
@@ -0,0 +1,58 @@
+<div>
+ <form wire:submit.prevent="submit" class="flex flex-col gap-2">
+ <div class="flex items-center gap-2">
+ <h2>General</h2>
+ <x-forms.button type="submit">
+ Save
+ </x-forms.button>
+ </div>
+ <div class="flex gap-2">
+ <x-forms.input label="Name" id="database.name" />
+ <x-forms.input label="Description" id="database.description" />
+ <x-forms.input label="Image" id="database.image" required
+ helper="For all available images, check here:<br><br><a target='_blank' href='https://hub.docker.com/_/mariadb'>https://hub.docker.com/_/mariadb</a>" />
+ </div>
+ @if ($database->started_at)
+ <div class="flex gap-2">
+ <x-forms.input label="Root Password" id="database.mariadb_root_password" type="password" readonly
+ helper="You can only change this in the database." />
+ <x-forms.input label="Normal User" id="database.mariadb_user" required readonly
+ helper="You can only change this in the database." />
+ <x-forms.input label="Normal User Password" id="database.mariadb_password" type="password" required
+ readonly helper="You can only change this in the database." />
+ <x-forms.input label="Initial Database" id="database.mariadb_database"
+ placeholder="If empty, it will be the same as Username." readonly
+ helper="You can only change this in the database." />
+ </div>
+ @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>
+ <div class="flex gap-2 pb-8">
+ <x-forms.input label="Root Password" id="database.mariadb_root_password" type="password"
+ helper="You can only change this in the database." />
+ <x-forms.input label="Normal User" id="database.mariadb_user" required
+ helper="You can only change this in the database." />
+ <x-forms.input label="Normal User Password" id="database.mariadb_password" type="password" required
+ helper="You can only change this in the database." />
+ <x-forms.input label="Initial Database" id="database.mariadb_database"
+ placeholder="If empty, it will be the same as Username."
+ helper="You can only change this in the database." />
+ </div>
+ @endif
+ <div class="flex flex-col gap-2">
+ <h3 class="py-2">Network</h3>
+ <div class="flex items-end gap-2">
+ <x-forms.input placeholder="3000:5432" id="database.ports_mappings" label="Ports Mappings"
+ helper="A comma separated list of ports you would like to map to the host system.<br><span class='inline-block font-bold text-warning'>Example</span>3000:5432,3002:5433" />
+ <x-forms.input placeholder="5432" disabled="{{ $database->is_public }}" id="database.public_port"
+ label="Public Port" />
+ <x-forms.checkbox instantSave id="database.is_public" label="Accessible over the internet" />
+ </div>
+ <x-forms.input label="MariaDB 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" />
+ </div>
+ <x-forms.textarea label="Custom MariaDB Configuration" rows="10" id="database.mariadb_conf" />
+ </form>
+</div>
diff --git a/resources/views/livewire/project/database/mysql/general.blade.php b/resources/views/livewire/project/database/mysql/general.blade.php
new file mode 100644
index 0000000000..09a23a694d
--- /dev/null
+++ b/resources/views/livewire/project/database/mysql/general.blade.php
@@ -0,0 +1,58 @@
+<div>
+ <form wire:submit.prevent="submit" class="flex flex-col gap-2">
+ <div class="flex items-center gap-2">
+ <h2>General</h2>
+ <x-forms.button type="submit">
+ Save
+ </x-forms.button>
+ </div>
+ <div class="flex gap-2">
+ <x-forms.input label="Name" id="database.name" />
+ <x-forms.input label="Description" id="database.description" />
+ <x-forms.input label="Image" id="database.image" required
+ helper="For all available images, check here:<br><br><a target='_blank' href='https://hub.docker.com/_/mysql'>https://hub.docker.com/_/mysql</a>" />
+ </div>
+ @if ($database->started_at)
+ <div class="flex gap-2">
+ <x-forms.input label="Root Password" id="database.mysql_root_password" type="password" readonly
+ helper="You can only change this in the database." />
+ <x-forms.input label="Normal User" id="database.mysql_user" required readonly
+ helper="You can only change this in the database." />
+ <x-forms.input label="Normal User Password" id="database.mysql_password" type="password" required
+ readonly helper="You can only change this in the database." />
+ <x-forms.input label="Initial Database" id="database.mysql_database"
+ placeholder="If empty, it will be the same as Username." readonly
+ helper="You can only change this in the database." />
+ </div>
+ @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>
+ <div class="flex gap-2 pb-8">
+ <x-forms.input label="Root Password" id="database.mysql_root_password" type="password"
+ helper="You can only change this in the database." />
+ <x-forms.input label="Normal User" id="database.mysql_user" required
+ helper="You can only change this in the database." />
+ <x-forms.input label="Normal User Password" id="database.mysql_password" type="password" required
+ helper="You can only change this in the database." />
+ <x-forms.input label="Initial Database" id="database.mysql_database"
+ placeholder="If empty, it will be the same as Username."
+ helper="You can only change this in the database." />
+ </div>
+ @endif
+ <div class="flex flex-col gap-2">
+ <h3 class="py-2">Network</h3>
+ <div class="flex items-end gap-2">
+ <x-forms.input placeholder="3000:5432" id="database.ports_mappings" label="Ports Mappings"
+ helper="A comma separated list of ports you would like to map to the host system.<br><span class='inline-block font-bold text-warning'>Example</span>3000:5432,3002:5433" />
+ <x-forms.input placeholder="5432" disabled="{{ $database->is_public }}" id="database.public_port"
+ label="Public Port" />
+ <x-forms.checkbox instantSave id="database.is_public" label="Accessible over the internet" />
+ </div>
+ <x-forms.input label="MySQL 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" />
+ </div>
+ <x-forms.textarea label="Custom Mysql Configuration" rows="10" id="database.mysql_conf" />
+ </form>
+</div>
diff --git a/resources/views/livewire/project/new/select.blade.php b/resources/views/livewire/project/new/select.blade.php
index 6ebefda41e..a18d00fc50 100644
--- a/resources/views/livewire/project/new/select.blade.php
+++ b/resources/views/livewire/project/new/select.blade.php
@@ -114,6 +114,26 @@
</div>
</div>
</div>
+ <div class="box group" wire:click="setType('mysql')">
+ <div class="flex flex-col mx-6">
+ <div class="font-bold text-white group-hover:text-white">
+ New MySQL
+ </div>
+ <div class="description">
+ MySQL
+ </div>
+ </div>
+ </div>
+ <div class="box group" wire:click="setType('mariadb')">
+ <div class="flex flex-col mx-6">
+ <div class="font-bold text-white group-hover:text-white">
+ New Mariadb
+ </div>
+ <div class="description">
+ MySQL
+ </div>
+ </div>
+ </div>
{{-- <div class="box group" wire:click="setType('existing-postgresql')">
<div class="flex flex-col mx-6">
<div class="group-hover:text-white">
diff --git a/resources/views/project/database/backups/executions.blade.php b/resources/views/project/database/backups/executions.blade.php
index 26d4aabd04..8c4625dcde 100644
--- a/resources/views/project/database/backups/executions.blade.php
+++ b/resources/views/project/database/backups/executions.blade.php
@@ -12,7 +12,7 @@
</x-slot:modalSubmit>
</x-modal>
<div class="pt-6">
- <livewire:project.database.backup-edit :backup="$backup" :s3s="$s3s" :status="data_get($database,'status')" />
+ <livewire:project.database.backup-edit :backup="$backup" :s3s="$s3s" :status="data_get($database, 'status')" />
<h3 class="py-4">Executions</h3>
<livewire:project.database.backup-executions :backup="$backup" :executions="$executions" />
</div>
diff --git a/resources/views/project/database/configuration.blade.php b/resources/views/project/database/configuration.blade.php
index 8fbfa8f0ca..3ad6e6df58 100644
--- a/resources/views/project/database/configuration.blade.php
+++ b/resources/views/project/database/configuration.blade.php
@@ -13,36 +13,48 @@
</x-modal>
<div x-data="{ activeTab: window.location.hash ? window.location.hash.substring(1) : 'general' }" class="flex h-full pt-6">
<div class="flex flex-col gap-4 min-w-fit">
- <a :class="activeTab === 'general' && 'text-white'" @click.prevent="activeTab = 'general';
- window.location.hash = 'general'" href="#">General</a>
+ <a :class="activeTab === 'general' && 'text-white'"
+ @click.prevent="activeTab = 'general';
+ window.location.hash = 'general'"
+ href="#">General</a>
<a :class="activeTab === 'environment-variables' && 'text-white'"
@click.prevent="activeTab = 'environment-variables'; window.location.hash = 'environment-variables'"
href="#">Environment
Variables</a>
- <a :class="activeTab === 'server' && 'text-white'" @click.prevent="activeTab = 'server';
- window.location.hash = 'server'" href="#">Server
+ <a :class="activeTab === 'server' && 'text-white'"
+ @click.prevent="activeTab = 'server';
+ window.location.hash = 'server'"
+ href="#">Server
</a>
- <a :class="activeTab === 'storages' && 'text-white'" @click.prevent="activeTab = 'storages';
- window.location.hash = 'storages'" href="#">Storages
+ <a :class="activeTab === 'storages' && 'text-white'"
+ @click.prevent="activeTab = 'storages';
+ window.location.hash = 'storages'"
+ href="#">Storages
</a>
- <a :class="activeTab === 'resource-limits' && 'text-white'" @click.prevent="activeTab = 'resource-limits';
- window.location.hash = 'resource-limits'" href="#">Resource Limits
+ <a :class="activeTab === 'resource-limits' && 'text-white'"
+ @click.prevent="activeTab = 'resource-limits';
+ window.location.hash = 'resource-limits'"
+ href="#">Resource Limits
</a>
- <a :class="activeTab === 'danger' && 'text-white'" @click.prevent="activeTab = 'danger';
- window.location.hash = 'danger'" href="#">Danger Zone
+ <a :class="activeTab === 'danger' && 'text-white'"
+ @click.prevent="activeTab = 'danger';
+ window.location.hash = 'danger'"
+ href="#">Danger Zone
</a>
</div>
<div class="w-full pl-8">
<div x-cloak x-show="activeTab === 'general'" class="h-full">
@if ($database->type() === 'standalone-postgresql')
<livewire:project.database.postgresql.general :database="$database" />
- @endif
- @if ($database->type() === 'standalone-redis')
+ @elseif ($database->type() === 'standalone-redis')
<livewire:project.database.redis.general :database="$database" />
+ @elseif ($database->type() === 'standalone-mongodb')
+ <livewire:project.database.mongodb.general :database="$database" />
+ @elseif ($database->type() === 'standalone-mysql')
+ <livewire:project.database.mysql.general :database="$database" />
+ @elseif ($database->type() === 'standalone-mariadb')
+ <livewire:project.database.mariadb.general :database="$database" />
@endif
- @if ($database->type() === 'standalone-mongodb')
- <livewire:project.database.mongodb.general :database="$database" />
- @endif
</div>
<div x-cloak x-show="activeTab === 'environment-variables'">
<livewire:project.shared.environment-variable.all :resource="$database" />