Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Dockerfile
config.mk
daemon/rtpengine
docs/
lib/dtmf_rx_fillin.h
lib/fix_frame_channel_layout.h
lib/spandsp_logging.h
perf-tester/
recording-daemon/rtpengine-recording
t/
tests/
**/*.strhash.c
**/.*
**/*.8
**/*.o
**/core
**/core.*
95 changes: 95 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
FROM debian:trixie-slim AS build

RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
curl \
default-libmysqlclient-dev \
g++ \
gcc \
git \
gperf \
iproute2 \
iptables \
libavcodec-extra \
libavfilter-dev \
libcurl4-openssl-dev \
libevent-dev \
libhiredis-dev \
libiptc-dev \
libjson-glib-dev \
libjwt-dev \
libmnl-dev \
libncursesw5-dev \
libnftnl-dev \
libopus-dev \
libpcap-dev \
libpcre2-dev \
libspandsp-dev \
libssl-dev \
libwebsockets-dev \
make \
markdown \
patch

WORKDIR /usr/src/rtpengine
COPY . .

FROM build AS rtpengine
WORKDIR /usr/src/rtpengine/daemon
RUN make -j$(nproc) rtpengine && \
strip -o /usr/local/bin/rtpengine rtpengine

FROM build AS rtpengine-recording
WORKDIR /usr/src/rtpengine/recording-daemon
RUN make -j$(nproc) rtpengine-recording && \
strip -o /usr/local/bin/rtpengine-recording rtpengine-recording

FROM debian:trixie-slim

VOLUME ["/rec"]
ENTRYPOINT ["/entrypoint.sh"]
CMD ["rtpengine"]

EXPOSE 23000-65535/udp 22222/udp

RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
curl \
iproute2 \
iptables \
libglib2.0-0 \
libavcodec-extra \
libavfilter10 \
libcurl4 \
libevent-2.1-7 \
libevent-pthreads-2.1-7 \
libhiredis1.1.0 \
libip6tc2 \
libjson-glib-1.0-0 \
libjwt2 \
libmariadb3 \
libmnl0 \
libncursesw6 \
libnftnl11 \
libopus0 \
libpcap0.8 \
libpcre2-8-0 \
libspandsp2 \
libssl3 \
libwebsockets19 \
net-tools \
procps \
sudo \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

COPY --from=rtpengine /usr/local/bin/rtpengine /usr/local/bin/
COPY --from=rtpengine-recording /usr/local/bin/rtpengine-recording /usr/local/bin/
COPY docker/entrypoint.sh /entrypoint.sh
RUN echo '%sudo ALL=(ALL:ALL) NOPASSWD: ALL' > /etc/sudoers.d/nopasswd && \
groupadd --gid 1000 rtpengine && \
useradd --uid 1000 --gid rtpengine -G sudo --shell /bin/bash --create-home rtpengine
USER rtpengine
WORKDIR /home/rtpengine
COPY docker/rtpengine.conf .
48 changes: 48 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash
set -e

PATH=/usr/local/bin:$PATH

case $CLOUD in
gcp)
LOCAL_IP=$(curl -s -H "Metadata-Flavor: Google" http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/ip)
PUBLIC_IP=$(curl -s -H "Metadata-Flavor: Google" http://metadata/computeMetadata/v1/instance/network-interfaces/0/access-configs/0/external-ip)
;;
aws)
LOCAL_IP=$(curl -s http://169.254.169.254/latest/meta-data/local-ipv4)
PUBLIC_IP=$(curl -s http://169.254.169.254/latest/meta-data/public-ipv4)
;;
scaleway)
LOCAL_IP=$(curl -s --local-port 1-1024 http://169.254.42.42/conf | grep PRIVATE_IP | cut -d = -f 2)
PUBLIC_IP=$(curl -s --local-port 1-1024 http://169.254.42.42/conf | grep PUBLIC_IP_ADDRESS | cut -d = -f 2)
;;
digitalocean)
LOCAL_IP=$(curl -s http://169.254.169.254/metadata/v1/interfaces/private/0/ipv4/address)
PUBLIC_IP=$(curl -s http://169.254.169.254/metadata/v1/interfaces/public/0/ipv4/address)
;;
azure)
LOCAL_IP=$(curl -H Metadata:true "http://169.254.169.254/metadata/instance/network/interface/0/ipv4/ipAddress/0/privateIpAddress?api-version=2017-08-01&format=text")
PUBLIC_IP=$(curl -H Metadata:true "http://169.254.169.254/metadata/instance/network/interface/0/ipv4/ipAddress/0/publicIpAddress?api-version=2017-08-01&format=text")
;;
*)
;;
esac

if [ -n "$PUBLIC_IP" ]; then
MY_IP="$LOCAL_IP"!"$PUBLIC_IP"
elif [ -n "$LOCAL_IP" ]; then
MY_IP="$LOCAL_IP"
else
MY_IP=$(hostname -I | cut -f1 -d' ')
LOCAL_IP="$MY_IP"
fi

sed -i -e "s:\(interface=.*\)MY_IP:\1$MY_IP:g" rtpengine.conf
sed -i -e "s/MY_IP/$LOCAL_IP/g" rtpengine.conf

if [ "$1" = 'rtpengine' ]; then
shift
exec rtpengine --config-file rtpengine.conf "$@"
fi

exec "$@"
13 changes: 13 additions & 0 deletions docker/rtpengine.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[rtpengine]
interface=public/MY_IP
foreground=true
log-stderr=true
listen-ng=MY_IP:22222
port-min=23000
port-max=32768
recording-dir=/rec
recording-method=pcap
recording-format=eth
log-level=6
delete-delay=0
listen-http=MY_IP:8080