概述
freeswitch是一款简单好用的VOIP开源软交换平台。
centos7 docker上编译安装fs的流程记录,本文使用dockerfile模式。
环境
docker engine:Version 24.0.6
centos docker:7
freeswitch:v1.6.20
dockerfile
创建空目录,创建dockerfile文件。
github访问经常失败,先下载好源码包,并将fs.1.6.20源码文件夹拷贝到目录下。
mkdir centos.7-fs.1.6.20
cd centos.7-fs.1.6.20
ls
dockerfile freeswitch-1.6.20
dockerfile文件内容如下。
vi dockerfile
FROM centos:7
WORKDIR /root
ADD ./freeswitch-1.6.20 /root/freeswitch
RUN cd /root/ \
&& yum -y update \
&& echo "signalwireusername" > /etc/yum/vars/signalwireusername \
&& echo "pat_signalwiretoken" > /etc/yum/vars/signalwiretoken \
&& yum install -y https://$(< /etc/yum/vars/signalwireusername):$(< /etc/yum/vars/signalwiretoken)@freeswitch.signalwire.com/repo/yum/centos-release/freeswitch-release-repo-0-1.noarch.rpm \
&& yum install -y epel-release \
&& yum install -y autoconf automake libtool gcc-c++ ncurses-devel make zlib-devel libjpeg-devel yasm nasm libevent libevent-devel \
&& yum install -y openssl-devel e2fsprogs-devel curl-devel pcre-devel speex-devel sqlite-devel mysql-devel \
&& yum install -y git ldns-devel libedit-devel lua-devel libsndfile-devel libshout-devel lame-devel \
&& yum install -y which tzdata ilbc2-devel opus-devel \
# && git clone https://github.com/signalwire/freeswitch.git -bv1.6.20 freeswitch \
&& cd /root/freeswitch/ \
&& chmod 775 -R * \
&& sh support-d/prereq.sh \
&& ./bootstrap.sh -j \
&& ./configure \
&& make \
&& make install \
&& cd /root/freeswitch/src/mod/codecs/mod_ilbc \
&& make \
&& make install \
&& cd /root/freeswitch/src/mod/applications/mod_translate \
&& make \
&& make install \
&& ln -s /usr/lib64/ilbc2/libilbc.so.0 /usr/lib64/libilbc.so.0 \
&& cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& yum clean all \
&& rm -rf /var/cache/yum \
&& rm -rf /root/freeswitch \
&& rm -rf /usr/local/freeswitch/conf /usr/local/freeswitch/log /usr/local/freeswitch/recordings
# EXPOSE 5080
VOLUME ["/usr/local/freeswitch/conf", "/usr/local/freeswitch/log", "/usr/local/freeswitch/recordings", "/usr/local/freeswitch/sounds", "/usr/local/freeswitch/webapp"]
CMD /usr/local/freeswitch/bin/freeswitch -nonat -nosql -nonatmap -nocal -nort
镜像操作
制作镜像,注意命令最后一个参数是当前目录“.“。
sudo docker build -t 10.55.55.136:5000/zr/centos.7-fs.1.6.20-test:v1.0 .
[+] Building 768.1s (9/9) FINISHED docker:default
=> [internal] load .dockerignore 0.2s
=> => transferring context: 2B 0.0s
=> [internal] load build definition from dockerfile 0.1s
=> => transferring dockerfile: 2.03kB 0.0s
=> [internal] load metadata for docker.io/library/centos:7 0.0s
=> [1/4] FROM docker.io/library/centos:7 0.0s
=> [internal] load build context 2.3s
=> => transferring context: 190.73MB 2.0s
=> CACHED [2/4] WORKDIR /ROOT 0.0s
=> [3/4] ADD ./freeswitch-1.6.20 /root/freeswitch 1.7s
=> [4/4] RUN cd /root/ && yum -y update && echo "signalwireusername" > /etc/yum/vars/signalwireusername && echo "pat_signalwiretoken" > /etc/yum/vars/signalwiretoken && yum install -y https://$(< 757.8s
=> exporting to image 5.5s
=> => exporting layers 5.5s
=> => writing image sha256:a0a8c5564ad901bc931d9610169b3388f60e07d2201f846d9c35a8603b880e69 0.0s
=> => naming to 10.55.55.136:5000/zr/centos.7-fs.1.6.20-test:v1.0 0.0s
上传镜像到registry。
sudo docker images
sudo docker push 10.55.55.136:5000/zr/centos.7-fs.1.6.20-test:v1.0
下载镜像。
sudo docker pull 10.55.55.136:5000/zr/centos.7-fs.1.6.20-test:v1.0
查看私服registry的镜像版本。
curl -XGET http://10.55.55.136:5000/v2/_catalog
{"repositories":["test/debian","test/registry","zr/centos.7-fs.1.6.19-compile","zr/centos.7-fs.1.6.19-release"]}
curl -XGET http://10.55.55.136:5000/v2/zr/centos.7-fs.1.6.19-release/tags/list
{"name":"zr/centos.7-fs.1.6.19-release","tags":["v1.1","v1.2","v1.3","v1.4","v1.5","v1.6"]}
问题处理
DOCKER使用过程问题汇总。
1 docker容器的时区设置问题,在容器中执行如下命令。
yum install tzdata
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
2 运行一个无日志的Docker容器。
docker run -d --log-driver none your_image_name
3 docker容器访问宿主机上nas目录的状态,取决于docker服务启动时宿主机挂载nas目录的状态。
所以,nas挂载目录有变化的时候,需要重启docker服务,以便docker容器可以正常访问nas目录。
4 docker容器自动重启。
docker run -d --restart=always your_image_name
总结
centos系统后续的维护问题需要关注。
centos和rocky的方向需要验证和抉择一下。
空空如常
求真得真