mirror of
https://github.com/RunLit/Bambu-Run.git
synced 2026-10-21 15:37:38 +01:00
feat(standalone): support Postgres via DB_ENGINE env var
Lets a standalone install point at an existing Postgres database (e.g. for testing against real data on a verification host) instead of always writing to local SQLite. Defaults to SQLite when DB_ENGINE is unset, so existing self-hosters see no behavior change.
This commit is contained in:
@@ -40,6 +40,9 @@ standalone = [
|
|||||||
"python-dotenv",
|
"python-dotenv",
|
||||||
"whitenoise",
|
"whitenoise",
|
||||||
]
|
]
|
||||||
|
postgres = [
|
||||||
|
"psycopg2-binary",
|
||||||
|
]
|
||||||
mcp = [
|
mcp = [
|
||||||
"mcp-gate @ git+https://github.com/RunLit/mcp-gate.git@v0.1.0",
|
"mcp-gate @ git+https://github.com/RunLit/mcp-gate.git@v0.1.0",
|
||||||
"uvicorn",
|
"uvicorn",
|
||||||
|
|||||||
@@ -63,10 +63,23 @@ TEMPLATES = [
|
|||||||
|
|
||||||
WSGI_APPLICATION = "standalone.wsgi.application"
|
WSGI_APPLICATION = "standalone.wsgi.application"
|
||||||
|
|
||||||
# Database — SQLite for zero-setup deployment
|
# Database — SQLite for zero-setup deployment, or Postgres when DB_ENGINE=postgresql
|
||||||
|
# is set (e.g. to point a standalone install at an existing database).
|
||||||
DATA_DIR = Path(os.environ.get("DATA_DIR", BASE_DIR / "data"))
|
DATA_DIR = Path(os.environ.get("DATA_DIR", BASE_DIR / "data"))
|
||||||
DATA_DIR.mkdir(parents=True, exist_ok=True)
|
DATA_DIR.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
if os.environ.get("DB_ENGINE") == "postgresql":
|
||||||
|
DATABASES = {
|
||||||
|
"default": {
|
||||||
|
"ENGINE": "django.db.backends.postgresql",
|
||||||
|
"NAME": os.environ["DB_NAME"],
|
||||||
|
"USER": os.environ["DB_USER"],
|
||||||
|
"PASSWORD": os.environ["DB_PASSWORD"],
|
||||||
|
"HOST": os.environ["DB_HOST"],
|
||||||
|
"PORT": os.environ.get("DB_PORT", "5432"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else:
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
"default": {
|
"default": {
|
||||||
"ENGINE": "django.db.backends.sqlite3",
|
"ENGINE": "django.db.backends.sqlite3",
|
||||||
|
|||||||
Reference in New Issue
Block a user