Linphone-SDK Ubuntu 22.04 Dockerイメージの作成とアプリのビルド(IPv6対応:検証中)

Linphone-SDK Dockerイメージの作成(Ubuntu 22.04)

Linphone-SDKのDockerコンテナ内でLinphoneアプリやflexisipサーバをビルドするため、Linphone-SDKのDockerイメージを作成します。必要なのは下記でダウンロードした docker-files ディレクトリです。

$ git clone https://gitlab.linphone.org/BC/public/linphone-sdk.git

docker-files ディレクトリ内の bc-dev-ubuntu-rolling を参考にして Ubuntu 22.04 に対応した新規ファイルを作成します。

bc-dev-ubuntu-22-04-lts

FROM ubuntu:22.04

MAINTAINER Takanobu Fuse <ficusonline@gmail.com>

# Configure locale
RUN apt-get update && \
    apt-get install -y locales && \
    apt-get clean && \
    echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \
    locale-gen
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8'
ENV TZ=Europe/Paris
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
ARG DEBIAN_FRONTEND=noninteractive

ENV SHELL=/bin/bash
#ENV PS1='\[\e[33m\]\u@bc-dev-ubuntu-22-04-lts>\[\e[0m\] '

# Install common general tools
RUN apt-get update && \
    apt-get install -y nano sudo vim && \
    apt-get clean

# Install development tools
RUN apt-get update && \
    apt-get install -y alien at autoconf bison ccache clang cmake doxygen elfutils g++ gdb git graphviz intltool libtool lsb-release make nasm ninja-build openssh-client patch python3-pip python3-pystache python-six yasm && \
    apt-get clean

# Install linphone & flexisip dependencies development packages
RUN apt-get update && \
    apt-get install -y libasound2-dev libavcodec-dev libavutil-dev libbsd-dev libegl1-mesa-dev libglew-dev libgsm1-dev libjansson-dev libmariadb-dev-compat libmbedtls-dev libopus-dev libpq-dev libprotobuf-dev libpulse-dev libqt5svg5-dev libsnmp-dev libspeex-dev libspeexdsp-dev libsqlite3-dev libsrtp2-dev libssl-dev libswscale-dev libturbojpeg0-dev libv4l-dev libvpx-dev libxerces-c-dev libxml2-dev libxv-dev protobuf-compiler qt3d5-dev qtbase5-dev qtbase5-dev-tools qtchooser qt5-qmake qtconnectivity5-dev qtdeclarative5-dev qtdeclarative5-dev-tools qtdeclarative5-dev-tools qtquickcontrols2-5-dev qttools5-dev qttools5-dev-tools xsdcxx && \
    apt-get clean

# Configure user bc
RUN useradd -ms /bin/bash bc && \
    echo 'bc:cotcot' | chpasswd && \
    echo 'bc ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

USER bc
WORKDIR /home/bc
COPY --chown=bc rpmmacros /home/bc/.rpmmacros
CMD bash

Makefikeの編集(Ubuntu 22.04のセクション追加)

.....
.....
ubuntu-22.04-LTS:
	docker build -f bc-dev-ubuntu-22-04-lts -t $(BASE_NAME)/bc-dev-ubuntu:22.04 --rm .
.....
.....

ビルド(直接 docker build コマンドでビルドしても構いません)

$ make ubuntu-22.04-LTS

Dockerイメージの確認

$ docker images
REPOSITORY                                                      TAG          IMAGE ID       CREATED          SIZE
gitlab.linphone.org:4567/bc/public/linphone-sdk/bc-dev-ubuntu   22.04        6ee9dee48674   47 minutes ago   2.28GB

任意のフォルダ(Linphoneまたはflexisipをビルドするフォルダ)内で上記イメージによるコンテナを起動

$ docker run --name linphone-sdk -v $PWD:/home/bc -it gitlab.linphone.org:4567/bc/public/linphone-sdk/bc-dev-ubuntu:22.04
bc@616cdfa4bb84:~$

Linphone-Desktopのビルド

ホストマシンの環境に依存しないAppImageフォーマットでアプリを作成します。

Linphone-SDKコンテナの起動

