# 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 # Patch default FreeSwitch config (fix IPv4 bug) RUN sed -i 's///' \ /usr/local/freeswitch/conf/autoload_configs/event_socket.conf.xml # 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 # Copy entrypoint COPY ./entrypoint.sh /entrypoint.sh # Set PATH ENV PATH="$PATH:/usr/local/freeswitch/bin" # Expose ports # ref: https://developer.signalwire.com/freeswitch/FreeSWITCH-Explained/Networking/Firewall_1048908/ EXPOSE 1719/udp EXPOSE 1720/tcp EXPOSE 2855-2856/tcp EXPOSE 3478/udp EXPOSE 3479/udp EXPOSE 5002/udp EXPOSE 5003/udp EXPOSE 5060/tcp EXPOSE 5060/udp EXPOSE 5070/tcp EXPOSE 5070/udp EXPOSE 5080/tcp EXPOSE 5080/udp EXPOSE 8021/tcp EXPOSE 16384-32768/udp EXPOSE 5066/tcp EXPOSE 7443/tcp EXPOSE 8081-8082/tcp # Set working directory and command WORKDIR /usr/local/freeswitch ENTRYPOINT ["/entrypoint.sh"] #CMD ["/usr/local/freeswitch/bin/freeswitch"]