From 669e1453ae556dfdbfb3b7b33dc3d8699acc9d9f Mon Sep 17 00:00:00 2001 From: Martin Bhuong Date: Sat, 13 Jul 2024 08:30:51 +0200 Subject: [PATCH 1/6] redefine system and tenant db paramters --- .../configure-module/10configure_environment_vars | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/imageroot/actions/configure-module/10configure_environment_vars b/imageroot/actions/configure-module/10configure_environment_vars index b59d89e..dbb5f5d 100755 --- a/imageroot/actions/configure-module/10configure_environment_vars +++ b/imageroot/actions/configure-module/10configure_environment_vars @@ -80,8 +80,16 @@ database_config = { "DB_USER": MARIADB_USER, "DB_PASSWORD": f'{MARIADB_PASSWORD}', "DB_CHARSET": "utf8mb4", + "SYSTEM_DB_HOST": f'{MARIADB_DATABASE}', + "SYSTEM_DB_USER": MARIADB_USER, + "SYSTEM_DB_PASSWORD": f'{MARIADB_PASSWORD}', "SYSTEM_DB_NAME": f'{MARIADB_DATABASE}', - "TENANT_DB_NAME_PERFIX": "bigcapital", + "SYSTEM_DB_CHARSET": "utf8mb4", + "TENANT_DB_NAME_PERFIX": "tn", + "TENANT_DB_HOST"= "mysql", + "TENANT_DB_USER"= MARIADB_USER + "TENANT_DB_PASSWORD"= f'{MARIADB_PASSWORD} + "TENANT_DB_CHARSET"= "utf8mb4", "MONGODB_DATABASE_URL": "mongodb://localhost:27017/bigcapital", } jwt_secret = secrets.token_hex(32) From 7b90e0c6fefc4c03e87d12eb33f2309844e281eb Mon Sep 17 00:00:00 2001 From: Martin Bhuong Date: Sat, 13 Jul 2024 08:41:06 +0200 Subject: [PATCH 2/6] fix SyntaxError: unterminated string literal --- .../actions/configure-module/10configure_environment_vars | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/imageroot/actions/configure-module/10configure_environment_vars b/imageroot/actions/configure-module/10configure_environment_vars index dbb5f5d..ff25cd7 100755 --- a/imageroot/actions/configure-module/10configure_environment_vars +++ b/imageroot/actions/configure-module/10configure_environment_vars @@ -87,8 +87,8 @@ database_config = { "SYSTEM_DB_CHARSET": "utf8mb4", "TENANT_DB_NAME_PERFIX": "tn", "TENANT_DB_HOST"= "mysql", - "TENANT_DB_USER"= MARIADB_USER - "TENANT_DB_PASSWORD"= f'{MARIADB_PASSWORD} + "TENANT_DB_USER"= MARIADB_USER, + "TENANT_DB_PASSWORD"= f'{MARIADB_PASSWORD}', "TENANT_DB_CHARSET"= "utf8mb4", "MONGODB_DATABASE_URL": "mongodb://localhost:27017/bigcapital", } From efc6ae0c18b03d1b893c5fbabeda8cef7d112889 Mon Sep 17 00:00:00 2001 From: Martin Bhuong Date: Sat, 13 Jul 2024 08:48:50 +0200 Subject: [PATCH 3/6] fix SyntaxError: ':' expected after dictionary key --- .../actions/configure-module/10configure_environment_vars | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/imageroot/actions/configure-module/10configure_environment_vars b/imageroot/actions/configure-module/10configure_environment_vars index ff25cd7..cd9f885 100755 --- a/imageroot/actions/configure-module/10configure_environment_vars +++ b/imageroot/actions/configure-module/10configure_environment_vars @@ -86,10 +86,10 @@ database_config = { "SYSTEM_DB_NAME": f'{MARIADB_DATABASE}', "SYSTEM_DB_CHARSET": "utf8mb4", "TENANT_DB_NAME_PERFIX": "tn", - "TENANT_DB_HOST"= "mysql", - "TENANT_DB_USER"= MARIADB_USER, - "TENANT_DB_PASSWORD"= f'{MARIADB_PASSWORD}', - "TENANT_DB_CHARSET"= "utf8mb4", + "TENANT_DB_HOST": "mysql", + "TENANT_DB_USER": MARIADB_USER, + "TENANT_DB_PASSWORD": f'{MARIADB_PASSWORD}', + "TENANT_DB_CHARSET": "utf8mb4", "MONGODB_DATABASE_URL": "mongodb://localhost:27017/bigcapital", } jwt_secret = secrets.token_hex(32) From 6d3a7b303166aefab6cd3cbaaa286029e27cd6ca Mon Sep 17 00:00:00 2001 From: Martin Bhuong Date: Sat, 13 Jul 2024 08:59:26 +0200 Subject: [PATCH 4/6] Define Signup PArameter env var --- .../actions/configure-module/10configure_environment_vars | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/imageroot/actions/configure-module/10configure_environment_vars b/imageroot/actions/configure-module/10configure_environment_vars index cd9f885..0777b6d 100755 --- a/imageroot/actions/configure-module/10configure_environment_vars +++ b/imageroot/actions/configure-module/10configure_environment_vars @@ -108,6 +108,10 @@ app_config = { "GOTENBERG_DOCS_URL": "http//server:3000/public/", "ADMIN_EMAIL":"accounting@bigcapital.com", "ADMIN_PASSWORD":"BigCapital", + "SIGNUP_DISABLED":"false", + "SIGNUP_ALLOWED_DOMAINS":"", + "SIGNUP_ALLOWED_EMAILS":"", + "SIGNUP_EMAIL_CONFIRMATION":"true", **database_config, **email_config, } From 48d0a6199919bb2958811a190f293accded6f701 Mon Sep 17 00:00:00 2001 From: Martin Bhuong Date: Sat, 13 Jul 2024 09:51:42 +0200 Subject: [PATCH 5/6] define db under create module --- .../actions/create-module/10configure_environment_vars | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/imageroot/actions/create-module/10configure_environment_vars b/imageroot/actions/create-module/10configure_environment_vars index 9f79d80..6f99f88 100755 --- a/imageroot/actions/create-module/10configure_environment_vars +++ b/imageroot/actions/create-module/10configure_environment_vars @@ -42,8 +42,16 @@ database_config = { "DB_USER": MARIADB_USER, "DB_PASSWORD": f'{MARIADB_PASSWORD}', "DB_CHARSET": "utf8mb4", + "SYSTEM_DB_HOST": f'{MARIADB_DATABASE}', + "SYSTEM_DB_USER": MARIADB_USER, + "SYSTEM_DB_PASSWORD": f'{MARIADB_PASSWORD}', "SYSTEM_DB_NAME": f'{MARIADB_DATABASE}', - "TENANT_DB_NAME_PERFIX": "bigcapital", + "SYSTEM_DB_CHARSET": "utf8mb4", + "TENANT_DB_NAME_PERFIX": "tn", + "TENANT_DB_HOST": "mariadb-app", + "TENANT_DB_USER": MARIADB_USER, + "TENANT_DB_PASSWORD": f'{MARIADB_PASSWORD}', + "TENANT_DB_CHARSET": "utf8mb4", "MONGODB_DATABASE_URL": "mongodb://mongo-app:27017/bigcapital", } From 45fda2ab02b3a8803dcc1bec8cf74653ae30ad6f Mon Sep 17 00:00:00 2001 From: Martin Bhuong Date: Sat, 13 Jul 2024 10:22:51 +0200 Subject: [PATCH 6/6] improve db configs --- .../10configure_environment_vars | 59 ++----------------- .../10configure_environment_vars | 2 +- 2 files changed, 5 insertions(+), 56 deletions(-) diff --git a/imageroot/actions/configure-module/10configure_environment_vars b/imageroot/actions/configure-module/10configure_environment_vars index 0777b6d..12e1090 100755 --- a/imageroot/actions/configure-module/10configure_environment_vars +++ b/imageroot/actions/configure-module/10configure_environment_vars @@ -18,24 +18,7 @@ data = json.load(sys.stdin) # we read a json stdin {"vars1":true, "var2":"foo", "vars3": 3} and we writ it to .config/state/environment # Upper case to set environment variable and minor case to read from stdin -# Configure database configurations -MARIADB_DATABASE = data.get("MARIADB_DATABASE","bigcapitalhq") -MARIADB_USER = data.get("MARIADB_USER","bigcapital") -MARIADB_ROOT_PASSWORD = data.get("MARIADB_ROOT_PASSWORD","Bigcapital,1234") -MARIADB_AUTO_UPGRADE = data.get("MARIADB_AUTO_UPGRADE","1") -MARIADB_PASSWORD = data.get("MARIADB_PASSWORD","Bigcapital,1234") - -db_config = { - "MARIADB_DATABASE": MARIADB_DATABASE, - "MARIADB_USER": MARIADB_USER, - "MARIADB_ROOT_PASSWORD": f'{MARIADB_ROOT_PASSWORD}', - "MARIADB_AUTO_UPGRADE": MARIADB_AUTO_UPGRADE, - "MARIADB_PASSWORD": f'{MARIADB_PASSWORD}', -} -agent.write_envfile('database.env', db_config) - -# Configure the application configurations # Configure email configurations rdb = agent.redis_connect(use_replica=True) smtp_settings = agent.get_smarthost_settings(rdb) @@ -58,45 +41,12 @@ email_config = { "MAIL_FROM_ADDRESS": data.get("MAIL_FROM_ADDRESS", f"{smtp_settings['username']}"), } agent.write_envfile('email.env', email_config) -# # Database -# - DB_HOST=mysql -# - DB_USER=${DB_USER} -# - DB_PASSWORD=${DB_PASSWORD} -# - DB_CHARSET=${DB_CHARSET} -# # System database -# - SYSTEM_DB_NAME=${SYSTEM_DB_NAME} -# -# # Tenants databases -# - TENANT_DB_NAME_PERFIX=${TENANT_DB_NAME_PERFIX} -# -# # Authentication -# - JWT_SECRET=${JWT_SECRET} -# -# # MongoDB -# - MONGODB_DATABASE_URL=mongodb://mongo/bigcapital -# -database_config = { - "DB_HOST": "mysql", - "DB_USER": MARIADB_USER, - "DB_PASSWORD": f'{MARIADB_PASSWORD}', - "DB_CHARSET": "utf8mb4", - "SYSTEM_DB_HOST": f'{MARIADB_DATABASE}', - "SYSTEM_DB_USER": MARIADB_USER, - "SYSTEM_DB_PASSWORD": f'{MARIADB_PASSWORD}', - "SYSTEM_DB_NAME": f'{MARIADB_DATABASE}', - "SYSTEM_DB_CHARSET": "utf8mb4", - "TENANT_DB_NAME_PERFIX": "tn", - "TENANT_DB_HOST": "mysql", - "TENANT_DB_USER": MARIADB_USER, - "TENANT_DB_PASSWORD": f'{MARIADB_PASSWORD}', - "TENANT_DB_CHARSET": "utf8mb4", - "MONGODB_DATABASE_URL": "mongodb://localhost:27017/bigcapital", -} -jwt_secret = secrets.token_hex(32) + + + HOST = data.get("host", "") app_config = { - "JWT_SECRET": jwt_secret, - "BASE_URL": HOST, + "BASE_URL": "https://" +HOST, "NEW_RELIC_APP_NAME":"BIGCAPITALHQ", "NEW_RELIC_DISTRIBUTED_TRACING_ENABLED": "false", "NEW_RELIC_LOG": "stdout", @@ -112,7 +62,6 @@ app_config = { "SIGNUP_ALLOWED_DOMAINS":"", "SIGNUP_ALLOWED_EMAILS":"", "SIGNUP_EMAIL_CONFIRMATION":"true", - **database_config, **email_config, } agent.write_envfile('app.env', app_config) diff --git a/imageroot/actions/create-module/10configure_environment_vars b/imageroot/actions/create-module/10configure_environment_vars index 6f99f88..82e7ca5 100755 --- a/imageroot/actions/create-module/10configure_environment_vars +++ b/imageroot/actions/create-module/10configure_environment_vars @@ -42,7 +42,7 @@ database_config = { "DB_USER": MARIADB_USER, "DB_PASSWORD": f'{MARIADB_PASSWORD}', "DB_CHARSET": "utf8mb4", - "SYSTEM_DB_HOST": f'{MARIADB_DATABASE}', + "SYSTEM_DB_HOST": "mariadb-app", "SYSTEM_DB_USER": MARIADB_USER, "SYSTEM_DB_PASSWORD": f'{MARIADB_PASSWORD}', "SYSTEM_DB_NAME": f'{MARIADB_DATABASE}',