initial commit

This commit is contained in:
2025-03-18 10:59:32 -04:00
commit fed4d36f10
3 changed files with 110 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
config/
db/

92
Dockerfile Normal file
View File

@@ -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/<param name="listen-ip" value="::"\/>/<param name="listen-ip" value="127.0.0.1"\/>/' \
/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"]

16
entrypoint.sh Executable file
View File

@@ -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