操作系统 :CentOS 7.6_x64
FreeSWITCH版本 :1.10.9
Docker版本:23.0.6
FreeSWITCH这种比较复杂的系统,使用容器部署是比较方便的,今天记录下CentOS 7环境下使用docker构建FreeSWITCH编译环境及打包发布的过程。
1)移除旧版本(可选)
yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
2)安装依赖项
yum install -y yum-utils device-mapper-persistent-data lvm2
3)添加yum源
yum-config-manager --add-repo http://download.docker.com/linux/centos/docker-ce.repo
或
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
4)查看可用docker版本
yum list docker-ce --showduplicates | sort -r
5)安装docker服务
指定版本安装(这里指定版本安装):
yum install docker-ce-cli-23.0.6 docker-ce-23.0.6 containerd.io
查看docker版本信息:
docker version
6)配置docker服务
启动docker服务: systemctl start docker
配置docker服务开机启动: systemctl enable docker
查看docker服务状态:systemctl status docker
可从如下地址获取:
https://files.freeswitch.org/releases/freeswitch/
也可通过wget获取:
wget https://files.freeswitch.org/releases/freeswitch/freeswitch-1.10.9.-release.tar.gz
主要依赖以下代码库:
libks-1.8.2 : https://github.com/signalwire/libks/archive/refs/tags/v1.8.2.tar.gz
sofia-sip-1.13.14 : https://github.com/freeswitch/sofia-sip/archive/refs/tags/v1.13.14.tar.gz
spandsp : https://github.com/freeswitch/spandsp.git
signalwire-c : https://github.com/signalwire/signalwire-c/archive/refs/tags/1.3.0.tar.gz
可通过wget或git获取:
wget https://github.com/signalwire/libks/archive/refs/tags/v1.8.2.tar.gz
wget https://github.com/freeswitch/sofia-sip/archive/refs/tags/v1.13.14.tar.gz
git clone https://github.com/freeswitch/spandsp.git
wget https://github.com/signalwire/signalwire-c/archive/refs/tags/1.3.0.tar.gz
这里使用Debian 11 (bullseye)作为基础镜像:
docker image pull debian:bullseye
1)启动debian容器
docker run --name debian --network host -t -d debian:bullseye
2)复制源码到debian容器
docker cp freeswitch-1.10.9.-release.tar.gz debian:/usr/src/
docker cp fs1.10.9-deps debian:/usr/src/
3)更新apt源(可选)
这里使用清华的源来加速安装:https://mirrors.tuna.tsinghua.edu.cn/help/debian/
更新apt源:
>/etc/apt/sources.list
echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free" >> /etc/apt/sources.list
echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free" >> /etc/apt/sources.list
echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free" >> /etc/apt/sources.list
echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free" >> /etc/apt/sources.list
cat /etc/apt/sources.list
apt update
4)安装编译依赖项
apt install gcc g++ autoconf automake make cmake yasm uuid-dev libvpx-dev unixodbc-dev ncurses-dev zlib1g-dev libjpeg-dev libtiff-dev liblua5.1-0-dev libsqlite3-dev libsndfile-dev libavformat-dev libswscale-dev libcurl4-openssl-dev libpcre3-dev libspeex-dev libspeexdsp-dev libedit-dev libtool libldns-dev libopus-dev libpq-dev
安装libks:
tar zxvf libks-1.8.2.tar.gz
cd libks-1.8.2
cmake .
make
make install
安装sofia-sip:
tar zxvf sofia-sip-1.13.14.tar.gz
cd sofia-sip-1.13.14
./bootstrap.sh
./configure
make
make install
安装spandsp:
cd spandsp/
./bootstrap.sh
./configure
make
make install
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:${PKG_CONFIG_PATH}
echo "export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:${PKG_CONFIG_PATH}" >> /etc/profile
ldconfig
安装signalwire-c:
tar zxvf signalwire-c-1.3.0.tar.gz
cd signalwire-c-1.3.0
cmake .
make
make install
5)编译FreeSWITCH
大致步骤:
./rebootstrap.sh && ./configure && make
具体参考 : https://www.cnblogs.com/MikeZhang/p/centos7InstallFs20221007.html
6)安装及运行FreeSWITCH(可选)
执行make install安装FreeSWITCH
运行FreeSWITCH:
/usr/local/freeswitch/bin/freeswitch -nonat
1)移除FreeSWITCH源代码及依赖项
rm -rf /usr/src/freeswitch-1.10.9.-release*
rm -rf /usr/src/fs1.10.9-deps/
2)导出debian容器快照
docker export -o debian_fs_builder.tar 164f8b171a95
3)给导出的容器快照添加标签
docker import debian_fs_builder.tar
docker image tag 91f9e45241ed fs:base
4)导出基础编译镜像
docker image save fs:base -o fs-base.tar
tar zcvf fs-base.tar.gz fs-base.tar
预编译的基础镜像(fs-base.tar.gz)可从如下渠道获取:
关注微信公众号(聊聊博文,文末可扫码)后回复 20230617 获取。
1)导入镜像
docker load -i fs-base.tar
2)启动容器
docker run --name fs --network host -t -d fs:base /bin/bash
3)编译及运行FreeeSWITCH
仅复制FreeSWITCH源码过去即可编译及安装,演示视频可从如下渠道获取:
关注微信公众号(聊聊博文,文末可扫码)后回复 2023061701 获取。
源码文件:freeswitch-1.10.9.-release.tar.gz
完整代码可从如下渠道获取:
关注微信公众号(聊聊博文,文末可扫码)后回复 20230617 获取。
自动构建脚本如下:
#! /bin/bash
tar zxvf freeswitch-1.10.9.-release.tar.gz
docker build -t fs:1.0.0 .
docker image save fs:1.0.0 -o fs_v1.0.0.tar
tar zcvf fs_v1.0.0.tar.gz fs_v1.0.0.tar
rm -rf fs_v1.0.0.tar
tar zxvf fs_v1.0.0.tar.gz
docker load -i fs_v1.0.0.tar
./run.sh
使用基础编译镜像自动构建版本及运行容器的演示视频,可从如下渠道获取:
关注微信公众号(聊聊博文,文末可扫码)后回复 2023061702 获取。
本文涉及源码和文件,可以从如下途径获取:
关注微信公众号(聊聊博文,文末可扫码)后回复 20230617 获取。
手机扫一扫
移动阅读更方便
你可能感兴趣的文章