Files
matrix/.env.example
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

26 lines
899 B
Bash
Raw Permalink 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.
# Matrix 点歌机器人 - 环境变量示例
#
# 复制本文件为 .env 并填入实际值:
# cp .env.example .env
#
# 然后:
# docker-compose up -d
#
# 警告:.env 文件包含敏感信息,**不要**提交到 git!
# ============================================================
# 必须设置
# ============================================================
# 用于加密 secret.bin 中的 access_token + device_id
# 要求:≥ 8 字符(强密码;operator 自己记忆 / 存到密码管理器)
MATRIX_BOT_SECRET_PASSPHRASE=change-me-to-a-strong-passphrase
# ============================================================
# 可选(不设置有默认值)
# ============================================================
# 日志级别(trace / debug / info / warn / error
# 默认:info,matrix_music_bot=debug
# 生产建议:info
RUST_LOG=info,matrix_music_bot=debug