mirror of
https://github.com/maxdorninger/MediaManager.git
synced 2026-04-23 17:28:42 +02:00
- Move images directory from /data/images to /app/images to separate app data from user media - Implement config folder approach instead of direct file mounting - Add automatic config initialization with example config on first boot - Remove hardcoded media directory environment variables from Dockerfile - Update startup script to handle config folder setup and validation - Only create application-managed directories, not user media directories - Update docker-compose.yaml to use config folder volume mapping Fixes container startup failures when config.toml doesn't exist and improves separation between application data and user media directories.
81 lines
2.5 KiB
Python
81 lines
2.5 KiB
Python
import os
|
|
from pathlib import Path
|
|
from typing import Type, Tuple
|
|
|
|
from pydantic import AnyHttpUrl
|
|
from pydantic_settings import (
|
|
BaseSettings,
|
|
SettingsConfigDict,
|
|
PydanticBaseSettingsSource,
|
|
TomlConfigSettingsSource,
|
|
)
|
|
|
|
from media_manager.auth.config import AuthConfig
|
|
from media_manager.database.config import DbConfig
|
|
from media_manager.indexer.config import IndexerConfig
|
|
from media_manager.metadataProvider.config import MetadataProviderConfig
|
|
from media_manager.notification.config import NotificationConfig
|
|
from media_manager.torrent.config import TorrentConfig
|
|
|
|
config_path = os.getenv("CONFIG_FILE")
|
|
|
|
if config_path is None:
|
|
# Default to config folder approach
|
|
config_dir = os.getenv("CONFIG_DIR", "/app/config")
|
|
config_path = Path(config_dir) / "config.toml"
|
|
else:
|
|
config_path = Path(config_path)
|
|
|
|
|
|
class LibraryItem(BaseSettings):
|
|
name: str
|
|
path: str
|
|
|
|
|
|
class BasicConfig(BaseSettings):
|
|
image_directory: Path = Path(__file__).parent.parent / "images"
|
|
tv_directory: Path = Path(__file__).parent.parent / "data" / "tv"
|
|
movie_directory: Path = Path(__file__).parent.parent / "data" / "movies"
|
|
torrent_directory: Path = Path(__file__).parent.parent / "data" / "torrents"
|
|
|
|
frontend_url: AnyHttpUrl = "http://localhost:3000/web/"
|
|
cors_urls: list[str] = []
|
|
development: bool = False
|
|
|
|
tv_libraries: list[LibraryItem] = []
|
|
movie_libraries: list[LibraryItem] = []
|
|
|
|
|
|
class AllEncompassingConfig(BaseSettings):
|
|
model_config = SettingsConfigDict(
|
|
toml_file=config_path, case_sensitive=False, env_nested_delimiter="__"
|
|
)
|
|
"""
|
|
This class is used to load all configurations from the environment variables.
|
|
It combines the BasicConfig with any additional configurations needed.
|
|
"""
|
|
misc: BasicConfig
|
|
torrents: TorrentConfig
|
|
notifications: NotificationConfig
|
|
metadata: MetadataProviderConfig
|
|
indexers: IndexerConfig
|
|
database: DbConfig
|
|
auth: AuthConfig
|
|
|
|
@classmethod
|
|
def settings_customise_sources(
|
|
cls,
|
|
settings_cls: Type[BaseSettings],
|
|
init_settings: PydanticBaseSettingsSource,
|
|
env_settings: PydanticBaseSettingsSource,
|
|
dotenv_settings: PydanticBaseSettingsSource,
|
|
file_secret_settings: PydanticBaseSettingsSource,
|
|
) -> Tuple[PydanticBaseSettingsSource, ...]:
|
|
return (
|
|
init_settings,
|
|
env_settings,
|
|
dotenv_settings,
|
|
TomlConfigSettingsSource(settings_cls),
|
|
file_secret_settings,
|
|
)
|