fix(docker): do not hardcode sqlite; allow env to override config.ini
Build and Deploy / build-and-push (push) Successful in 53s
Build and Deploy / build-and-push (push) Successful in 53s
This commit is contained in:
@@ -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 == "" {
|
||||
|
||||
Reference in New Issue
Block a user