把 runner/ 打包成可直接部署的容器镜像,Linux 服务器 / 群晖 / 云主机上 不用再手动装 Node 与浏览器。 - Dockerfile:node:22-bookworm-slim + 官方 google-chrome-stable。 刻意不用发行版 chromium —— 它不带 H.264/AAC 专有编解码器,课程视频会 一直停在 0 秒;同时满足 preflight.mjs 对 Node 22+ 的硬性要求。 构建期完成 npm ci + npm run build,并实跑一次 headless 验证浏览器可用; CHROME_DEB_URL 构建参数供国内换镜像源。 - docker/entrypoint.sh:建 profile / 日志目录;首参为 sh/node 等时直接 exec 便于排查;无参数且无凭据时降级成 --check,避免容器无意义重启空转。 - docker-compose.yml:挂载 ./.run-profile 与 ./run-logs,shm_size 512m, init: true,日志轮转。restart 用 on-failure:3 而非 always —— 运行器刷完课 会以 0 正常退出,always 会造成「刷完 → 重启 → 再刷完」的热循环。 - .dockerignore:排除 node_modules / .run-profile / run-logs / .env, 凭据不进镜像层。 - .env.example:账号模板;.gitignore 加 !.env.example 白名单。 - .gitattributes:*.sh / Dockerfile / docker-compose.yml 强制 LF —— 带 CRLF 时 shebang 会变成 "/bin/sh\r",容器启动直接 exec format error。 - scripts/check.mjs:静态检查扩展到容器入口,跑 sh -n 并对 CRLF 报错 (Windows 无 sh 时只校验行尾)。29 个文件全绿。 - README:新增「容器(Docker)」小节,含 build / 自检 / run / compose 流程 与 8 条注意事项(卷权限、/dev/shm、沙箱、验证码、时区、退出码与重启策略)。
27 lines
531 B
Plaintext
27 lines
531 B
Plaintext
# 让镜像只带源码与运行必需文件,别把本机的浏览器 profile / 日志 / 凭据 / node_modules 打进去
|
|
node_modules
|
|
.run-profile
|
|
.run-tmp
|
|
run-logs
|
|
*.log
|
|
|
|
# 凭据绝对不能进镜像层
|
|
.env
|
|
.env.*
|
|
!.env.example
|
|
runner.local.mjs
|
|
|
|
# 开发工具与文档:容器里跑无头用不到,省体积
|
|
.git
|
|
.gitattributes
|
|
.gitignore
|
|
.vscode
|
|
.idea
|
|
docs
|
|
dev/tests
|
|
|
|
# 镜像自身文件(entrypoint.sh 由 Dockerfile 单独 COPY,这里的 .dockerignore 规则不影响)
|
|
Dockerfile
|
|
docker-compose.yml
|
|
.dockerignore
|