From a245d16e0556191805072a6cbea318cc916a1541 Mon Sep 17 00:00:00 2001 From: Vahor Date: Tue, 27 Aug 2024 18:57:02 +0200 Subject: [PATCH] =?UTF-8?q?add=20env=20vars=20for=20db=20services=20?= =?UTF-8?q?=F0=9F=98=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Actions/Database/StartClickhouse.php | 15 +++++++++++++++ app/Actions/Database/StartKeydb.php | 15 +++++++++++++++ app/Actions/Database/StartMariadb.php | 15 +++++++++++++++ app/Actions/Database/StartMongodb.php | 15 +++++++++++++++ app/Actions/Database/StartMysql.php | 15 +++++++++++++++ app/Actions/Database/StartPostgresql.php | 15 +++++++++++++++ app/Actions/Database/StartRedis.php | 15 +++++++++++++++ 7 files changed, 105 insertions(+) diff --git a/app/Actions/Database/StartClickhouse.php b/app/Actions/Database/StartClickhouse.php index 4943d926c..508418557 100644 --- a/app/Actions/Database/StartClickhouse.php +++ b/app/Actions/Database/StartClickhouse.php @@ -168,6 +168,21 @@ private function generate_environment_variables() $environment_variables->push("CLICKHOUSE_ADMIN_PASSWORD={$this->database->clickhouse_admin_password}"); } + // TODO: move this in a shared function + if ($environment_variables->where('key', 'COOLIFY_APP_NAME')->isEmpty()) { + $environment_variables->push("COOLIFY_APP_NAME={$this->database->name}"); + } + if ($environment_variables->where('key', 'COOLIFY_SERVER_IP')->isEmpty()) { + $environment_variables->push("COOLIFY_SERVER_IP={$this->database->destination->server->ip}"); + } + if ($environment_variables->where('key', 'COOLIFY_ENVIRONMENT_NAME')->isEmpty()) { + $environment_variables->push("COOLIFY_ENVIRONMENT_NAME={$this->database->environment->name}"); + } + if ($environment_variables->where('key', 'COOLIFY_PROJECT_NAME')->isEmpty()) { + $environment_variables->push("COOLIFY_PROJECT_NAME={$this->database->project()->name}"); + } + + return $environment_variables->all(); } } diff --git a/app/Actions/Database/StartKeydb.php b/app/Actions/Database/StartKeydb.php index b13bc7552..4493bf114 100644 --- a/app/Actions/Database/StartKeydb.php +++ b/app/Actions/Database/StartKeydb.php @@ -171,6 +171,21 @@ private function generate_environment_variables() $environment_variables->push("REDIS_PASSWORD={$this->database->keydb_password}"); } + // TODO: move this in a shared function + if ($environment_variables->where('key', 'COOLIFY_APP_NAME')->isEmpty()) { + $environment_variables->push("COOLIFY_APP_NAME={$this->database->name}"); + } + if ($environment_variables->where('key', 'COOLIFY_SERVER_IP')->isEmpty()) { + $environment_variables->push("COOLIFY_SERVER_IP={$this->database->destination->server->ip}"); + } + if ($environment_variables->where('key', 'COOLIFY_ENVIRONMENT_NAME')->isEmpty()) { + $environment_variables->push("COOLIFY_ENVIRONMENT_NAME={$this->database->environment->name}"); + } + if ($environment_variables->where('key', 'COOLIFY_PROJECT_NAME')->isEmpty()) { + $environment_variables->push("COOLIFY_PROJECT_NAME={$this->database->project()->name}"); + } + + return $environment_variables->all(); } diff --git a/app/Actions/Database/StartMariadb.php b/app/Actions/Database/StartMariadb.php index b2b5f8f00..42b8ad272 100644 --- a/app/Actions/Database/StartMariadb.php +++ b/app/Actions/Database/StartMariadb.php @@ -177,6 +177,21 @@ private function generate_environment_variables() $environment_variables->push("MARIADB_PASSWORD={$this->database->mariadb_password}"); } + // TODO: move this in a shared function + if ($environment_variables->where('key', 'COOLIFY_APP_NAME')->isEmpty()) { + $environment_variables->push("COOLIFY_APP_NAME={$this->database->name}"); + } + if ($environment_variables->where('key', 'COOLIFY_SERVER_IP')->isEmpty()) { + $environment_variables->push("COOLIFY_SERVER_IP={$this->database->destination->server->ip}"); + } + if ($environment_variables->where('key', 'COOLIFY_ENVIRONMENT_NAME')->isEmpty()) { + $environment_variables->push("COOLIFY_ENVIRONMENT_NAME={$this->database->environment->name}"); + } + if ($environment_variables->where('key', 'COOLIFY_PROJECT_NAME')->isEmpty()) { + $environment_variables->push("COOLIFY_PROJECT_NAME={$this->database->project()->name}"); + } + + return $environment_variables->all(); } diff --git a/app/Actions/Database/StartMongodb.php b/app/Actions/Database/StartMongodb.php index 3ec8f0aa5..954b8381a 100644 --- a/app/Actions/Database/StartMongodb.php +++ b/app/Actions/Database/StartMongodb.php @@ -190,6 +190,21 @@ private function generate_environment_variables() $environment_variables->push("MONGO_INITDB_DATABASE={$this->database->mongo_initdb_database}"); } + // TODO: move this in a shared function + if ($environment_variables->where('key', 'COOLIFY_APP_NAME')->isEmpty()) { + $environment_variables->push("COOLIFY_APP_NAME={$this->database->name}"); + } + if ($environment_variables->where('key', 'COOLIFY_SERVER_IP')->isEmpty()) { + $environment_variables->push("COOLIFY_SERVER_IP={$this->database->destination->server->ip}"); + } + if ($environment_variables->where('key', 'COOLIFY_ENVIRONMENT_NAME')->isEmpty()) { + $environment_variables->push("COOLIFY_ENVIRONMENT_NAME={$this->database->environment->name}"); + } + if ($environment_variables->where('key', 'COOLIFY_PROJECT_NAME')->isEmpty()) { + $environment_variables->push("COOLIFY_PROJECT_NAME={$this->database->project()->name}"); + } + + return $environment_variables->all(); } diff --git a/app/Actions/Database/StartMysql.php b/app/Actions/Database/StartMysql.php index 7eba18b6a..9749eceac 100644 --- a/app/Actions/Database/StartMysql.php +++ b/app/Actions/Database/StartMysql.php @@ -177,6 +177,21 @@ private function generate_environment_variables() $environment_variables->push("MYSQL_PASSWORD={$this->database->mysql_password}"); } + // TODO: move this in a shared function + if ($environment_variables->where('key', 'COOLIFY_APP_NAME')->isEmpty()) { + $environment_variables->push("COOLIFY_APP_NAME={$this->database->name}"); + } + if ($environment_variables->where('key', 'COOLIFY_SERVER_IP')->isEmpty()) { + $environment_variables->push("COOLIFY_SERVER_IP={$this->database->destination->server->ip}"); + } + if ($environment_variables->where('key', 'COOLIFY_ENVIRONMENT_NAME')->isEmpty()) { + $environment_variables->push("COOLIFY_ENVIRONMENT_NAME={$this->database->environment->name}"); + } + if ($environment_variables->where('key', 'COOLIFY_PROJECT_NAME')->isEmpty()) { + $environment_variables->push("COOLIFY_PROJECT_NAME={$this->database->project()->name}"); + } + + return $environment_variables->all(); } diff --git a/app/Actions/Database/StartPostgresql.php b/app/Actions/Database/StartPostgresql.php index 184cc6897..14a5a2930 100644 --- a/app/Actions/Database/StartPostgresql.php +++ b/app/Actions/Database/StartPostgresql.php @@ -199,6 +199,21 @@ private function generate_environment_variables() $environment_variables->push("POSTGRES_DB={$this->database->postgres_db}"); } + // TODO: move this in a shared function + if ($environment_variables->where('key', 'COOLIFY_APP_NAME')->isEmpty()) { + $environment_variables->push("COOLIFY_APP_NAME={$this->database->name}"); + } + if ($environment_variables->where('key', 'COOLIFY_SERVER_IP')->isEmpty()) { + $environment_variables->push("COOLIFY_SERVER_IP={$this->database->destination->server->ip}"); + } + if ($environment_variables->where('key', 'COOLIFY_ENVIRONMENT_NAME')->isEmpty()) { + $environment_variables->push("COOLIFY_ENVIRONMENT_NAME={$this->database->environment->name}"); + } + if ($environment_variables->where('key', 'COOLIFY_PROJECT_NAME')->isEmpty()) { + $environment_variables->push("COOLIFY_PROJECT_NAME={$this->database->project()->name}"); + } + + return $environment_variables->all(); } diff --git a/app/Actions/Database/StartRedis.php b/app/Actions/Database/StartRedis.php index ee78501ea..b7b32d304 100644 --- a/app/Actions/Database/StartRedis.php +++ b/app/Actions/Database/StartRedis.php @@ -176,6 +176,21 @@ private function generate_environment_variables() $environment_variables->push("REDIS_PASSWORD={$this->database->redis_password}"); } + // TODO: move this in a shared function + if ($environment_variables->where('key', 'COOLIFY_APP_NAME')->isEmpty()) { + $environment_variables->push("COOLIFY_APP_NAME={$this->database->name}"); + } + if ($environment_variables->where('key', 'COOLIFY_SERVER_IP')->isEmpty()) { + $environment_variables->push("COOLIFY_SERVER_IP={$this->database->destination->server->ip}"); + } + if ($environment_variables->where('key', 'COOLIFY_ENVIRONMENT_NAME')->isEmpty()) { + $environment_variables->push("COOLIFY_ENVIRONMENT_NAME={$this->database->environment->name}"); + } + if ($environment_variables->where('key', 'COOLIFY_PROJECT_NAME')->isEmpty()) { + $environment_variables->push("COOLIFY_PROJECT_NAME={$this->database->project()->name}"); + } + + return $environment_variables->all(); }