The media/data location is no longer configurable — DATA_DIR is a fixed constant (/var/thoughtsync) and THOUGHTSYNC_MEDIA_ROOT is removed, so a mutable path can't drift from where the volume is mounted. media_root() = DATA_DIR/media. Both compose files drop THOUGHTSYNC_DATA_DIR and mount the data volume at /var/thoughtsync (was the contradictory /data). conftest drops the stale MEDIA_ROOT monkeypatch (create_app never reads DATA_DIR). Net env surface: THOUGHTSYNC_DATABASE_URL (required) + THOUGHTSYNC_SECRET_KEY (optional break-glass). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FRgehjoz7Yv8LkUfADxACm
40 lines
1.4 KiB
Python
40 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
import os
|
|
from pathlib import Path
|
|
|
|
|
|
class Config:
|
|
"""Bootstrap configuration.
|
|
|
|
For a basic install, ``THOUGHTSYNC_DATABASE_URL`` is the ONLY required env var —
|
|
every other tunable lives in the DB-backed Settings UI (rule 25). The only other
|
|
env var is an optional "break-glass" item:
|
|
|
|
- ``THOUGHTSYNC_SECRET_KEY`` — optional override for the cookie-signing secret.
|
|
If unset, a key is generated and persisted in the DB (see
|
|
``thoughtsync.settings.load_or_create_secret_key``), so sessions survive
|
|
restarts with no volume required.
|
|
|
|
Uploaded media lives under ``DATA_DIR`` — a fixed, authoritative path
|
|
(``/var/thoughtsync``), intentionally NOT configurable (a mutable data path only
|
|
invites breakage). Mount a volume there if you want uploads to persist across
|
|
container recreation; a text-notes-only install never writes to it.
|
|
"""
|
|
|
|
DATA_DIR = "/var/thoughtsync"
|
|
|
|
DATABASE_URL = os.environ.get(
|
|
"THOUGHTSYNC_DATABASE_URL",
|
|
"postgresql+asyncpg://thoughtsync:thoughtsync@localhost:5432/thoughtsync",
|
|
)
|
|
|
|
@classmethod
|
|
def media_root(cls) -> Path:
|
|
return Path(cls.DATA_DIR) / "media"
|
|
|
|
@classmethod
|
|
def secret_key_env(cls) -> str | None:
|
|
"""Optional break-glass override for the cookie-signing secret."""
|
|
return os.environ.get("THOUGHTSYNC_SECRET_KEY") or None
|