上記投稿記事のイメージからコンテナを起動します。FUSE を使用するための管理者権限オプションを付与する必要があります。

$ docker run --device /dev/fuse --cap-add SYS_ADMIN --security-opt apparmor:unconfined --name linphone-sdk -v $PWD:/home/bc -it gitlab.linphone.org:4567/bc/public/linphone-sdk/bc-dev-ubuntu:22.04

linphone-sdk コンテナ内で以下のコマンドを実行

$ pip install pystache six
$ eval "$(qtchooser -print-env)"
$ export Qt5_DIR=${QTLIBDIR}/cmake/Qt5
$ export PATH=${QTTOOLDIR}:$PATH

ビルドに必要な追加パッケージをインストール

$ sudo apt install wget fuse libfuse2
$ sudo apt install qml-module-qt-labs-folderlistmodel qml-module-qt-labs-platform qml-module-qt-labs-settings qml-module-qtgraphicaleffects qml-module-qtqml qml-module-qtqml-models2 qml-module-qtquick-controls qml-module-qtquick-controls2 qml-module-qtquick-dialogs qml-module-qtquick-layouts qml-module-qtquick-privatewidgets qml-module-qtquick-shapes qml-module-qtquick-templates2 qml-module-qtquick-window2 qml-module-qtquick2

qml-module については、以下のLinphone Desktop バグレポートも参照して下さい。
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=978108

Qtドキュメント
https://doc.qt.io/

QML Modules
QML Modules | Qt QML 5.15.12

Qt Product Map

Qtオープンソース

ターミナルまたはスクリプトによりインストール

$ sudo apt install -y qtcreator qtbase5-dev qt5-qmake cmake

ソースのダウンロード・Makeファイルの作成・ビルド

AppImageパッケージを出力するため -DENABLE_APP_PACKAGING=YES を指定

$ git clone https://gitlab.linphone.org/BC/public/linphone-desktop.git --recursive
$ cd linphone-desktop
$ mkdir build
$ cd build
$ cmake .. -DENABLE_APP_PACKAGING=YES -DCMAKE_BUILD_PARALLEL_LEVEL=10 -DCMAKE_BUILD_TYPE=RelWithDebInfo
$ cmake --build . --target install --parallel 10 --config RelWithDebInfo

以下のディレクトリ・ファイル名でAppImageが作成されます。
実行権は付与されているので、これを任意の場所へ移動してダブルクリックして起動します。
build/OUTPUT/Packages/Linphone-5.1.0-alpha.40+e198f5f7.AppImage

シェルから起動することで各種ログを確認することが出来ます。

$ ./Linphone-5.1.0-alpha.40+e198f5f7.AppImage

Flexisipのビルド・DEBパッケージの作成

引き続き linphone-sdk コンテナを利用します。
初めにコンテナ内で flexisip のソースと関連パッケージをダウンロードします。

$ git clone https://gitlab.linphone.org/BC/public/flexisip.git --recursive

次に flexisip のビルドに必要なパッケージを、以下ファイルを参考に追加インストール・ビルドインストールします。

追加パッケージ

$ sudo apt install file llvm libboost-dev libboost-system-dev libboost-thread-dev libhiredis-dev libjsoncpp-dev mariadb-server libnghttp2-dev redis-server

追加ビルド・インストールパッケージ(スクリプトによりビルド・インストール)

$ cd flexisip/docker
$ sudo ./libnghttp2_asio_install.sh 1.43.0

上記の準備ができたら以下のフローで flexisip をビルドして下さい。

$ mkdir build
$ cd build
$ cmake .. -DCMAKE_INSTALL_PREFIX=/opt/belledonne-communications -DCMAKE_BUILD_TYPE=RelWithDebInfo -DSYSCONF_INSTALL_DIR=/etc -DCPACK_GENERATOR=DEB
$ make package

問題なければ以下2種類のパッケージが作成されます。

bc-flexisip_2.3.0-0.*_amd64.deb
bc-flexisip-dbgsym_2.3.0-0.*_amd64.ddeb


OS別flexisip公式レポジトリのインストール

CentOS, RockyLinux, Ubuntu, Debian対応。flexisipをビルドせずにレポジトリを登録し、新規にflexisipDockerイメージを作成する場合は以下を参照して下さい。

