feat(server): 统一配置文件管理并增强环境变量配置

- 将服务器配置文件合并到根目录的 .env.example 中,移除 server/.env.example
- 为 PostgreSQL、Redis、MinIO/S3、Server、前端构建和Nginx 配置添加详细注释
- 新增 S3_REGION、S3_PUBLIC_URL 和 SENTRY_DSN 环境变量配置
- 修改配置加载逻辑以正确读取根目录下的 .env 文件
- 更新 docker-compose.yml 以包含新增的环境变量
This commit is contained in:
2026-05-09 18:33:33 +08:00
parent 0afd5bbb2c
commit a493d1bcf6
4 changed files with 73 additions and 29 deletions
-22
View File
@@ -1,22 +0,0 @@
DATABASE_URL=postgresql+asyncpg://postgres:postgres@localhost:5432/ciyuan_viewfinder
DATABASE_URL_SYNC=postgresql://postgres:postgres@localhost:5432/ciyuan_viewfinder
REDIS_URL=redis://localhost:6379/0
SECRET_KEY=change-me-to-a-random-secret-key
ACCESS_TOKEN_EXPIRE_MINUTES=30
REFRESH_TOKEN_EXPIRE_DAYS=7
# Storage: "local" or "s3" (s3 compatible with MinIO/OSS/COS)
STORAGE_BACKEND=local
LOCAL_STORAGE_PATH=./uploads
S3_ENDPOINT=http://localhost:9000
S3_ACCESS_KEY=minioadmin
S3_SECRET_KEY=minioadmin
S3_BUCKET=ciyuan-viewfinder
S3_REGION=
S3_PUBLIC_URL=
# Tencent Maps API Key (apply at https://lbs.qq.com/)
TENCENT_MAP_KEY=
SENTRY_DSN=
+11 -1
View File
@@ -1,6 +1,16 @@
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
@@ -25,7 +35,7 @@ class Settings(BaseSettings):
LOG_LEVEL: str = "INFO"
class Config:
env_file = ".env"
env_file = _env_file
settings = Settings()