fix wrong database container name + code simplification
This commit is contained in:
@@ -22,74 +22,28 @@ class StartDatabaseProxy
|
|||||||
|
|
||||||
public function handle(StandaloneRedis|StandalonePostgresql|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse|ServiceDatabase $database)
|
public function handle(StandaloneRedis|StandalonePostgresql|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse|ServiceDatabase $database)
|
||||||
{
|
{
|
||||||
$internalPort = null;
|
$databaseType = $database->database_type;
|
||||||
$type = $database->getMorphClass();
|
|
||||||
$network = data_get($database, 'destination.network');
|
$network = data_get($database, 'destination.network');
|
||||||
$server = data_get($database, 'destination.server');
|
$server = data_get($database, 'destination.server');
|
||||||
$containerName = data_get($database, 'uuid');
|
$containerName = data_get($database, 'uuid');
|
||||||
$proxyContainerName = "{$database->uuid}-proxy";
|
$proxyContainerName = "{$database->uuid}-proxy";
|
||||||
|
|
||||||
if ($database->getMorphClass() === \App\Models\ServiceDatabase::class) {
|
if ($database->getMorphClass() === \App\Models\ServiceDatabase::class) {
|
||||||
$databaseType = $database->databaseType();
|
$databaseType = $database->databaseType();
|
||||||
// $connectPredefined = data_get($database, 'service.connect_to_docker_network');
|
// $connectPredefined = data_get($database, 'service.connect_to_docker_network');
|
||||||
$network = $database->service->uuid;
|
$network = $database->service->uuid;
|
||||||
$server = data_get($database, 'service.destination.server');
|
$server = data_get($database, 'service.destination.server');
|
||||||
$proxyContainerName = "{$database->service->uuid}-proxy";
|
$proxyContainerName = "{$database->service->uuid}-proxy";
|
||||||
switch ($databaseType) {
|
$containerName = "{$database->name}-{$database->service->uuid}";
|
||||||
case 'standalone-mariadb':
|
|
||||||
$type = \App\Models\StandaloneMariadb::class;
|
|
||||||
$containerName = "mariadb-{$database->service->uuid}";
|
|
||||||
break;
|
|
||||||
case 'standalone-mongodb':
|
|
||||||
$type = \App\Models\StandaloneMongodb::class;
|
|
||||||
$containerName = "mongodb-{$database->service->uuid}";
|
|
||||||
break;
|
|
||||||
case 'standalone-mysql':
|
|
||||||
$type = \App\Models\StandaloneMysql::class;
|
|
||||||
$containerName = "mysql-{$database->service->uuid}";
|
|
||||||
break;
|
|
||||||
case 'standalone-postgresql':
|
|
||||||
$type = \App\Models\StandalonePostgresql::class;
|
|
||||||
$containerName = "postgresql-{$database->service->uuid}";
|
|
||||||
break;
|
|
||||||
case 'standalone-redis':
|
|
||||||
$type = \App\Models\StandaloneRedis::class;
|
|
||||||
$containerName = "redis-{$database->service->uuid}";
|
|
||||||
break;
|
|
||||||
case 'standalone-keydb':
|
|
||||||
$type = \App\Models\StandaloneKeydb::class;
|
|
||||||
$containerName = "keydb-{$database->service->uuid}";
|
|
||||||
break;
|
|
||||||
case 'standalone-dragonfly':
|
|
||||||
$type = \App\Models\StandaloneDragonfly::class;
|
|
||||||
$containerName = "dragonfly-{$database->service->uuid}";
|
|
||||||
break;
|
|
||||||
case 'standalone-clickhouse':
|
|
||||||
$type = \App\Models\StandaloneClickhouse::class;
|
|
||||||
$containerName = "clickhouse-{$database->service->uuid}";
|
|
||||||
break;
|
|
||||||
case 'standalone-supabase/postgres':
|
|
||||||
$type = \App\Models\StandalonePostgresql::class;
|
|
||||||
$containerName = "supabase-db-{$database->service->uuid}";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($type === \App\Models\StandaloneRedis::class) {
|
|
||||||
$internalPort = 6379;
|
|
||||||
} elseif ($type === \App\Models\StandalonePostgresql::class) {
|
|
||||||
$internalPort = 5432;
|
|
||||||
} elseif ($type === \App\Models\StandaloneMongodb::class) {
|
|
||||||
$internalPort = 27017;
|
|
||||||
} elseif ($type === \App\Models\StandaloneMysql::class) {
|
|
||||||
$internalPort = 3306;
|
|
||||||
} elseif ($type === \App\Models\StandaloneMariadb::class) {
|
|
||||||
$internalPort = 3306;
|
|
||||||
} elseif ($type === \App\Models\StandaloneKeydb::class) {
|
|
||||||
$internalPort = 6379;
|
|
||||||
} elseif ($type === \App\Models\StandaloneDragonfly::class) {
|
|
||||||
$internalPort = 6379;
|
|
||||||
} elseif ($type === \App\Models\StandaloneClickhouse::class) {
|
|
||||||
$internalPort = 9000;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$internalPort = match ($databaseType) {
|
||||||
|
'standalone-mariadb', 'standalone-mysql' => 3306,
|
||||||
|
'standalone-postgresql', 'standalone-supabase/postgres' => 5432,
|
||||||
|
'standalone-redis', 'standalone-keydb', 'standalone-dragonfly' => 6379,
|
||||||
|
'standalone-clickhouse' => 9000,
|
||||||
|
};
|
||||||
|
|
||||||
$configuration_dir = database_proxy_dir($database->uuid);
|
$configuration_dir = database_proxy_dir($database->uuid);
|
||||||
$nginxconf = <<<EOF
|
$nginxconf = <<<EOF
|
||||||
user nginx;
|
user nginx;
|
||||||
|
|||||||
Reference in New Issue
Block a user