mediasoup版本:3.14.14
mediasoup-demo版本:v3
windows 10 专业版
docker-desktop版本:4.30.0 (149282)
docker info:
Client:Version: 26.1.1Plugins:buildx: Docker Buildx (Docker Inc.)Version: v0.14.0-desktop.1Path: C:\Program Files\Docker\cli-plugins\docker-buildx.exe
...
Server:
...Server Version: 26.1.1Storage Driver: overlay2
打包完之后的镜像:
第一步:前期准备
1.下载docker-desktop,并开启buildx。不开启buildx无法跨平台编译。尽可能下载最新或最稳定的docker-desktop。
2.下载mediasoup-demo到本地目录。
3.修改打包文件。
如果不需要指定mediasoup的版本,不需要修改server/package.json中默认拉去的是最新的mediasoup版本。如果需要指定mediasoup的版本可以配置为Release的版本号获知指定某次提交。
我的配置(3.14.14):
"mediasoup": "git+https://github.com/versatica/mediasoup.git#efa8f5149082b4738ad5d3a8144e6b1d56e4fe73",
4.创建certs文件夹,生成证书。打开powershell执行。
openssl req -new -newkey rsa:1024 -x509 -sha256 -days 3650 -nodes -out fullchain.pem -keyout privkey.pem
5.修改config.example.js为config.js。里面的内容可以后面再改。
6.修改Dockerfile。建议修改为18或20。打包时间非常非常漫长,没有时间尝试更新的版本。
第一个是v18.20.4 第二个是v20.10.0
我的配置:
FROM node:18 AS stage-one
# Install DEB dependencies and others.
RUN \set -x \&& apt-get update \&& apt-get install -y net-tools build-essential python3 python3-pip valgrind
WORKDIR /service
COPY package.json .
RUN npm install --verbose --legacy-peer-deps
COPY server.js .
COPY config.js .
COPY lib lib
COPY certs certs
CMD ["node", "/service/server.js"]
第二步,开始打包。
1.下载node-18的镜像到本地,否则会很慢。
docker pull node:18 --platform linux/arm64
2.开始打包mediasoup
docker buildx build --platform linux/arm64/v8 --progress=plain -f .\Dockerfile -t mediasoup:v3-arm .
三个小时后打包成功。
#9 4540.3 npm http fetch GET 200 https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz 28963ms (cache miss)
#9 4544.2 npm http fetch GET 200 https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz 33605ms (cache miss)
#9 8735.9 npm info run bufferutil@4.0.8 install node_modules/bufferutil node-gyp-build
#9 8736.0 npm info run utf-8-validate@5.0.10 install node_modules/utf-8-validate node-gyp-build
#9 8761.5 npm info run bufferutil@4.0.8 install { code: 0, signal: null }
#9 8761.5 npm info run mediasoup@3.14.14 postinstall node_modules/mediasoup node npm-scripts.mjs postinstall
#9 8762.7 npm info run es5-ext@0.10.64 postinstall { code: 0, signal: null }
#9 11973.4 npm info run mediasoup@3.14.14 postinstall { code: 0, signal: null }
#9 11976.2
#9 11976.2 added 614 packages, and audited 615 packages in 3h
#9 11976.2
#9 11976.2 53 packages are looking for funding
#9 11976.2 run `npm fund` for details
#9 11976.3
#9 11976.3 11 vulnerabilities (7 moderate, 4 high)
#9 11976.3
#9 11976.3 To address all issues (including breaking changes), run:
...
PS:不确定后面这几个code: 0, signal: null。是不是正常情况,反正镜像打成了,也能正常运行。
docker_96">第三步:运行docker
保存镜像到本地
docker save -o mediasoup-v3-arm.tar mediasoup:v3-arm
拷贝到arm64服务器上。导入镜像。
docker load -i mediasoup-v3-arm.tar
docker run --name=mediasoup -p 4443:4443/tcp -p 3000:3000/tcp -p 44440-44500:44440-44500/udp -p 44440-44500:44440-44500/tcp --init -e DEBUG="mediasoup-demo-server:INFO* *WARN* *ERROR*" -e INTERACTIVE="true" -e PROTOO_LISTEN_PORT="4443" -e MEDIASOUP_LISTEN_IP="0.0.0.0" -e MEDIASOUP_ANNOUNCED_IP="192.168.50.153" -e MEDIASOUP_MIN_PORT="2000" -e MEDIASOUP_MAX_PORT="2020" -e MEDIASOUP_USE_VALGRIND="false" -e MEDIASOUP_VALGRIND_OPTIONS="--leak-check=full --track-fds=yes --log-file=/storage/mediasoup_valgrind_%p.log" -it -d mediasoup:v3-arm
PS:MEDIASOUP_ANNOUNCED_IP为本机的IP地址。如果端口号冲突或者docker代理问题,使用–network host主机模式。
启动成功日志:
...mediasoup-demo-server:INFO running 4 mediasoup Workers... +0ms[opening Readline Command Console...]
type help to print available commands
cmd> mediasoup-demo-server:INFO creating Express app... +86msmediasoup-demo-server:INFO running an HTTPS server... +2msmediasoup-demo-server:INFO running protoo WebSocketServer... +37ms