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",
|
||||
"whitenoise",
|
||||
]
|
||||
postgres = [
|
||||
"psycopg2-binary",
|
||||
]
|
||||
mcp = [
|
||||
"mcp-gate @ git+https://github.com/RunLit/mcp-gate.git@v0.1.0",
|
||||
"uvicorn",
|
||||
|
||||
@@ -63,16 +63,29 @@ TEMPLATES = [
|
||||
|
||||
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.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
DATABASES = {
|
||||
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 = {
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.sqlite3",
|
||||
"NAME": DATA_DIR / "db.sqlite3",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Password validation
|
||||
AUTH_PASSWORD_VALIDATORS = [
|
||||
|
||||
Reference in New Issue
Block a user