/etc/apt/sources.list.d/belledonne.list

# For Ubuntu 22.04 LTS
deb [arch=amd64] http://linphone.org/snapshots/ubuntu jammy stable # hotfix beta alpha
# For Ubuntu
$ wget https://www.linphone.org/snapshots/ubuntu/pubkey.gpg -O - | sudo apt-key add -
# Not doing this can result in the following error : "[SOCI] connection pool open error: Failed to find shared library for backend mysql"
$ sudo apt install libmariadb-dev
# Update & Install
$ sudo apt update
$ sudo apt install bc-flexisip

Flexisip Dockerイメージの作成

前記事で作成した flexisip のパッケージを利用して Flexisip Dockerイメージ を作成します。

deb,ddeb パッケージを以下のフォルダにコピーして作業します。

flex-from-deb を参考にUbuntu 22.04ベースのDockerfile flex-from-ubuntu-deb を作成しMakefileにビルドコマンドを追加します。(snmp-mibs-downloader snmp snmpd のインストールはオプション。SNMPによりflexisipの設定ファイル内の各セクションの設定事項の確認と書換えが行えます。)

flex-from-ubuntu-deb

FROM ubuntu:22.04
MAINTAINER  Takanobu Fuse <ficusonline@gmail.com>

# Prepare dependencies
RUN apt-get update
RUN apt-get install -y nano xsdcxx gdb libmariadb3 snmp-mibs-downloader snmp snmpd iproute2

