Skip to content

Commit 5ffd342

Browse files
committed
feat: load environment variables from .env file and update config loading logic
1 parent 5fa0734 commit 5ffd342

File tree

4 files changed

+27
-8
lines changed

4 files changed

+27
-8
lines changed

.github/dependabot.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "pip"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
timezone: "Asia/Shanghai"

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,4 +184,6 @@ data
184184
.dev
185185
poetry.lock
186186
apps/setting/models_provider/impl/*/icon/
187-
tmp/
187+
tmp/
188+
config.yml
189+
config.yml

apps/maxkb/const.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,21 @@
22
#
33
import os
44

5+
from dotenv import load_dotenv
6+
57
from .conf import ConfigManager
68

79
__all__ = ['BASE_DIR', 'PROJECT_DIR', 'VERSION', 'CONFIG']
810

911
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
1012
PROJECT_DIR = os.path.dirname(BASE_DIR)
1113
VERSION = '2.0.0'
12-
CONFIG = ConfigManager.load_user_config(root_path=os.path.abspath('/opt/maxkb/conf'))
14+
15+
# load environment variables from .env file
16+
load_dotenv()
17+
# print(os.getenv('MAXKB_CONFIG'))
18+
if os.getenv('MAXKB_CONFIG') is not None:
19+
CONFIG = ConfigManager.load_user_config(root_path=PROJECT_DIR)
20+
else:
21+
CONFIG = ConfigManager.load_user_config(root_path=os.path.abspath('/opt/maxkb/conf'))
22+

pyproject.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ readme = "README.md"
77

88
[tool.poetry.dependencies]
99
python = "^3.11"
10-
django = "^5.2"
11-
drf-spectacular = { extras = ["sidecar"], version = "^0.28.0" }
12-
django-redis = "^5.4.0"
13-
django-db-connection-pool = "^1.2.5"
14-
psycopg = {extras = ["binary"], version = "^3.2.6"}
15-
10+
django = "5.2"
11+
drf-spectacular = { extras = ["sidecar"], version = "0.28.0" }
12+
django-redis = "5.4.0"
13+
django-db-connection-pool = "1.2.5"
14+
psycopg = {extras = ["binary"], version = "3.2.6"}
15+
python-dotenv = "1.1.0"
1616

1717
[build-system]
1818
requires = ["poetry-core"]

0 commit comments

Comments
 (0)