From c2d9456ef7141104ea4d22aed287d830a7874216 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Tue, 30 Dec 2025 12:02:23 +0200 Subject: [PATCH] Introduce docker build Source: https://github.com/audiocodes/docker-rtpengine. --- .dockerignore | 17 ++++++++ Dockerfile | 95 +++++++++++++++++++++++++++++++++++++++++++ docker/entrypoint.sh | 48 ++++++++++++++++++++++ docker/rtpengine.conf | 13 ++++++ 4 files changed, 173 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100755 docker/entrypoint.sh create mode 100644 docker/rtpengine.conf diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..f45198721 --- /dev/null +++ b/.dockerignore @@ -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.* diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..4fc0b842a --- /dev/null +++ b/Dockerfile @@ -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 . diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100755 index 000000000..a72286204 --- /dev/null +++ b/docker/entrypoint.sh @@ -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 "$@" diff --git a/docker/rtpengine.conf b/docker/rtpengine.conf new file mode 100644 index 000000000..b466be482 --- /dev/null +++ b/docker/rtpengine.conf @@ -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