@@ -22,74 +22,27 @@ class StartDatabaseProxy
22
22
23
23
public function handle (StandaloneRedis |StandalonePostgresql |StandaloneMongodb |StandaloneMysql |StandaloneMariadb |StandaloneKeydb |StandaloneDragonfly |StandaloneClickhouse |ServiceDatabase $ database )
24
24
{
25
- $ internalPort = null ;
26
- $ type = $ database ->getMorphClass ();
25
+ $ databaseType = $ database ->database_type ;
27
26
$ network = data_get ($ database , 'destination.network ' );
28
27
$ server = data_get ($ database , 'destination.server ' );
29
28
$ containerName = data_get ($ database , 'uuid ' );
30
29
$ proxyContainerName = "{$ database ->uuid }-proxy " ;
31
30
if ($ database ->getMorphClass () === \App \Models \ServiceDatabase::class) {
32
31
$ databaseType = $ database ->databaseType ();
33
- // $connectPredefined = data_get($database, 'service.connect_to_docker_network');
34
32
$ network = $ database ->service ->uuid ;
35
33
$ server = data_get ($ database , 'service.destination.server ' );
36
34
$ proxyContainerName = "{$ database ->service ->uuid }-proxy " ;
37
- switch ($ databaseType ) {
38
- case 'standalone-mariadb ' :
39
- $ type = \App \Models \StandaloneMariadb::class;
40
- $ containerName = "mariadb- {$ database ->service ->uuid }" ;
41
- break ;
42
- case 'standalone-mongodb ' :
43
- $ type = \App \Models \StandaloneMongodb::class;
44
- $ containerName = "mongodb- {$ database ->service ->uuid }" ;
45
- break ;
46
- case 'standalone-mysql ' :
47
- $ type = \App \Models \StandaloneMysql::class;
48
- $ containerName = "mysql- {$ database ->service ->uuid }" ;
49
- break ;
50
- case 'standalone-postgresql ' :
51
- $ type = \App \Models \StandalonePostgresql::class;
52
- $ containerName = "postgresql- {$ database ->service ->uuid }" ;
53
- break ;
54
- case 'standalone-redis ' :
55
- $ type = \App \Models \StandaloneRedis::class;
56
- $ containerName = "redis- {$ database ->service ->uuid }" ;
57
- break ;
58
- case 'standalone-keydb ' :
59
- $ type = \App \Models \StandaloneKeydb::class;
60
- $ containerName = "keydb- {$ database ->service ->uuid }" ;
61
- break ;
62
- case 'standalone-dragonfly ' :
63
- $ type = \App \Models \StandaloneDragonfly::class;
64
- $ containerName = "dragonfly- {$ database ->service ->uuid }" ;
65
- break ;
66
- case 'standalone-clickhouse ' :
67
- $ type = \App \Models \StandaloneClickhouse::class;
68
- $ containerName = "clickhouse- {$ database ->service ->uuid }" ;
69
- break ;
70
- case 'standalone-supabase/postgres ' :
71
- $ type = \App \Models \StandalonePostgresql::class;
72
- $ containerName = "supabase-db- {$ database ->service ->uuid }" ;
73
- break ;
74
- }
75
- }
76
- if ($ type === \App \Models \StandaloneRedis::class) {
77
- $ internalPort = 6379 ;
78
- } elseif ($ type === \App \Models \StandalonePostgresql::class) {
79
- $ internalPort = 5432 ;
80
- } elseif ($ type === \App \Models \StandaloneMongodb::class) {
81
- $ internalPort = 27017 ;
82
- } elseif ($ type === \App \Models \StandaloneMysql::class) {
83
- $ internalPort = 3306 ;
84
- } elseif ($ type === \App \Models \StandaloneMariadb::class) {
85
- $ internalPort = 3306 ;
86
- } elseif ($ type === \App \Models \StandaloneKeydb::class) {
87
- $ internalPort = 6379 ;
88
- } elseif ($ type === \App \Models \StandaloneDragonfly::class) {
89
- $ internalPort = 6379 ;
90
- } elseif ($ type === \App \Models \StandaloneClickhouse::class) {
91
- $ internalPort = 9000 ;
35
+ $ containerName = substr (str ($ database ->name )->slug ().'- ' .$ database ->service ->uuid , 0 , 32 );
92
36
}
37
+ $ internalPort = match ($ databaseType ) {
38
+ 'standalone-mariadb ' , 'standalone-mysql ' => 3306 ,
39
+ 'standalone-postgresql ' , 'standalone-supabase/postgres ' => 5432 ,
40
+ 'standalone-redis ' , 'standalone-keydb ' , 'standalone-dragonfly ' => 6379 ,
41
+ 'standalone-clickhouse ' => 9000 ,
42
+ 'standalone-mongodb ' => 27017 ,
43
+ default => throw new \Exception ("Unsupported database type: $ databaseType " ),
44
+ };
45
+
93
46
$ configuration_dir = database_proxy_dir ($ database ->uuid );
94
47
$ nginxconf = <<<EOF
95
48
user nginx;
0 commit comments