fix(docker): do not hardcode sqlite; allow env to override config.ini
Build and Deploy / build-and-push (push) Successful in 53s

This commit is contained in:
2026-07-26 15:14:19 +08:00
parent c06a8a7f7d
commit afe7833539
2 changed files with 7 additions and 6 deletions
+4 -5
View File
@@ -116,9 +116,8 @@ func LoadConfig(path string) (*AppConfig, error) {
},
}
// 检查配置文件是否存在
// 检查配置文件是否存在:文件先加载,再用环境变量覆盖(compose 注入优先)
if _, err := os.Stat(path); err == nil {
// 配置文件存在,从文件加载
logger.Infof("[Config] 从文件加载配置: %s", path)
cfg, err := ini.Load(path)
if err != nil {
@@ -128,10 +127,10 @@ func LoadConfig(path string) (*AppConfig, error) {
return nil, err
}
} else {
// 配置文件不存在,使用环境变量
logger.Info("[Config] 配置文件不存在,从环境变量加载")
applyEnvOverrides()
logger.Info("[Config] 配置文件不存在,使用默认值 + 环境变量")
}
// 环境变量始终可覆盖(便于 Docker Compose 注入 MySQL/Redis 等)
applyEnvOverrides()
// 设置默认数据库路径
if Config.Database.Path == "" {