From d206ebc112aa684d0cbe1c764d52ef581a6f7410 Mon Sep 17 00:00:00 2001 From: Alejandro Giacometti Date: Fri, 16 Jul 2021 13:18:11 +0100 Subject: [PATCH] Update NcConfigFactory.ts & README.md Extract NC_DB from DATABASE_URL_FILE when provided Add DATABASE_URL_FILE reference in README.md Signed-off-by: Alejandro Giacometti --- README.md | 1 + packages/nocodb/src/lib/utils/NcConfigFactory.ts | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 32f971b069..f7c364bfe0 100644 --- a/README.md +++ b/README.md @@ -168,6 +168,7 @@ docker-compose up |-------------------------|-----------|----------------------------------------------------------------------------------|--------------------------------------------| | NC_DB | Yes | See our database URLs | A local SQLite will be created in root folder | | DATABASE_URL | No | JDBC URL Format. Can be used instead of NC_DB. Used in 1-Click Heroku deployment| | +| DATABASE_URL_FILE | No | path to file containing JDBC URL Format. Can be used instead of NC_DB. Used in 1-Click Heroku deployment| | | NC_PUBLIC_URL | Yes | Used for sending Email invitations | Best guess from http request params | | NC_AUTH_JWT_SECRET | Yes | JWT secret used for auth and storing other secrets | A Random secret will be generated | | NC_SENTRY_DSN | No | For Sentry monitoring | | diff --git a/packages/nocodb/src/lib/utils/NcConfigFactory.ts b/packages/nocodb/src/lib/utils/NcConfigFactory.ts index 98582a9b29..317ba064f8 100644 --- a/packages/nocodb/src/lib/utils/NcConfigFactory.ts +++ b/packages/nocodb/src/lib/utils/NcConfigFactory.ts @@ -1,4 +1,5 @@ import {SqlClientFactory} from 'nc-help'; +import fs from 'fs'; import parseDbUrl from "parse-database-url"; import {AuthConfig, DbConfig, MailerConfig, NcConfig} from "../../interface/config"; @@ -565,7 +566,10 @@ export default class NcConfigFactory implements NcConfig { public static jdbcToXcUrl() { - if (process.env.NC_DATABASE_URL || process.env.DATABASE_URL) { + if (process.env.NC_DATABASE_URL_FILE || process.env.DATABASE_URL_FILE) { + const database_url = fs.readFileSync(process.env.NC_DATABASE_URL_FILE || process.env.DATABASE_URL_FILE, 'utf-8'); + process.env.NC_DB = this.extractXcUrlFromJdbc(database_url); + } else if (process.env.NC_DATABASE_URL || process.env.DATABASE_URL) { process.env.NC_DB = this.extractXcUrlFromJdbc(process.env.NC_DATABASE_URL || process.env.DATABASE_URL); } }