FreeSWITCH Docker Building Guide

Install docker

First, install the docker service on the server to facilitate subsequent environment construction.

1
2
3
4
sudo  yum install -y docker
docker --version
sudo systemctl start docker
systemctl status docker

Construct Docker file of FreeSWITCH

Write the docker file to set the instructions that need to be executed, and directly install the various dependencies and external functions required by freeswitch.

  • Create Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#When the system kernel is incompatible with the docker system, switch bullseye to buster
FROM debian:buster
MAINTAINER Andrey Volk <andrey@signalwire.com>

RUN sed -i 's/http:\/\/deb.debian.org/http:\/\/mirrors.aliyun.com/g' /etc/apt/sources.list


RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -yq install git

#RUN git clone https://github.com/signalwire/freeswitch /usr/src/freeswitch
RUN cd /usr/src/ \
&& git clone https://github.com/signalwire/freeswitch.git -bv1.10 freeswitch \
&& cd freeswitch \
&& git config pull.rebase true
RUN cd /usr/src/
RUN git clone https://github.com/signalwire/libks /usr/src/libs/libks
RUN git clone https://github.com/freeswitch/sofia-sip /usr/src/libs/sofia-sip
RUN git clone https://github.com/freeswitch/spandsp /usr/src/libs/spandsp
RUN git clone https://github.com/signalwire/signalwire-c /usr/src/libs/signalwire-c

RUN DEBIAN_FRONTEND=noninteractive apt-get -yq install \
# 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
# Other software
# vim sngrep htop

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 && git checkout 0d2e6ac && ./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

RUN ln -sf /usr/local/freeswitch/bin/freeswitch /usr/bin/
RUN ln -sf /usr/local/freeswitch/bin/fs_cli /usr/bin/

# Install libfvad
RUN cd /usr/src/
RUN git clone https://github.com/dpirch/libfvad.git \
&& cd libfvad \
&& autoreconf -i \
&& ./configure \
&& make \
&& make install \
&& ldconfig

# Cleanup the image
#RUN apt-get clean

# Uncomment to cleanup even more
#RUN rm -rf /usr/src/*
  • Compile File
1
2
3
4
5
sudo docker build -t freeswitch ./
sudo docker images
sudo docker run -itd --network host -v /home/work/volume:/usr/local/freeswitch --name freeswitch freeswitch
sudo docker ps
docker exec -it freeswitch bash