# Get flexisip package
COPY *.deb *.ddeb deb-packages/
RUN apt-get install -y /deb-packages/*
RUN rm -rf /deb-packages

# Add it to the default path
ENV PATH=$PATH:/opt/belledonne-communications/bin

WORKDIR /opt/belledonne-communications

# Generate a default configuration
RUN flexisip --dump-default all > /etc/flexisip/flexisip.conf

VOLUME /etc/opt/belledonne-communications/flexisip
VOLUME /var/opt/belledonne-communications/log/flexisip
COPY flexisip-entrypoint.sh /
COPY backtrace.gdb /
RUN chmod a+x /flexisip-entrypoint.sh

# Script to wait db before launch flexisip [Licence Apache2]
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.2.1/wait /wait
RUN chmod +x /wait

ENTRYPOINT ["/flexisip-entrypoint.sh"]
CMD flexisip

Makefile 注)追加部分のみ記載

.....
.....

# For Ubuntu 22.04
flexisip-ubuntu-deb-before:
	$(eval DOCKER_FILE = flex-from-ubuntu-deb)
	# forcing context to .
	# at the moment of the condition above being executed, $DOCKER_FILE doesn't have the right value
	$(eval CONTEXT = .)
	$(eval DOCKER_TAG = $(DOCKER_TAG)-deb)

.....
.....
.....

# For Ubuntu 22.04
flexisip-ubuntu-deb-build: flexisip-ubuntu-deb-before flexisip-build

flexisip-ubuntu-deb-push: flexisip-ubuntu-deb-before flexisip-push

flexisip-ubuntu-deb-clean: flexisip-ubuntu-deb-before flexisip-clean

.....

ビルド
注)flexisip-entrypoint.sh"ulimit -c unlimited*" を修正。'*'を削除。

$ make flexisip-ubuntu-deb-build

イメージファイルの確認

$ docker images
REPOSITORY                                                      TAG                            IMAGE ID       CREATED       SIZE
gitlab.linphone.org:4567/bc/public/flexisip                     2.3.0-alpha-29-gb19a1ce5-deb   b3e1a47e3efd   9 hours ago   775MB

コンテナ起動
設定ファイルを定義していないため、このイメージから起動できるのはプロキシモードのみとなります。設定ファイル flexisip.conf を出力するためプロキシモードでコンテナを起動して下さい。

$ docker run -d --network host --name ubuntu-flexisip <IMAGE_ID> --server proxy
$ docker ps
CONTAINER ID   IMAGE          COMMAND                  CREATED       STATUS       PORTS     NAMES
0fd6f8e90621   b3e1a47e3efd   "/flexisip-entrypoin…"   9 hours ago   Up 9 hours             ubuntu-flexisip

ログ確認

$ docker logs ubuntu-flexisip
Flexisip docker params : flexisip --server proxy
--server param found, starting only one Flexisip instance

設定ファイル flexisip.conf をコピー

$ docker cp ubuntu-flexisip:/etc/flexisip/flexisip.conf ./

設定ファイル : flexisip.conf

グローバル設定

flexisip.confのセクションごとにポイントを纏めます。

[global]

user-errors-logs=true

transports=sip:ficus-home.duckdns.org:5060;maddr=172.16.0.6 sips:ficus-home.duckdns.org:5061;maddr=172.16.0.6

tls-certificates-file=/etc/letsencrypt/live/sip.example.com/fullchain.pem

tls-certificates-private-key=/etc/letsencrypt/live/sip.example.com/privkey.pem

tls-certificates-ca-file=/etc/letsencrypt/live/sip.example.com/cert.pem

[event-logs]

enabled=true

[presence-server]

rls-database-connection=db='flexisip_presence' user='flexisip' password='flexisip' host='flexisip-mariadb'

rls-database-max-thread=20

[conference-server]

conference-factory-uris=sip:conference-factory@ficus-home.duckdns.org

conference-focus-uris=

local-domains=ficus-home.duckdns.org

database-connection-string=db='flexisip_conference' user='flexisip' password='flexisip' host='flexisip-mariadb'

[regevent-server]

transport=sip:172.16.0.6:6065;transport=tcp

[b2bua-server] pending

#transport=sip:127.0.0.1:6067;transport=tcp

#outbound-proxy=sip:127.0.0.1:5060;transport=tcp

[b2bua-server::trenscrypter] pending

#outgoing-enc-regex=

#outgoing-srtp-regex=

[module::DoSProtection]

white-list=ficus-home.duckdns.org sip.linphone.org

[module::NatHelper]

# documentation here : https://wiki.linphone.org/xwiki/wiki/public/view/Flexisip/Configuration/Filter%20syntax/
# Default: 
filter=!(user-agent contains 'No NatHelper')

[module::Authentication]

enabled=true

#trusted-hosts=

auth-domains=ficus-home.duckdns.org localhost

available-algorithms=SHA-256 MD5

db-implementation=soci

soci-connection-string=db='flexisip' user='flexisip' password='flexisip' host='flexisip-mariadb'

soci-password-request=select passwords.password, passwords.algorithm from accounts inner join passwords on accounts.id=passwords.account_id where username = :id and domain = :domain

soci-poolsize=25

[module::RegEvent]

regevent-server=sip:172.16.0.6:6065;transport=tcp

[module::B2bua] pending

#enabled=false

# documentation here : https://wiki.linphone.org/xwiki/wiki/public/view/Flexisip/Configuration/Filter%20syntax/
#filter=

# A sip uri where to send all the relevent requests.
# Default: sip:127.0.0.1:6067;transport=tcp
#b2bua-server=sip:127.0.0.1:6067;transport=tcp

[module::Presence] pending

enabled=true

# A SIP URI where to send all presence related requests.
# Default: sip:127.0.0.1:5065;transport=tcp
#presence-server=sip:127.0.0.1:5065;transport=tcp

[module::Registrar]

reg-domains=ficus-home.duckdns.org localhost

db-implementation=redis

redis-server-domain=redis
 
redis-auth-password=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

[module::Router] pending

#message-database-enabled=false

#message-database-backend=mysql

#message-database-connection-string=db='mydb' user='myuser' password='mypass' host='myhost.com'

[module::MediaRelay]

# The minimal value of SDP port range
# Default: 1024
sdp-port-range-min=10000

# The maximal value of SDP port range
# Default: 65535
sdp-port-range-max=10050

[module::Forward]

route=<sip:172.16.0.6;transport=tcp>

ワンドメインでの設定ファイル例


SOCI

Supported Backends and Features

Features - SOCI (master)

Follow the links to learn more about each backend and detailed supported features.

Oracle PostgreSQL MySQL SQLite3 Firebird ODBC DB2
Binding by Name YES YES (≥8.0) YES YES YES YES YES
Dynamic Binding YES YES YES YES YES YES
Bulk Operations YES YES YES YES YES YES YES
Transactions YES YES YES (≥4.0) YES YES YES YES
BLOB Data Type YES YES YES (mapped to std::string) YES YES NO NO
RowID Data Type YES YES NO NO NO NO NO
Nested Statements YES NO NO NO NO NO YES
Stored Procedures YES YES NO (but stored functions, YES) NO YES NO YES

SNMP (Simple Network Management Protocol)

flexisipの設定ファイルでsnmpを有効にした場合、snmpコマンドによりflexisipの設定事項の確認と書換えが行えます。必要なパッケージは snmp-mibs-downloader, snmp, snmpd の3つです。

注) 特に必要なければ、このオプションは無効のままで構いません。念の為、FlexisipDockerイメージ作成時に上記パッケージを予めインストールしておきましょう。

下記flexisipsnmpを参考に snmpd.conf に必要な項目を追加・変更します。

追加・変更項目

agentAddress  udp:127.0.0.1:161
master agentx
agentXPerms  0660 0550 root root
rocommunity public localhost
rwcommunity private localhost

/etc/snmp/snmpd.conf

###########################################################################
#
# snmpd.conf
# An example configuration file for configuring the Net-SNMP agent ('snmpd')
# See snmpd.conf(5) man page for details
#
###########################################################################
# SECTION: System Information Setup
#

# syslocation: The [typically physical] location of the system.
#   Note that setting this value here means that when trying to
#   perform an snmp SET operation to the sysLocation.0 variable will make
#   the agent return the "notWritable" error code.  IE, including
#   this token in the snmpd.conf file will disable write access to
#   the variable.
#   arguments:  location_string
sysLocation    Sitting on the Dock of the Bay
sysContact     Me <me@example.org>

# sysservices: The proper value for the sysServices object.
#   arguments:  sysservices_number
sysServices    72



###########################################################################
# SECTION: Agent Operating Mode
#
#   This section defines how the agent will operate when it
#   is running.

# master: Should the agent operate as a master agent or not.
#   Currently, the only supported master agent type for this token
#   is "agentx".
#   
#   arguments: (on|yes|agentx|all|off|no)

master  agentx
agentXPerms  0660 0550 root root
# agentaddress: The IP address and port number that the agent will listen on.
#   By default the agent listens to any and all traffic from any
#   interface on the default SNMP port (161).  This allows you to
#   specify which address, interface, transport type and port(s) that you
#   want the agent to listen on.  Multiple definitions of this token
#   are concatenated together (using ':'s).
#   arguments: [transport:]port[@interface/address],...

agentaddress  udp:127.0.0.1:161



###########################################################################
# SECTION: Access Control Setup
#
#   This section defines who is allowed to talk to your running
#   snmp agent.

# Views 
#   arguments viewname included [oid]

#  system + hrSystem groups only
view   systemonly  included   .1.3.6.1.2.1.1
view   systemonly  included   .1.3.6.1.2.1.25.1


# rocommunity: a SNMPv1/SNMPv2c read-only access community name
#   arguments:  community [default|hostname|network/bits] [oid | -V view]

# Read-only access to everyone to the systemonly view
rocommunity public localhost
rwcommunity private localhost

rocommunity  public default -V systemonly
rocommunity6 public default -V systemonly

# SNMPv3 doesn't use communities, but users with (optionally) an
# authentication and encryption string. This user needs to be created
# with what they can view with rouser/rwuser lines in this file.
#
# createUser username (MD5|SHA|SHA-512|SHA-384|SHA-256|SHA-224) authpassphrase [DES|AES] [privpassphrase]
# e.g.
# createuser authPrivUser SHA-512 myauthphrase AES myprivphrase
#
# This should be put into /var/lib/snmp/snmpd.conf 
#
# rouser: a SNMPv3 read-only access username
#    arguments: username [noauth|auth|priv [OID | -V VIEW [CONTEXT]]]
rouser authPrivUser authpriv -V systemonly

# include a all *.conf files in a directory
includeDir /etc/snmp/snmpd.conf.d

snmpデーモンの起動

# /etc/init.d/snmpd start

flexisipmibの作成

# mkdir -p ~/.snmp/mibs
# flexisip --dump-mibs > ~/.snmp/mibs/fleximib.txt

flexisipmib出力
注) flexisip.conf内でコメントアウトしているデフォルト項目が全てアンコメントになります。

# snmpwalk -m FLEXISIP-MIB  -v 2c -c public -Of localhost FLEXISIP-MIB::flexisipMIB
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.notif.msg.0 = ""
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.notif.source.0 = ""
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.global.runtimeError.0 = ""
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.global.versionNumber.0 = STRING: "2.3.0-alpha-29-gb19a1ce5"
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.global.dumpCorefiles.0 = INTEGER: false(0)
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.global.countIncomingResponse401.0 = Counter64: 0
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.global.countIncomingResponse603.0 = Counter64: 0
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.global.logDirectory.0 = STRING: "/var/opt/belledonne-communications/log/flexisip"
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.global.tlsCertificatesPrivateKey.0 = ""
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.global.countReply408.0 = Counter64: 0
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.global.maxLogSize.0 = STRING: "-1"
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.global.countReplyUnknown.0 = Counter64: 0
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.global.keepaliveInterval.0 = INTEGER: 1800
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.global.countIncomingRequestUnknown.0 = Counter64: 0
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.global.countReply101.0 = Counter64: 0
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.global.rtpBindAddress.0 = STRING: "0.0.0.0 ::0"
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.global.enableSnmp.0 = INTEGER: true(1)
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.global.syslogLevel.0 = STRING: "debug"
.......
.......
.......

上記の特定の項目のみ出力

# snmpget -m FLEXISIP-MIB -v 2c -c public -Of localhost FLEXISIP-MIB::flexisipMIB.flexisip.global.syslogLevel.0
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.global.syslogLevel.0 = STRING: "debug"

設定項目を変更(systemlogLeveldebugからerrorへ変更)

# snmpset -m FLEXISIP-MIB  -v 2c -c private localhost FLEXISIP-MIB::flexisipMIB.flexisip.global.syslogLevel.0 s "error"

YouTube SNMP Operation

Certbot DockerコンテナによるSSL認証手続き

flexisipによるシステム運用にはSSL(TLS)認証は不可欠です。Dockerコンテナにより事前に取得しておくことによりnginxflexisipの設定に反映させて下さい。以下の記事も参照願います。

Alternative 1: Docker
Get Certbot — Certbot 2.4.0 documentation

注) $PWDはコマンドを実行するディレクトリ

$ docker run -it --rm --name certbot -v "$PWD/letsencrypt:/etc/letsencrypt" -p 80:80 certbot/certbot certonly --standalone -d www.example.com

Setting up automated renewal
User Guide — Certbot 2.4.0 documentation

ホストマシンのクロンジョブに以下のCertbot Dockerコンテナによるrenewコマンドを追加
注) ディレクトリには絶対パスを指定すること。

$ docker run -it --rm --name certbot -v "/??/??/.../letsencrypt:/etc/letsencrypt" -p 80:80 certbot/certbot renew

証明書の期限は90日のため60日毎の更新手続きを推奨しています。

flexisip.conf での設定は以下のようにします。

tls-certificates-file=/etc/letsencrypt/live/sip.example.com/fullchain.pem
tls-certificates-private-key=/etc/letsencrypt/live/sip.example.com/privkey.pem
tls-certificates-ca-file=/etc/letsencrypt/live/sip.example.com/cert.pem

flexisip-account-managerの導入

flexisip-account-manage(以下 fam )のデザインは Laravel (PHPフレームワーク)によるものです。Docker Compose ファイルで使用するサービスの一つとして、専用のイメージをビルドするための Docker ファイル : php-fpm-alpine-laravel を作成します。

ComposerPHP機能拡張のインストールには、DockerHubのPHP公認ページが推奨している以下の docker-php-extension-installer を利用します。

php-fpm-alpine-laravel

FROM php:fpm-alpine

# Set working directory
WORKDIR /var/www/html  

# Install Composer and PHP extensions
RUN curl -sSLf \
        -o /usr/local/bin/install-php-extensions \
        https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \
    chmod +x /usr/local/bin/install-php-extensions && \
    install-php-extensions redis mysqli xmlrpc pdo_mysql @composer

# Installing Laravel
RUN chown -R www-data:www-data /var/www/html
RUN composer global require laravel/installer \
    && ln -s /root/.config/composer/vendor/laravel/installer/bin/laravel /usr/local/bin/laravel

ダウンロード:GitHub

Docker Composeファイル(IPv6対応)の作成

docker-compose.yml

version: '3.5'

services:
##### redis-server
  redis:
    container_name: redis
    image: redis:alpine
    volumes:
        - ./redis:/etc/redis
    # need to download default config file:redis.conf from https://redis.io/topics/config
    # then modify it to enable the auth access(password), and input it into /redis/etc directory.
    command: ["redis-server", "/etc/redis/redis.conf"]
    privileged: true
    restart: always
    networks: 
      proxy-tier:

##### nginx
  nginx:
    container_name: nginx
    image: nginx:alpine
    tty: true
    ports:
      - "80:80"
      - "443:443"
    volumes:
      # nginx config
      - ./nginx:/etc/nginx/conf.d
      # certbot letsencrypt certification. Created by docker_hub certbot/certbot
      # $ docker run -it --rm --name certbot -v "$PWD/letsencrypt:/etc/letsencrypt" -p 80:80 certbot/certbot certonly --standalone -d www.example.com
      # Add the below cronjob into the host crontab.
      # docker run -it --rm --name certbot -v "/??/??/.../letsencrypt:/etc/letsencrypt" -p 80:80 certbot/certbot renew
      - ./letsencrypt:/etc/letsencrypt
      # shared the directory /flexisip-account-manager in php-fpm-laravel container
      - ./flexisip-account-manager/flexiapi:/var/www/html/flexiapi
      - ./flexisip-account-manager/xmlrpc/src:/var/www/html/flexisip-account-manager
      # shared the directory /var/www/html in phpmysql-fpm container
      - phpmyadmin:/var/www/html/phpmyadmin
    restart: always
    networks: 
      proxy-tier:     

##### mariadb
  flexisip-mariadb:
    container_name: flexisip-mariadb
    image: mariadb
    restart: always
    volumes:
      - ./db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - MYSQL_DATABASE=${MYSQL_DATABASE}
      - MYSQL_USER=${MYSQL_USER}
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}
    networks: 
      proxy-tier:

### flexisip
  ubuntu-flexisip:
    container_name: ubuntu-flexisip
    image: gitlab.linphone.org:4567/bc/public/flexisip:2.3.0-alpha-29-gb19a1ce5-deb
    ports:
      - 5060-5061:5060-5061
      #### Presence-Server
      - 5065:5065
      #### Conference and RegEvent Server
      - 6064-6065:6064-6065
      - 10000-10050:10000-10050/udp
      #### STUN Server
      - 3478:3478/udp   
    volumes:
      - ./letsencrypt:/etc/letsencrypt
      # previously need to add "flexisip" directory and input "flexisip.conf" into it.
      - ./flexisip_conf:/etc/flexisip
      # for conference server linphone db directory
      - ./linphone:/root/.local/share/linphone
    depends_on:
      - redis
      - nginx
      - flexisip-mariadb
    restart: always
    # https://github.com/BelledonneCommunications/flexisip/blob/master/docker/flexisip-entrypoint.sh
    # for starting only "proxy" server
    #command: ["--server","proxy"]
    # for starting "proxy, presence, conference" servers
    command: [""]
    networks: 
      proxy-tier:
    cap_add:
      - NET_ADMIN
      - SYS_RESOURCE
    devices:
      - "/dev/snd:/dev/snd"
    
##### phpmyadmin-fpm
  phpmyadmin-fpm:
    container_name: phpmyadmin-fpm
    image: phpmyadmin/phpmyadmin:fpm-alpine
    tty: true
    expose: 
      - "9000"
    environment:
      - PMA_HOST=flexisip-mariadb
      - PMA_PORT=3306
      - PMA_ABSOLUTE_URI=http://localhost/phpmyadmin
    volumes:
      - phpmyadmin:/var/www/html
      - /sessions
    depends_on:
      - flexisip-mariadb
    restart: always
    networks: 
      proxy-tier:
        
##### php-fpm-laravel
  php-fpm-laravel:
    container_name: php-fpm-laravel
    build: 
      context: ./docker_files
      dockerfile: php-fpm-alpine-laravel      
    tty: true
    expose: 
      - "9000"
    # "php artisan serve" commmand default port
    ports:
      - 8000:8000
    volumes:
      # for laravel php framework
      - ./flexisip-account-manager/flexiapi:/var/www/html/flexiapi
      - ./flexisip-account-manager/xmlrpc/src:/var/www/html/flexisip-account-manager
      - ./flexisip-account-manager/conf:/etc/flexisip-account-manager
      # provisioning config
      - ./xmlrpc:/opt/belledonne-communications/share/flexisip-account-manager/xmlrpc
      # Flexisip-account-manager log
      - ./log:/var/opt/belledonne-communications/log
    depends_on:
      - ubuntu-flexisip
    restart: always
    networks: 
      proxy-tier:

networks:
  proxy-tier:
    name: containers-network-ipv6
    external: true

### $ docker volume create phpmyadmin  
volumes:
  phpmyadmin:
    external: true

備 考)

  • Dockerネットワークとphpmyadminボリュームは予め作成すること。

    ブリッジネットワーク

    $ docker network create --gateway 172.xx.0.1 --gateway fdxx:xxxx:xxxx:1::1 --subnet 172.xx.0.0/24 -- subnet fdxx:xxxx:xxxx:1::0/80 --ipv6 containers-network-ipv6
    

    ボリュームの作成

    $ docker volume create phpmyadmin
    
  • redis設定ファイルは上記記述したサイトからダウンロードして下さい。
    bindにはコンテナに割当てられるIPも追加してください。

    bind 127.0.0.1 172.xx.xx.xx ::1 fdxx:xxxx:xxxx:1::xx
    
  • flexisipcommand: [""]proxyサーバだけを起動する場合には command: ["--server", "proxy"] とします。指定しない場合には、proxy, presence. conference の3サーバが同時に起動します。

  • TLS認証はCerbotコンテナでflexisipを起動する前に行います。

    $ docker run -it --rm --name certbot -v "$PWD/letsencrypt:/etc/letsencrypt" -p 80:80 certbot/certbot certonly --standalone -d www.example.com
    

    更新する際もCertbotコンテナを利用しますが、ホストマシンのクローンジョブに以下のコマンドを登録する必要があります。

    $ docker run -it --rm --name certbot -v "/??/??/.../letsencrypt:/etc/letsencrypt" -p 80:80 certbot/certbot renew
    

エラー対応

conferenceサーバ起動時のエラーログ

2023-03-26 02:42:39:281 liblinphone-error-Could not find a suitable soundcard with capabilities : 2
2023-03-26 02:42:39:281 liblinphone-error-Could not find a suitable soundcard with capabilities : 2
2023-03-26 02:42:39:281 liblinphone-error-Could not find a suitable soundcard with capabilities : 1
2023-03-26 02:42:39:281 liblinphone-error-Could not find a suitable soundcard with capabilities : 2
2023-03-26 02:42:39:328 bctbx-error-bctbx_file_open: Error open No such file or directory
2023-03-26 02:42:39:328 liblinphone-error-Error in the opening zrtp_cache_db_file(/root/.local/share/linphone/zrtp-secrets.db): unable to open database file.

① ハードウェア(サウンドカード)認識エラー

liblinphone-error-Could not find a suitable soundcard with capabilities

Docker Composeファイルにデバイスオプション追加—>検証中

devices:
      - "/dev/snd:/dev/snd"

sqlite3データベース作成エラー

bctbx-error-bctbx_file_open: Error open No such file or directory
liblinphone-error-Error in the opening zrtp_cache_db_file(/root/.local/share/linphone/zrtp-secrets.db): unable to open database file.

以下参照し、新規にディレクトリを作成

イメージ作成時に以下のコマンドを追加。

# mkdir -p /root/.local/share/linphone

またはDocker Composeファイルにボリューム追加。

Volumes:
  # for conference server linphone db directory
  - ./linphone:/root/.local/share/linphone