Files
order_site/deploy/docker/tools.Dockerfile
T
yml2213 08318ef8d9 feat(deploy): 财务上线数据阶段编排与运维加固
- 新增 deploy/post-deploy.sh:回填 → 业务配置 → 同步 → 验收四阶段编排,支持 --only/--dry-run/窗口参数
- 新增 tools 镜像与 scripts/verify-finance-launch.sql(15 项上线验收)
- 验收口径:成本闸门二选一、要求已过账凭证、备用金支出关联、成本覆盖 WARN
- 加固:参数校验、工具镜像每次刷新、docker run 兜底超时、迁移前缀探测、验收失败退出码 2
- 工具镜像预建 /app/data,消除日志 EACCES
- 回填后与 restore-db 恢复后自动 VACUUM (ANALYZE),修复订单列表分页 COUNT 全表扫描(41 万单实测 27s → 0.17s)
- 文档:41 万单同步用 7 天窗 + 180s 超时;回填/恢复后刷新统计
2026-10-28 11:52:42 +08:00

50 lines
1.9 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 财务运维工具镜像(一次性/按需容器)
#
# 为什么需要它:生产 backend 镜像为了体积与安全做了两件事——
# 1) `npm prune --omit=dev`(删掉 tsx 等 devDependencies)
# 2) 只 `COPY dist`(tsconfig.build.json 的 rootDir=src,scripts/ 不进 dist)
# 因此 `docker compose exec backend npm run revenue:backfill` 在生产**必然失败**。
# 本镜像保留源码 + devDependencies,专门用来跑 scripts/ 下的回填/同步脚本。
#
# 构建(仓库根目录):
# docker compose --profile tools build tools
# 或:
# docker build -f deploy/docker/tools.Dockerfile -t order-site/tools:latest .
#
# 直接执行单个脚本(不需要 compose):
# docker run --rm --network order_site_default --env-file .env \
# order-site/tools:latest npm run revenue:backfill -- --dryRun
#
# 说明:脚本只读写数据库,不写文件;镜像不挂载业务数据卷。
ARG BASE_REGISTRY=docker.m.daocloud.io
FROM ${BASE_REGISTRY}/library/node:22-bookworm
ARG DEBIAN_MIRROR=mirrors.aliyun.com
ARG NPM_REGISTRY=https://registry.npmmirror.com
ENV DEBIAN_FRONTEND=noninteractive \
NPM_CONFIG_REGISTRY=${NPM_REGISTRY} \
TZ=Asia/Shanghai \
NODE_ENV=development
WORKDIR /app
# 先装依赖再拷源码,命中 Docker 层缓存:只改脚本时不必重装 node_modules。
COPY apps/backend/package.json apps/backend/package-lock.json ./
RUN --mount=type=cache,target=/root/.npm \
npm ci --include=dev
COPY --chown=node:node apps/backend/ ./
# 脚本运行时会加载 backend 的 logger,它会把日志写到 $DATA_ROOT/logs。
# 镜像以 node 用户运行,必须提前建好该目录并授权,否则每条日志都会刷
# EACCES: permission denied, mkdir '/app/data'。
RUN mkdir -p /app/data && chown -R node:node /app/data
USER node
# 不带命令运行时列出可用脚本,避免误用。
CMD ["npm", "run"]