mirror of
https://github.com/ZhuLinsen/daily_stock_analysis
synced 2026-09-20 10:53:33 +08:00
fix(docker): grant efinance cache dir to non-root user (#1749)
efinance writes its search cache (search-cache.json) into its own package directory (site-packages/efinance/data), which is root-owned in the image. Since the container runs as the non-root dsa user (uid 1000), every A-share fetch failed with PermissionError, forcing EfinanceFetcher (the default priority-0 source) to fail and fall back. Pre-create and chown the efinance data dir to dsa at build time. The path is resolved dynamically to avoid hardcoding the Python version. This is image-internal static content, so the fix belongs at build time rather than the runtime mount-repair in the entrypoint (#1263), which only covers user-mounted volumes. Fixes #1748 Co-authored-by: gang.wu@ximalaya.com <gang.wu@ximalaya.com> Co-authored-by: mumu <42829555+ZhuLinsen@users.noreply.github.com>
This commit is contained in:
@@ -64,6 +64,14 @@ RUN mkdir -p /app/data /app/logs /app/reports && \
|
||||
chown -R dsa:dsa /app && \
|
||||
chmod +x /usr/local/bin/docker-entrypoint.sh
|
||||
|
||||
# efinance 将搜索缓存(search-cache.json)写入自身安装包内的 data 目录,
|
||||
# 该目录默认归 root 所有;容器以非 root 用户 dsa 运行时写入会 PermissionError,
|
||||
# 导致 efinance 数据源每次抓取 A 股数据都失败并降级。预置目录属主给 dsa 修复此问题。
|
||||
# 动态解析路径,避免写死 Python 版本目录。
|
||||
RUN EF_DATA_DIR="$(python -c 'import efinance, pathlib; print(pathlib.Path(efinance.__file__).parent / "data")')" && \
|
||||
mkdir -p "$EF_DATA_DIR" && \
|
||||
chown -R dsa:dsa "$EF_DATA_DIR"
|
||||
|
||||
# 设置环境变量默认值
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
ENV LOG_DIR=/app/logs
|
||||
|
||||
@@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
|
||||
- [修复] 避免 runtime scheduler 重建定时任务时重复立即运行事件监控,减少重复告警和后台任务状态丢失。
|
||||
- [修复] Web/API runtime scheduler 接管 `--serve --schedule` 后保留 `--dry-run`、`--no-notify` 等启动参数语义。
|
||||
- [改进] Web 历史报告详情不再内嵌展示 AI 建议卡片,结构化决策信号集中在 AI 建议页查询,并保留按来源报告 ID 筛选或 URL 参数精确定位入口。
|
||||
- [修复] Docker 镜像预置 efinance 缓存目录(efinance/data)属主给非 root 运行用户 dsa,修复 A 股 efinance 数据源因写 search-cache.json 触发 PermissionError 而每次抓取失败降级的问题。
|
||||
- [修复] Docker 部署中 Web 设置页保存自定义 Webhook 模板时自动转义 `$content_json` 等应用占位符,并在运行时还原,避免 Compose 重新部署将其展开为空。
|
||||
|
||||
## [3.23.0] - 2026-06-20
|
||||
|
||||
Reference in New Issue
Block a user