Skip to content

Commit

Permalink
Merge pull request #208 from hecko/python3-rhel7
Browse files Browse the repository at this point in the history
Port to Python3 and add Dockerfile for supported platforms.
  • Loading branch information
juha-h authored Dec 4, 2024
2 parents b0cd42b + d759fa7 commit 8a6cf80
Show file tree
Hide file tree
Showing 35 changed files with 648 additions and 352 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Build docker images

on:
push:
branches:
- '**'

jobs:
images_test_build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Build image based on RHEL7
run: docker build -t sems -f Dockerfile-rhel7 .

- name: Build image based on RHEL8
run: docker build -t sems -f Dockerfile-rhel8 .

- name: Build image based on RHEL9
run: docker build -t sems -f Dockerfile-rhel9 .

- name: Build image based on Debian 11
run: docker build -t sems -f Dockerfile-debian11 .

- name: Build image based on Debian 12
run: docker build -t sems -f Dockerfile-debian12 .
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ apps/py_sems/sip/*.cpp
apps/py_sems/sip/*.h
apps/py_sems/sip/Makefile.gen
apps/rtmp/flash_phone/*.swf
apps/rtmp/librtmp/librtmp.so.0
apps/xmlrpc2di/xmlrpc++/src/Makefile
build/
cmake_install.cmake
Expand Down
21 changes: 21 additions & 0 deletions Dockerfile-debian11
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM debian:11

RUN apt update
RUN apt install -y \
git debhelper g++ make libspandsp-dev flite1-dev \
libspeex-dev libgsm1-dev libopus-dev libssl-dev python3-dev \
python3.9-dev \
python3-sip-dev openssl libev-dev libmysqlcppconn-dev libevent-dev \
libxml2-dev libcurl4-openssl-dev libhiredis-dev

WORKDIR /

RUN git clone --depth 1 --branch python3-rhel7 https://github.com/hecko/sems.git

WORKDIR /sems

RUN USE_SPANDSP=1 make
RUN USE_SPANDSP=1 make install

# Run SEMS with the specified configuration
CMD ["/usr/local/sbin/sems", "-E", "-f", "/usr/local/etc/sems/sems.conf"]
21 changes: 21 additions & 0 deletions Dockerfile-debian12
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM debian:12

RUN apt update
RUN apt install -y \
git debhelper g++ make libspandsp-dev flite1-dev \
libspeex-dev libgsm1-dev libopus-dev libssl-dev python3-dev \
python3.11-dev \
python3-sip-dev openssl libev-dev libmysqlcppconn-dev libevent-dev \
libxml2-dev libcurl4-openssl-dev libhiredis-dev

WORKDIR /

RUN git clone --depth 1 --branch python3-rhel7 https://github.com/hecko/sems.git

WORKDIR /sems

RUN USE_SPANDSP=1 make
RUN USE_SPANDSP=1 make install

# Run SEMS with the specified configuration
CMD ["/usr/local/sbin/sems", "-E", "-f", "/usr/local/etc/sems/sems.conf"]
42 changes: 42 additions & 0 deletions Dockerfile-rhel7
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM centos:7

RUN cat /etc/yum.repos.d/CentOS-Base.repo
RUN sed -i '/^mirrorlist=/d; s/^#baseurl=/baseurl=/' /etc/yum.repos.d/*.repo
#RUN find /etc/yum.repos.d/CentOS-*.repo -type f -exec sed -i 's/mirrorlist\.centos\.org/vault\.centos\.org/g' {} +
RUN find /etc/yum.repos.d/CentOS-*.repo -type f -exec sed -i 's/mirror\.centos\.org/vault\.centos\.org/g' {} +
RUN cat /etc/yum.repos.d/CentOS-Base.repo
RUN yum -y update

RUN yum install -y epel-release \
&& yum install -y https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm \
&& yum install -y \
git \
make \
gcc-c++ \
libevent-devel \
gsm-devel \
opus-devel \
speex-devel \
openssl-devel \
python3-devel \
python3.6-devel \
hiredis-devel \
zlib-devel \
libcurl-devel \
spandsp-devel \
mysql-connector-c++ \
python3-mysqlclient --nogpgcheck \
&& ln -s /usr/lib64/libmysqlcppconn8.so.2 /usr/lib64/libmysqlcppconn.so

WORKDIR /

RUN git clone --depth 1 --branch python3-rhel7 https://github.com/hecko/sems.git

WORKDIR /sems

RUN ln -s /usr/lib64/libpython3.6m.so /usr/lib64/libpython3.6.so
RUN USE_SPANDSP=1 make
RUN USE_SPANDSP=1 make install

# Run SEMS with the specified configuration
CMD ["/usr/local/sbin/sems", "-E", "-f", "/usr/local/etc/sems/sems.conf"]
37 changes: 37 additions & 0 deletions Dockerfile-rhel8
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM almalinux:8

RUN yum -y update

RUN yum install -y epel-release \
&& dnf config-manager --set-enabled powertools \
&& yum install -y https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm \
&& yum install -y \
git \
make \
gcc-c++ \
libevent-devel \
gsm-devel \
opus-devel \
speex-devel \
openssl-devel \
python36-devel \
hiredis-devel \
zlib-devel \
libcurl-devel \
spandsp-devel \
mysql-connector-c++ \
python3-mysqlclient --nogpgcheck \
&& ln -s /usr/lib64/libmysqlcppconn8.so.2 /usr/lib64/libmysqlcppconn.so

WORKDIR /

RUN git clone --depth 1 --branch python3-rhel7 https://github.com/hecko/sems.git

WORKDIR /sems

RUN ln -s /usr/lib64/libpython3.6m.so /usr/lib64/libpython3.6.so
RUN USE_SPANDSP=1 make
RUN USE_SPANDSP=1 make install

# Run SEMS with the specified configuration
CMD ["/usr/local/sbin/sems", "-E", "-f", "/usr/local/etc/sems/sems.conf"]
34 changes: 34 additions & 0 deletions Dockerfile-rhel9
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM almalinux:9

RUN yum install -y epel-release \
&& dnf config-manager --set-enabled crb \
&& dnf install -y https://dev.mysql.com/get/mysql80-community-release-el9-1.noarch.rpm \
&& dnf install -y \
git \
make \
gcc-c++ \
libevent-devel \
gsm-devel \
opus-devel \
speex-devel \
openssl-devel \
python3-devel \
hiredis-devel \
zlib-devel \
libcurl-devel \
spandsp-devel \
mysql-connector-c++ \
python3-mysqlclient --nogpgcheck \
&& ln -s /usr/lib64/libmysqlcppconn8.so.2 /usr/lib64/libmysqlcppconn.so

WORKDIR /

RUN git clone --depth 1 --branch python3-rhel7 https://github.com/hecko/sems.git

WORKDIR /sems

RUN USE_SPANDSP=1 make
RUN USE_SPANDSP=1 make install

# Run SEMS with the specified configuration
CMD ["/usr/local/sbin/sems", "-E", "-f", "/usr/local/etc/sems/sems.conf"]
21 changes: 19 additions & 2 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,25 @@ Requirements:

All requirements are optional.

o Python version >= 2.3 for the ivr (embedded python interpreter)
and py_sems
o Python for the ivr (embedded python interpreter) and py_sems
o flite speech synthesizer for TTS in the ivr
o lame >= 3.95 for mp3 file output, mpg123 for mp3 playback
o spandsp library for DTMF detection and PLC
(SEMS has its own implementations for both)
o libZRTP SDK (http://zfoneproject.com) for ZRTP
o libev for jsonrpc

Supported environments:

SEMS server hes been tested with the following:
* RHEL 7 with Python 3
* RHEL 8 with Python 3
* RHEL 9 with Python 3
* Debian 11 with Python 3
* Debian 12 with Python 3

Please see appropriate Dockerfiles

Creating packages on debian (ubuntu, ...):

install debian package build tools:
Expand Down Expand Up @@ -204,6 +214,13 @@ Creating packages on debian (ubuntu, ...):

install sems and sems-python-modules packages in .. using dpkg.

Build and run in container

# build
docker build -t sems-rhel8 -f Dockerfile-rhel8
# test-run in foreground
podman run --rm -it --name sems sems-rhel8

Installed files using 'make install':

/usr/local/sbin/sems : SEMS executable
Expand Down
2 changes: 2 additions & 0 deletions apps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ local_exclude_app_modules += jsonrpc
local_exclude_app_modules += mp3
local_exclude_app_modules += py_sems
local_exclude_app_modules += twit
# Not supported since RHEL6 or so:
local_exclude_app_modules += ivr-python2

include $(COREPATH)/../Makefile.defs

Expand Down
4 changes: 2 additions & 2 deletions apps/conf_auth/conf_auth.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from log import *
from ivr import *
import xmlrpclib
import xmlrpc


XMLRPC_PROTOCOL = 'http' # could e.g. be https
Expand Down Expand Up @@ -76,7 +76,7 @@ def onDtmf(self,key,duration):
self.flush()
if key == 10:

c = xmlrpclib.ServerProxy(server_path )
c = xmlrpc.client.ServerProxy(server_path )
erg = c.AuthorizeConference(self.dialog.remote_uri,
self.dialog.local_party, self.keys)

Expand Down
6 changes: 4 additions & 2 deletions apps/dsm/mods/mod_py/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
plug_in_name = mod_py

PYTHON_VERSION ?= $(shell python -c 'import sys;print sys.version[0:3]')
PYTHON_VERSION ?= $(shell (python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")' 2>/dev/null) || \
(python -c 'import sys; assert sys.version_info.major == 3; print(f"{sys.version_info.major}.{sys.version_info.minor}")' 2>/dev/null))

PY_VER = $(PYTHON_VERSION)
PY_EXE = python$(PY_VER)

Expand Down Expand Up @@ -36,4 +38,4 @@ ifneq ($(OS),macosx)
ifneq ($(OS),solaris)
PYTHON_module_ldflags += -Xlinker --export-dynamic
endif
endif
endif
Loading

0 comments on commit 8a6cf80

Please sign in to comment.