部署环境
CentOS Linux release 7.9.2009
Docker version 24.0.7
Docker Compose version v2.22.0
freeswitch version v1.10.10
关闭防火墙
systemctl stop iptables
systemctl disable iptables
构建Dockerfile
构建freeswitch镜像时,一起把nginx也放进去了,为了后续使用Java对接freeswitch时下载录音用;大陆地区下载海外的服务依赖会比较慢,这里使用了华为镜像(因为我们云服务全部在华为云上),也可以替换成mirrors.aliyun.com或者mirrors.163.com。
FROM debian:bullseye
MAINTAINER caoliang1918 <caoliang1918@gmail.com>
WORKDIR /usr/local/freeswitch
ADD docker-entrypoint.sh /usr/local/
RUN chmod +x /usr/local/docker-entrypoint.sh
RUN echo voice9 > /etc/hostname
RUN sed -i 's/http:\/\/deb.debian.org/http:\/\/mirrors.huaweicloud.com/g' /etc/apt/sources.list
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -yq install vim git sngrep
RUN git clone -b 'v1.10.10' https://github.com/signalwire/freeswitch /usr/src/freeswitch
RUN git clone -b 'v2.0.3' https://github.com/signalwire/libks /usr/src/libs/libks
RUN git clone -b 'v1.13.17' https://github.com/freeswitch/sofia-sip /usr/src/libs/sofia-sip
RUN git clone https://github.com/freeswitch/spandsp /usr/src/libs/spandsp && cd /usr/src/libs/spandsp && git checkout 0d2e6ac
RUN git clone -b 'v2.0.0' https://github.com/signalwire/signalwire-c /usr/src/libs/signalwire-c
RUN DEBIAN_FRONTEND=noninteractive apt-get -yq install \
# nginx
nginx \
# build
build-essential cmake automake autoconf 'libtool-bin|libtool' pkg-config \
# general
libssl-dev zlib1g-dev libdb-dev unixodbc-dev libncurses5-dev libexpat1-dev libgdbm-dev bison erlang-dev libtpl-dev libtiff5-dev uuid-dev \
# core
libpcre3-dev libedit-dev libsqlite3-dev libcurl4-openssl-dev nasm \
# core codecs
libogg-dev libspeex-dev libspeexdsp-dev \
# mod_enum
libldns-dev \
# mod_python3
python3-dev \
# mod_av
libavformat-dev libswscale-dev libavresample-dev \
# mod_lua
liblua5.2-dev \
# mod_opus
libopus-dev \
# mod_pgsql
libpq-dev \
# mod_sndfile
libsndfile1-dev libflac-dev libogg-dev libvorbis-dev \
# mod_shout
libshout3-dev libmpg123-dev libmp3lame-dev
RUN cd /usr/src/libs/libks && cmake . -DCMAKE_INSTALL_PREFIX=/usr -DWITH_LIBBACKTRACE=1 && make install
RUN cd /usr/src/libs/sofia-sip && ./bootstrap.sh && ./configure CFLAGS="-g -ggdb" --with-pic --with-glib=no --without-doxygen --disable-stun --prefix=/usr && make -j`nproc --all` && make install
RUN cd /usr/src/libs/spandsp && ./bootstrap.sh && ./configure CFLAGS="-g -ggdb" --with-pic --prefix=/usr && make -j`nproc --all` && make install
RUN cd /usr/src/libs/signalwire-c && PKG_CONFIG_PATH=/usr/lib/pkgconfig cmake . -DCMAKE_INSTALL_PREFIX=/usr && make install
# Enable modules
RUN sed -i 's|#formats/mod_shout|formats/mod_shout|' /usr/src/freeswitch/build/modules.conf.in
RUN cd /usr/src/freeswitch && ./bootstrap.sh -j
RUN cd /usr/src/freeswitch && ./configure
RUN cd /usr/src/freeswitch && make -j`nproc` && make install
# Cleanup the image
RUN apt-get clean
RUN rm -rf /usr/src/*
ENTRYPOINT ["/usr/local/docker-entrypoint.sh"]
启动脚本
docker-entrypoint.sh
#!/bin/bash
set -e
#echo "restart nginx"
/etc/init.d/nginx start
echo "start freeswitch"
cd /usr/local/freeswitch/bin
exec ./freeswitch -nonat -c
exec "$@"
构建镜像脚本
执行build.sh 构建过程时间会很久,如果没有网络加速环境,大概率是会失败的,建议找一个网络加速环境,一次失败就再支持一次(毕竟失败是成功他妈🧐),docker build 时不要加 -no-cache。
#!/bin/bash
docker build -t registry.cn-hangzhou.aliyuncs.com/voice9-x86/freeswitch-debian:1.10.10 .
启动freeswitch
docker-compose up -d
freeswitch控制台
./fs_cli.sh
GitHub: https://github.com/caoliang1918/contact-center
演示系统:
呼叫中心后台:https://dev.voice9.com/admin/ 账号密码: admin 12345678
坐席端:https://dev.voice9.com/agent/ 账号密码:1001@test 12345678