From fed4d36f10c43bb74935c3a0af5c7ff4d06e5e1e Mon Sep 17 00:00:00 2001 From: William P Date: Tue, 18 Mar 2025 10:59:32 -0400 Subject: [PATCH] initial commit --- .gitignore | 2 ++ Dockerfile | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++ entrypoint.sh | 16 +++++++++ 3 files changed, 110 insertions(+) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100755 entrypoint.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9c5f17c --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +config/ +db/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9aaa625 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,92 @@ +# Stage 1: Builder Stage +FROM ubuntu:22.04 AS builder + +# Install build dependencies +RUN apt-get -y update && \ + apt-get install --no-install-recommends --yes \ + build-essential pkg-config uuid-dev zlib1g-dev libjpeg-dev libsqlite3-dev \ + libcurl4-openssl-dev libpcre3-dev libspeexdsp-dev libldns-dev libedit-dev \ + libtiff5-dev yasm libopus-dev libsndfile1-dev unzip libavformat-dev \ + libswscale-dev liblua5.2-dev cmake libpq-dev unixodbc-dev autoconf \ + automake libxml2-dev git ca-certificates libtool wget && \ + rm -rf /var/lib/apt/lists/* + +WORKDIR /usr/local/src + +# Clone and build libks +RUN git clone https://github.com/signalwire/libks.git libks && \ + cd libks && \ + cmake . && \ + make -j$(nproc) && \ + make install + +# Clone and build signalwire-c +RUN git clone https://github.com/signalwire/signalwire-c.git signalwire-c && \ + cd signalwire-c && \ + cmake . && \ + make -j$(nproc) && \ + make install + +# Clone and build sofia-sip +RUN git clone https://github.com/freeswitch/sofia-sip.git sofia-sip && \ + cd sofia-sip && \ + ./bootstrap.sh && \ + ./configure && \ + make -j$(nproc) && \ + make install + +# Clone and build spandsp (with specific commit) +RUN git clone https://github.com/freeswitch/spandsp.git spandsp && \ + cd spandsp && \ + git checkout -b finecode20230705 0d2e6ac65e0e8f53d652665a743015a88bf048d4 && \ + ./bootstrap.sh && \ + ./configure && \ + make -j$(nproc) && \ + make install + +# Download and build FreeSwitch +RUN wget -c https://files.freeswitch.org/releases/freeswitch/freeswitch-1.10.12.-release.tar.gz -P /usr/local/src && \ + tar -zxvf freeswitch-1.10.12.-release.tar.gz && \ + cd freeswitch-1.10.12.-release && \ + ./configure && \ + make -j$(nproc) && \ + make install && \ + make cd-sounds-install && \ + make cd-moh-install + +# Stage 2: Runtime Stage +FROM ubuntu:22.04 + +# Install runtime dependencies only +RUN apt-get -y update && \ + apt-get install --no-install-recommends --yes \ + zlib1g libjpeg8 libsqlite3-0 libcurl4 libpcre3 libspeexdsp1 \ + libedit2 libtiff5 libopus0 libsndfile1 libavformat58 libswscale5 \ + liblua5.2-0 libpq5 unixodbc libxml2 ca-certificates ntpdate && \ + rm -rf /var/lib/apt/lists/* + +# Copy FreeSwitch and runtime libraries from builder +COPY --from=builder /usr/local/freeswitch /usr/local/freeswitch +COPY --from=builder /usr/local/lib/libks* /usr/local/lib/ +COPY --from=builder /usr/local/lib/libsignalwire* /usr/local/lib/ +COPY --from=builder /usr/local/lib/libsofia-sip* /usr/local/lib/ +COPY --from=builder /usr/local/lib/libspandsp* /usr/local/lib/ + +COPY --from=builder /usr/local/freeswitch/conf /usr/local/freeswitch/default-conf + +# Update linker cache +RUN ldconfig + +# Modify FreeSwitch config (same as your sed command) +RUN sed -i 's///' \ + /usr/local/freeswitch/conf/autoload_configs/event_socket.conf.xml + +# Copy entrypoint +COPY ./entrypoint.sh /entrypoint.sh +# Set PATH +ENV PATH="$PATH:/usr/local/freeswitch/bin" + +# Set working directory and command +WORKDIR /usr/local/freeswitch +ENTRYPOINT ["/entrypoint.sh"] +#CMD ["/usr/local/freeswitch/bin/freeswitch"] \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..038925a --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -e + +CONF_DIR="/usr/local/freeswitch/conf" +DEFAULT_CONF_DIR="/usr/local/freeswitch/default-conf" + +# Check if conf directory is empty or missing files +if [ -z "$(ls -A "$CONF_DIR" 2>/dev/null)" ]; then + echo "Configuration directory is empty. Copying default configuration..." + cp -r "$DEFAULT_CONF_DIR"/* "$CONF_DIR"/ +else + echo "Configuration directory is already populated. Skipping copy." +fi + +# Execute the main process +exec /usr/local/freeswitch/bin/freeswitch