文档说明:只记录关键地方;
试验环境: linux debian 11
目标:构建能启动的 coturn
coturn 服务器完整的实现了 STUN/TURN/ICE 协议
基础环境: docker
构建脚本 build-docker.sh
#!/bin/bash
set -e
export DOCKER_BUILDKIT=1
# shellcheck disable=SC2006
TIME=`date "+%Y%m%d"`
VERSION="dev-"${TIME}
IMAGE="registry.cn-beijing.aliyuncs.com/jingjingxyk-public/app:coturn-dev-${VERSION}"
PROXY_URL=${2:+'http://192.168.3.26:8015'}
# 要使用代理,需要传递两个参数
# sh build-docker.sh --proxy 1
docker build -t "$IMAGE" -f Dockerfile . --progress=plain
docker push "$IMAGE"
FROM debian:buster
# 启动非交互模式:
ENV DEBIAN_FRONTEND=noninteractive
# https://github.com/coturn/coturn/blob/master/INSTALL
# https://github.com/coturn/coturn/blob/master/docker/coturn/Dockerfile
RUN test ! -f /etc/apt/source.list.save && cp /etc/apt/sources.list /etc/apt/sources.list.save
RUN sed -i "s@security.ubuntu.com@mirrors.ustc.edu.cn@g" /etc/apt/sources.list
RUN sed -i "s@archive.ubuntu.com@mirrors.ustc.edu.cn@g" /etc/apt/sources.list
RUN apt update -y
RUN apt install -y sudo
RUN sudo apt install -y \
ca-certificates \
git wget curl \
gcc \
openssl libssl-dev \
sqlite \
libsqlite-dev \
libevent-dev \
libpq-dev \
libmariadbd-dev libmariadb-dev \
libevent-dev
# https://github.com/mongodb/mongo-c-driver/
RUN sudo apt install -y \
libbson-dev libmongoc-dev \
libhiredis-dev
RUN sudo apt install -y -y make cmake g++ gdebi-core
RUN sudo apt install -y initscripts net-tools pkg-config sqlite3 libsqlite3-dev
ENV BUILD_PREFIX /usr/local/src
ENV INSTALL_PREFIX /usr/local
WORKDIR $BUILD_PREFIX
ARG PROXY_URL
ENV http_proxy=$PROXY_URL
ENV https_proxy=$PROXY_URL
RUN git clone https://github.com/coturn/coturn.git
ENV http_proxy=''
ENV https_proxy=''
#ADD ./coturn /coturn
# Build Coturn
WORKDIR ${BUILD_PREFIX}/coturn
RUN ./configure -h
RUN make
RUN make install
# set startup parameters
# SUTN/TURN PORTS
EXPOSE 3478 3479 3478/udp 3479/udp 80 80/udp
EXPOSE 5349 5350 5349/udp 5350/udp 443 443/udp
# CLI
EXPOSE 5766
# Relay Ports
EXPOSE 49152-65535 49152-65535/udp
#COPY ./docker-entrypoint.sh /
#ENTRYPOINT ["/docker-entrypoint.sh"]
RUN cp /usr/local/etc/turnserver.conf.default /usr/local/etc/turnserver.conf
WORKDIR ${INSTALL_PREFIX}
# ENTRYPOINT ["tini", "--","/usr/local/bin/turnserver"]
CMD ${INSTALL_PREFIX}/bin/turnserver
# cat /usr/local/share/doc/turnserver/postinstall.txt
# install examples/etc/turnserver.conf /usr/local/etc/turnserver.conf.default
# install turndb/schema.sql /usr/local/share/doc/turnserver
参考文档
- coturn INSTALL
- coturn Dockerfile
- WebRTC samples
- WebRTC source code
- github coturn
- shell之变量默认值
- Dockerfile