a493d1bcf6
- 将服务器配置文件合并到根目录的 .env.example 中,移除 server/.env.example - 为 PostgreSQL、Redis、MinIO/S3、Server、前端构建和Nginx 配置添加详细注释 - 新增 S3_REGION、S3_PUBLIC_URL 和 SENTRY_DSN 环境变量配置 - 修改配置加载逻辑以正确读取根目录下的 .env 文件 - 更新 docker-compose.yml 以包含新增的环境变量
42 lines
925 B
Python
42 lines
925 B
Python
from pathlib import Path
|
|
|
|
from pydantic_settings import BaseSettings
|
|
|
|
|
|
_config_path = Path(__file__).resolve()
|
|
_env_file = (
|
|
_config_path.parents[3] / ".env"
|
|
if _config_path.parents[2].name == "server"
|
|
else _config_path.parents[2] / ".env"
|
|
)
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
DATABASE_URL: str
|
|
DATABASE_URL_SYNC: str
|
|
REDIS_URL: str = "redis://localhost:6379/0"
|
|
SECRET_KEY: str
|
|
ACCESS_TOKEN_EXPIRE_MINUTES: int = 43200
|
|
REFRESH_TOKEN_EXPIRE_DAYS: int = 60
|
|
|
|
STORAGE_BACKEND: str = "local"
|
|
LOCAL_STORAGE_PATH: str = "./uploads"
|
|
S3_ENDPOINT: str = ""
|
|
S3_ACCESS_KEY: str = ""
|
|
S3_SECRET_KEY: str = ""
|
|
S3_BUCKET: str = "ciyuan-viewfinder"
|
|
S3_REGION: str = ""
|
|
S3_PUBLIC_URL: str = ""
|
|
|
|
TENCENT_MAP_KEY: str = ""
|
|
|
|
SENTRY_DSN: str = ""
|
|
LOG_JSON: bool = False
|
|
LOG_LEVEL: str = "INFO"
|
|
|
|
class Config:
|
|
env_file = _env_file
|
|
|
|
|
|
settings = Settings()
|