使用docker 搭建MediaSoup服务

相关连接
  1. WebRtc 框架学习(一)
  2. Mediasoup基本框架学习
  3. 使用docker 搭建MediaSoup服务
  4. MediaSoup-demo模块增加nginx

使用docker 搭建MediaSoup服务

mediasoup-demo 编译并且安装在docker容器上既复杂又浪费时间,我在这里编译一个已经安装好的镜像,并且增加了nginx模块。提升了Web端的性能。

github项目路径

docker hub 路径

环境变量说明
  • DEBUG
  • DOMAIN
  • PROTOO_LISTEN_PORT
  • MEDIASOUP_LISTEN_IP
  • MEDIASOUP_ANNOUNCED_IP
  • MEDIASOUP_MIN_PORT
  • MEDIASOUP_MAX_PORT
  • MEDIASOUP_USE_VALGRIND
  • MEDIASOUP_VALGRIND_OPTIONS
编写环境变量文件
# media.env
DOMAIN=47.114.54.xxxx  #your host ip
MEDIASOUP_LISTEN_IP=172.88.0.3 #docker ip
MEDIASOUP_ANNOUNCED_IP=47.114.54.xxx #your host ip
DEBUG=*mediasoup* *ERROR* *WARN*
INTERACTIVE=false
PROTOO_LISTEN_PORT=4443
HTTPS_CERT_FULLCHAIN=/mediasoup/config/certs/fullchain.pem
HTTPS_CERT_PRIVKEY=/mediasoup/config/certs/privkey.pem
MEDIASOUP_MIN_PORT=30000
MEDIASOUP_MAX_PORT=30100
MEDIASOUP_USE_VALGRIND=false
MEDIASOUP_VALGRIND_OPTIONS=--leak-check=full --track-fds=yes --log-file=/storage/mediasoup_valgrind_%p.log
docker-compose 编排
version: '3'

services:            
    # mediasoup-worker
    mediasoup:
        image: ysf465639310/mediasoup-demo-cloud:v2
        ports:
            - '${PROTOO_LISTEN_PORT}:${PROTOO_LISTEN_PORT}'
            - '${MEDIASOUP_MIN_PORT}-${MEDIASOUP_MAX_PORT}:${MEDIASOUP_MIN_PORT}-${MEDIASOUP_MAX_PORT}/udp'
            - '${MEDIASOUP_MIN_PORT}-${MEDIASOUP_MAX_PORT}:${MEDIASOUP_MIN_PORT}-${MEDIASOUP_MAX_PORT}/tcp'
        working_dir: /mediasoup/server/
        
        #if you want your own config,you can use volume lis this
        volumes:
          - /etc/localtime:/etc/localtime
          #如果需要添加自己的配件文件,将注释取消,挂载自己的目录
          #- ../../config/config.js:/mediasoup/config/config.js:rw
          #- ../../config/config.js:/mediasoup/server/config.js:rw
          #- ../data:/data
          #- ../storage:/storage
            
        env_file:
            - ./media.env
        
        command:  ["node", "./server.js"]
        #command: ["sleep", "10000000"]
        
        networks:
             cloud_conference:
                ipv4_address: 172.88.0.3
networks:
   cloud_conference:
      ipam:
         config:
         - subnet: 172.88.0.0/16
           #gateway: 172.88.0.1
运行
  1. Step1:

    root@H3CDATA:/opt/CLOUD_MEDIASOUP# cd mediasoup/compose/
    root@H3CDATA:/opt/CLOUD_MEDIASOUP/mediasoup/compose# mv media.env .env
    
  2. Step2

    root@H3CDATA:/opt/CLOUD_MEDIASOUP/mediasoup/compose# docker-compose up -d
    
增加nginx 配置

mediasoup-demo 增加nginx模块

你可能感兴趣的:(云计算,mediasoup)