t38modem Dockerfile
This commit is contained in:
parent
a5a8b2c3a2
commit
1a3c20b4cb
5 changed files with 122 additions and 0 deletions
2
docker/t38modem/.dockerignore
Normal file
2
docker/t38modem/.dockerignore
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
Dockerfile
|
||||||
|
docker-compose.yml
|
81
docker/t38modem/Dockerfile
Normal file
81
docker/t38modem/Dockerfile
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
ARG PTLIB_VERSION="2.18.6"
|
||||||
|
ARG PTLIB_VERSION_PATH="v3.18 Cygni/Stable 6/ptlib-2.18.6"
|
||||||
|
|
||||||
|
ARG OPAL_VERSION="3.18.6"
|
||||||
|
ARG OPAL_VERSION_PATH="v3.18 Cygni/Stable 6/opal-3.18.6"
|
||||||
|
|
||||||
|
ARG T38MODEM_VERSION="4.6.2"
|
||||||
|
|
||||||
|
FROM docker.io/debian:12.8-slim AS builder
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get upgrade -y \
|
||||||
|
&& apt-get install -y --no-install-recommends ca-certificates build-essential pkg-config wget libssl-dev libsrtp2-dev libspandsp-dev
|
||||||
|
|
||||||
|
WORKDIR /usr/src
|
||||||
|
RUN mkdir /opt/t38modem
|
||||||
|
ENV PKG_CONFIG_PATH=/opt/t38modem/lib/pkgconfig
|
||||||
|
ENV LD_LIBRARY_PATH=/opt/t38modem/lib
|
||||||
|
|
||||||
|
ARG PTLIB_VERSION
|
||||||
|
ARG PTLIB_VERSION_PATH
|
||||||
|
RUN wget -q -O- "https://sourceforge.net/projects/opalvoip/files/${PTLIB_VERSION_PATH}.tar.bz2" \
|
||||||
|
| tar xj \
|
||||||
|
&& cd "ptlib-${PTLIB_VERSION}" \
|
||||||
|
&& CPPFLAGS="-O3 -flto=auto" LDFLAGS="-O3 -flto=auto" ./configure --prefix=/opt/t38modem \
|
||||||
|
&& make -j$(nproc) \
|
||||||
|
&& make install \
|
||||||
|
&& rm -rf "/usr/src/ptlib-${PTLIB_VERSION}"
|
||||||
|
|
||||||
|
ARG OPAL_VERSION
|
||||||
|
ARG OPAL_VERSION_PATH
|
||||||
|
RUN wget -q -O- "https://sourceforge.net/projects/opalvoip/files/${OPAL_VERSION_PATH}.tar.bz2" \
|
||||||
|
| tar xj \
|
||||||
|
&& cd "opal-${OPAL_VERSION}" \
|
||||||
|
&& CPPFLAGS="-O3" ./configure --prefix=/opt/t38modem \
|
||||||
|
&& make -j$(nproc) \
|
||||||
|
&& make install \
|
||||||
|
&& rm -rf "/usr/src/opal-${OPAL_VERSION}"
|
||||||
|
|
||||||
|
ARG T38MODEM_VERSION
|
||||||
|
RUN wget -q -O- "https://github.com/hehol/t38modem/archive/refs/tags/${T38MODEM_VERSION}.tar.gz" \
|
||||||
|
| tar xz \
|
||||||
|
&& cd "t38modem-${T38MODEM_VERSION}" \
|
||||||
|
&& CPPFLAGS="-O3 -flto=auto -Wno-narrowing" LDFLAGS="-O3 -flto=auto" make \
|
||||||
|
&& mv t38modem /opt/t38modem/bin \
|
||||||
|
&& rm -rf "/usr/src/t38modem-${T38MODEM_VERSION}"
|
||||||
|
|
||||||
|
FROM docker.io/debian:12.8-slim AS runner
|
||||||
|
LABEL maintainer="dominic@dergrimm.net" \
|
||||||
|
org.opencontainers.image.title="t38modem" \
|
||||||
|
org.opencontainers.image.description="t38modem bridged over socat TCP" \
|
||||||
|
org.opencontainers.image.authors="Dominic Grimm" \
|
||||||
|
org.opencontainers.image.source="https://git.dergrimm.net/dergrimm/linux-fax-stack.git"
|
||||||
|
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get upgrade -y \
|
||||||
|
&& apt-get install -y ca-certificates socat libssl-dev libsrtp2-dev libspandsp-dev \
|
||||||
|
&& apt-get clean -y \
|
||||||
|
&& apt-get autoremove -y \
|
||||||
|
&& apt-get autoclean -y \
|
||||||
|
&& rm -rf /tmp/* \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
WORKDIR /usr/local/t38modem
|
||||||
|
COPY --from=builder /opt/t38modem/lib /usr/local/t38modem/lib
|
||||||
|
COPY --from=builder /opt/t38modem/bin/t38modem /usr/local/t38modem/bin/t38modem
|
||||||
|
COPY services services
|
||||||
|
COPY start.sh .
|
||||||
|
RUN chmod +x /usr/local/t38modem/services/t38modem.sh /usr/local/t38modem/services/socat.sh /usr/local/t38modem/start.sh
|
||||||
|
|
||||||
|
RUN rm -rf /tmp/*
|
||||||
|
|
||||||
|
ENV PATH="$PATH:/usr/local/t38modem/bin"
|
||||||
|
ENV PREFIX="/usr/local/t38modem"
|
||||||
|
ENV LD_LIBRARY_PATH="/usr/local/t38modem/lib"
|
||||||
|
ARG PTLIB_VERSION
|
||||||
|
ARG OPAL_VERSION
|
||||||
|
ENV PTLIBPLUGINDIR="/usr/local/t38modem/lib/ptlib-${PTLIB_VERSION}:/usr/local/t38modem/lib/opal-${OPAL_VERSION}"
|
||||||
|
|
||||||
|
ENTRYPOINT [ "/usr/local/t38modem/start.sh" ]
|
6
docker/t38modem/services/socat.sh
Normal file
6
docker/t38modem/services/socat.sh
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# $1: PTTY ID
|
||||||
|
# $2: TCP server port
|
||||||
|
|
||||||
|
socat -d -d "file:${1},raw,echo=0" "TCP-LISTEN:${2},reuseaddr"
|
22
docker/t38modem/services/t38modem.sh
Normal file
22
docker/t38modem/services/t38modem.sh
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
PTTY=$(seq -f "+${1}-%g" -s "," "${T38MODEM_MODEM_COUNT}")
|
||||||
|
|
||||||
|
CMD=(
|
||||||
|
"t38modem"
|
||||||
|
"--ptty" "${PTTY}"
|
||||||
|
"--sip-proxy" "${T38MODEM_SIP_USERNAME}:${T38MODEM_SIP_PASSWORD}@${T38MODEM_SIP_SERVER}"
|
||||||
|
"--sip-register" "${T38MODEM_SIP_USERNAME}@${T38MODEM_SIP_SERVER},${T38MODEM_SIP_PASSWORD}"
|
||||||
|
"--sip-listen" "udp\$:5060"
|
||||||
|
"--stun" "${T38MODEM_STUN_SERVER}"
|
||||||
|
"--route" "t38:.*=sip:<dn>@${T38MODEM_SIP_SERVER}"
|
||||||
|
"--route" "sip:.*=t38:<dn>"
|
||||||
|
)
|
||||||
|
|
||||||
|
if [ "$T38MODEM_DISABLE_T38" = true ]; then
|
||||||
|
cmd+=("--disable-t38-mode" "--audio")
|
||||||
|
fi
|
||||||
|
|
||||||
|
CMD+=("${T38MODEM_CMD_ARGS}")
|
||||||
|
|
||||||
|
exec "${CMD[@]}"
|
11
docker/t38modem/start.sh
Normal file
11
docker/t38modem/start.sh
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
exec "${PREFIX}/services/t38modem.sh" /dev/ttyT38 &
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
for i in $(seq "${T38MODEM_MODEM_COUNT}"); do
|
||||||
|
PORT="$(("${T38MODEM_START_PORT}" + i - 1))"
|
||||||
|
exec "${PREFIX}/services/socat.sh" "/dev/ttyT38-${i}" "${PORT}" &
|
||||||
|
done
|
||||||
|
|
||||||
|
wait
|
Loading…
Reference in a new issue