fix: database proxy for services

version++
tiny css modifications
This commit is contained in:
Andras Bacsai 2023-11-10 09:41:42 +01:00
parent 87ab4bd71e
commit db0e3cfcc4
8 changed files with 18 additions and 13 deletions

View File

@ -21,26 +21,33 @@ public function handle(StandaloneRedis|StandalonePostgresql|StandaloneMongodb|St
$type = $database->getMorphClass(); $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');
$proxyContainerName = "{$database->uuid}-proxy";
if ($database->getMorphClass() === 'App\Models\ServiceDatabase') { if ($database->getMorphClass() === 'App\Models\ServiceDatabase') {
$databaseType = $database->databaseType(); $databaseType = $database->databaseType();
$network = data_get($database, 'service.destination.network'); $network = data_get($database, 'service.destination.network');
$server = data_get($database, 'service.destination.server'); $server = data_get($database, 'service.destination.server');
ray($databaseType, $network); $proxyContainerName = "{$database->service->uuid}-proxy";
switch ($databaseType) { switch ($databaseType) {
case 'standalone-mariadb': case 'standalone-mariadb':
$type = 'App\Models\StandaloneMariadb'; $type = 'App\Models\StandaloneMariadb';
$containerName = "mariadb-{$database->service->uuid}";
break; break;
case 'standalone-mongodb': case 'standalone-mongodb':
$type = 'App\Models\StandaloneMongodb'; $type = 'App\Models\StandaloneMongodb';
$containerName = "mongodb-{$database->service->uuid}";
break; break;
case 'standalone-mysql': case 'standalone-mysql':
$type = 'App\Models\StandaloneMysql'; $type = 'App\Models\StandaloneMysql';
$containerName = "mysql-{$database->service->uuid}";
break; break;
case 'standalone-postgresql': case 'standalone-postgresql':
$type = 'App\Models\StandalonePostgresql'; $type = 'App\Models\StandalonePostgresql';
$containerName = "postgresql-{$database->service->uuid}";
break; break;
case 'standalone-redis': case 'standalone-redis':
$type = 'App\Models\StandaloneRedis'; $type = 'App\Models\StandaloneRedis';
$containerName = "redis-{$database->service->uuid}";
break; break;
} }
} }
@ -55,7 +62,6 @@ public function handle(StandaloneRedis|StandalonePostgresql|StandaloneMongodb|St
} else if ($type === 'App\Models\StandaloneMariadb') { } else if ($type === 'App\Models\StandaloneMariadb') {
$internalPort = 3306; $internalPort = 3306;
} }
$containerName = "{$database->uuid}-proxy";
$configuration_dir = database_proxy_dir($database->uuid); $configuration_dir = database_proxy_dir($database->uuid);
$nginxconf = <<<EOF $nginxconf = <<<EOF
user nginx; user nginx;
@ -69,7 +75,7 @@ public function handle(StandaloneRedis|StandalonePostgresql|StandaloneMongodb|St
stream { stream {
server { server {
listen $database->public_port; listen $database->public_port;
proxy_pass $database->uuid:$internalPort; proxy_pass $containerName:$internalPort;
} }
} }
EOF; EOF;
@ -81,13 +87,13 @@ public function handle(StandaloneRedis|StandalonePostgresql|StandaloneMongodb|St
$docker_compose = [ $docker_compose = [
'version' => '3.8', 'version' => '3.8',
'services' => [ 'services' => [
$containerName => [ $proxyContainerName => [
'build' => [ 'build' => [
'context' => $configuration_dir, 'context' => $configuration_dir,
'dockerfile' => 'Dockerfile', 'dockerfile' => 'Dockerfile',
], ],
'image' => "nginx:stable-alpine", 'image' => "nginx:stable-alpine",
'container_name' => $containerName, 'container_name' => $proxyContainerName,
'restart' => RESTART_MODE, 'restart' => RESTART_MODE,
'ports' => [ 'ports' => [
"$database->public_port:$database->public_port", "$database->public_port:$database->public_port",

View File

@ -20,7 +20,7 @@ public function __construct(
public bool $readonly = false, public bool $readonly = false,
public string|null $helper = null, public string|null $helper = null,
public bool $allowToPeak = true, public bool $allowToPeak = true,
public string $defaultClass = "input input-sm bg-coolgray-200 rounded text-white w-full disabled:bg-coolgray-200/50 disabled:border-none placeholder:text-coolgray-500 read-only:text-neutral-500 read-only:bg-coolgray-200/50" public string $defaultClass = "input input-sm bg-coolgray-100 rounded text-white w-full disabled:bg-coolgray-200/50 disabled:border-none placeholder:text-coolgray-500 read-only:text-neutral-500 read-only:bg-coolgray-200/50"
) { ) {
} }

View File

@ -7,7 +7,7 @@
// 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.119', 'release' => '4.0.0-beta.120',
// 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.119'; return '4.0.0-beta.120';

View File

@ -53,7 +53,7 @@ .icon:hover {
@apply text-white; @apply text-white;
} }
.box { .box {
@apply flex p-2 transition-colors cursor-pointer min-h-16 bg-coolgray-200 hover:bg-coollabs-100 hover:text-white hover:no-underline min-w-[24rem]; @apply flex p-2 transition-colors cursor-pointer min-h-16 bg-coolgray-100 hover:bg-coollabs-100 hover:text-white hover:no-underline min-w-[24rem];
} }
.box-without-bg { .box-without-bg {
@apply flex p-2 transition-colors min-h-16 hover:text-white hover:no-underline min-w-[24rem]; @apply flex p-2 transition-colors min-h-16 hover:text-white hover:no-underline min-w-[24rem];

View File

@ -25,7 +25,6 @@
@endif @endif
</head> </head>
@section('body') @section('body')
<body> <body>
@livewireScripts @livewireScripts
<dialog id="help" class="modal"> <dialog id="help" class="modal">

View File

@ -39,12 +39,12 @@ module.exports = {
themes: [ themes: [
{ {
coollabs: { coollabs: {
primary: "#323232", primary: "#202020",
"primary-focus": "#242424", "primary-focus": "#242424",
secondary: "#6B16ED", secondary: "#6B16ED",
accent: "#4338ca", accent: "#4338ca",
neutral: "#1B1D1D", neutral: "#1B1D1D",
"base-100": "#181818", "base-100": "#101010",
info: "#2563EB", info: "#2563EB",
success: "#16A34A", success: "#16A34A",
warning: "#FCD34D", warning: "#FCD34D",

View File

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