docker-compose.yml 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. # ============================================================
  2. # 鸣鹤 (MingHe) SIP Server — Docker Compose 配置
  3. # ============================================================
  4. #
  5. # 使用方法:
  6. # 1. 复制配置模板: cp config.template.toml config/config.toml
  7. # 2. 编辑配置文件: vim config/config.toml
  8. # 3. 启动服务: docker compose up -d
  9. # 4. 查看日志: docker compose logs -f
  10. # 5. 停止服务: docker compose down
  11. #
  12. # ============================================================
  13. services:
  14. minghe:
  15. # 使用预构建镜像
  16. image: facilisvelox/minghe:latest
  17. # 容器名称
  18. container_name: minghe-sip
  19. # 自动重启策略
  20. restart: unless-stopped
  21. # 端口映射
  22. ports:
  23. # SIP TLS 信令端口
  24. - "${SIP_PORT:-5061}:5061/tcp"
  25. # RTP/SRTP 媒体端口范围(UDP)
  26. # 外部端口必须与容器端口一致,因为 SDP 会直接公布这些端口。
  27. # 默认 20000-20020 支持约 10 通并发;不要在小 VPS 上一次映射上万个 UDP 端口。
  28. - "${RTP_PORT_START:-20000}-${RTP_PORT_END:-20020}:${RTP_PORT_START:-20000}-${RTP_PORT_END:-20020}/udp"
  29. # 卷挂载
  30. volumes:
  31. # 配置文件
  32. - ./config:/app/config:ro
  33. # TLS 证书持久化(使用 Docker 命名卷,避免宿主机目录权限导致证书无法写入)
  34. - certs:/app/certs
  35. # 环境变量
  36. environment:
  37. # 日志级别: error, warn, info, debug, trace
  38. - RUST_LOG=${RUST_LOG:-info}
  39. # 时区
  40. - TZ=${TZ:-Asia/Shanghai}
  41. # 网络模式
  42. # 如果需要使用宿主机网络(适用于 RTP 端口范围大的场景),取消注释:
  43. # network_mode: host
  44. # 资源限制
  45. deploy:
  46. resources:
  47. limits:
  48. # CPU 限制。默认 1.0,兼容 1 核 VPS;多核机器可通过 CPU_LIMIT 调高。
  49. cpus: "${CPU_LIMIT:-1.0}"
  50. # 内存限制
  51. memory: "${MEM_LIMIT:-512M}"
  52. reservations:
  53. cpus: "0.25"
  54. memory: 64M
  55. # 健康检查
  56. healthcheck:
  57. test: ["CMD", "pgrep", "minghe"]
  58. interval: 30s
  59. timeout: 5s
  60. retries: 3
  61. start_period: 10s
  62. # 日志配置
  63. logging:
  64. driver: json-file
  65. options:
  66. max-size: "10m"
  67. max-file: "3"
  68. volumes:
  69. certs: