概述
freeswitch是一款簡單好用的VOIP開源軟交換平臺。
centos7 docker上編譯安裝fs.1.10的流程記錄,本文使用dockerfile模式。
環境
docker engine:Version 24.0.6
centos docker:7
freeswitch:v1.10.7
dockerfile
建立空目錄,建立dockerfile檔案。
github訪問經常失敗,先下載好原始碼包,並將fs.1.10.7原始碼資料夾複製到目錄下。
mkdir centos.7-fs.1.10
cd centos.7-fs.1.10
git clone https://github.com/signalwire/freeswitch.git -bv1.10.7 freeswitch-1.10.7
ls
dockerfile freeswitch-1.10.7
保持編譯的簡易性,該版本不編譯mod_av相關的模組,刪除mod_av模組目錄。
sudo rm -rf freeswitch-1.10.7/src/mod/applications/mod_av
遮蔽configure檔案的mod_av模組。
vi freeswitch-1.10.7/configure.ac
刪除行,src/mod/applications/mod_av/Makefile
dockerfile檔案內容如下。
vi dockerfile
FROM centos:7
WORKDIR /root
ADD ./freeswitch-1.10.7 /root/freeswitch
RUN cd /root/ \
&& yum -y update \
&& yum install -y centos-release-scl centos-release-scl-rh \
&& yum install -y scl-utils scl-utils-build yum-utils \
&& yum install -y devtoolset-9-gcc \
&& echo "signalwireusername" > /etc/yum/vars/signalwireusername \
&& echo "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 yum-utils \
&& yum-builddep -y freeswitch --skip-broken \
&& yum install -y yum-plugin-ovl rpmdevtools yum-utils git centos-release-scl centos-release-scl-rh \
&& yum remove -y spandsp-devel spandsp \
&& yum install -y sofia-sip-devel spandsp3-devel libks signalwire-client-c erlang python-devel postgresql-devel \
&& yum install -y which tzdata ilbc2-devel opus-devel \
# && git clone https://github.com/signalwire/freeswitch.git -bv1.10.7 freeswitch \
&& cd /root/freeswitch/ \
&& chmod 775 -R * \
&& ./bootstrap.sh -j \
&& ./configure \
&& cd /root/freeswitch/ \
&& 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 \
&& package-cleanup --quiet --leaves | xargs yum remove -y \
# && package-cleanup --quiet --dupes | xargs yum remove -y \
&& 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 --no-cache -t 10.55.55.136:5000/zr/centos.7-fs.1.10-release:v1.1.1 .
[+] Building 1120.5s (9/9) FINISHED docker:default
=> [internal] load build definition from dockerfile 0.1s
=> => transferring dockerfile: 2.75kB 0.0s
=> [internal] load metadata for docker.io/library/centos:7 0.0s
=> [internal] load .dockerignore 0.1s
=> => transferring context: 2B 0.0s
=> [1/4] FROM docker.io/library/centos:7 0.0s
=> [internal] load build context 0.4s
=> => transferring context: 1.16MB 0.3s
=> CACHED [2/4] WORKDIR /ROOT 0.0s
=> [3/4] ADD ./freeswitch-1.10.7 /root/freeswitch 1.3s
=> [4/4] RUN cd /root/ && yum -y update && yum install -y centos-release-scl centos-release-scl-rh && yum install -y scl-utils scl-utils-build yum-utils && yum install -y devtoolset-9-gcc && ec 1106.0s
=> exporting to image 12.0s
=> => exporting layers 12.0s
=> => writing image sha256:008cccf11d97a69d076a32fa8e27a93dd7899f4cf258ea102644f63badd9bfc8 0.0s
=> => naming to 10.55.55.136:5000/zr/centos.7-fs.1.10-release:v1.1.0 0.0s
上傳映象到registry。
sudo docker images
sudo docker push 10.55.55.136:5000/zr/centos.7-fs.1.10-release:v1.1.0
下載映象。
sudo docker pull 10.55.55.136:5000/zr/centos.7-fs.1.10-release:v1.1.0
啟動容器
sudo docker run -itd --net=host -v /home/adminx/docker/centos.7-fs.1.6.19/fs-sbc/conf:/usr/local/freeswitch/conf -v /usr/local/freeswitch/log:/usr/local/freeswitch/log -v /usr/local/freeswitch/recordings:/usr/local/freeswitch/recordings --name centos.7-fs.1.10-sbc 10.55.55.136:5000/zr/centos.7-fs.1.10-release:v1.1.1 /usr/local/freeswitch/bin/freeswitch -nonat -nosql -nonatmap -nocal -nort
sudo docker logs centos.7-fs.1.10-sbc
sudo docker exec -it centos.7-fs.1.10-sbc /usr/local/freeswitch/bin/fs_cli -x status
sudo docker rm -f centos.7-fs.1.10-sbc
總結
編譯出的docker映象還是比較大,需要持續瘦身。
centos系統後續的維護問題需要關注。
centos和rocky的方向需要驗證和抉擇一下。
空空如常
求真得真