Matrix Music Bot Dev
|
f55e28ee1d
|
docker: 多阶段 Dockerfile + docker-compose.yml + .dockerignore + .env.example
按用户选定方案:
1. 多阶段 Debian bookworm-slim
- builder=rust:1.96-bookworm(含 pkg-config libsqlite3-dev libssl-dev)
- runtime=debian:bookworm-slim(ffmpeg libsqlite3-0 libssl3 tini ca-certificates)
- 利用 Docker 层缓存:先预编译 deps 再复制 src
2. yt-dlp standalone 二进制
- ARG YTDLP_VERSION=2026.03.17
- 用 ADD --checksum=sha256 校验
- 与 README 中版本一致便于锁版本
3. 全部 bind mount
- ./config → /app/config:ro(配置只读)
- ./data → /app/data(secret.bin / crypto.db / cache/)
4. 单服务 docker-compose
- 重启策略 unless-stopped
- 资源限制 2 CPU + 1G RAM
- 健康检查 pgrep
- MATRIX_BOT_SECRET_PASSPHRASE 从 .env 必填
- RUST_LOG 默认 info + matrix_music_bot=debug
安全要点:
- 非 root 用户(bot:bot)
- tini 作为 PID 1(正确转发 SIGTERM/SIGINT)
- 健康检查:仅进程存活检测(bot 没有 health endpoint)
.dockerignore 排除:
- /target /data /config /tests /docs 等
- 减少 build context 大小(避免每次 build 重复传输)
.env.example:
- 模板文件,含 MATRIX_BOT_SECRET_PASSPHRASE 默认值
- RUST_LOG 默认值
下一步:补充 README.md + CLAUDE.md 的 Docker 部署章节
|
2026-07-02 23:54:36 +08:00 |
|