Build PJSIP from source with multi-stage build (v2.0.2)
This commit is contained in:
@@ -1,24 +1,74 @@
|
|||||||
ARG BUILD_FROM
|
ARG BUILD_FROM
|
||||||
|
FROM $BUILD_FROM as builder
|
||||||
|
|
||||||
|
# Install build dependencies
|
||||||
|
RUN apk add --no-cache \
|
||||||
|
git \
|
||||||
|
build-base \
|
||||||
|
python3-dev \
|
||||||
|
linux-headers \
|
||||||
|
openssl-dev \
|
||||||
|
alsa-lib-dev \
|
||||||
|
opus-dev \
|
||||||
|
speex-dev \
|
||||||
|
speexdsp-dev \
|
||||||
|
py3-pip
|
||||||
|
|
||||||
|
# Build PJSIP
|
||||||
|
WORKDIR /tmp
|
||||||
|
RUN git clone --depth 1 --branch 2.14.1 https://github.com/pjsip/pjproject.git && \
|
||||||
|
cd pjproject && \
|
||||||
|
./configure \
|
||||||
|
--prefix=/opt/pjsip \
|
||||||
|
--enable-shared \
|
||||||
|
--disable-video \
|
||||||
|
--disable-opencore-amr \
|
||||||
|
--disable-silk \
|
||||||
|
--disable-opus \
|
||||||
|
--disable-resample \
|
||||||
|
--disable-speex-aec \
|
||||||
|
--disable-g711-codec \
|
||||||
|
--disable-l16-codec \
|
||||||
|
--disable-g722-codec && \
|
||||||
|
make dep && \
|
||||||
|
make && \
|
||||||
|
make install && \
|
||||||
|
cd pjsip-apps/src/python && \
|
||||||
|
python3 setup.py build && \
|
||||||
|
python3 setup.py install --prefix=/opt/pjsip
|
||||||
|
|
||||||
|
# Final stage
|
||||||
FROM $BUILD_FROM
|
FROM $BUILD_FROM
|
||||||
|
|
||||||
# Install system dependencies
|
# Install runtime dependencies only
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
python3 \
|
python3 \
|
||||||
py3-pip \
|
py3-pip \
|
||||||
py3-pjsua2 \
|
|
||||||
ffmpeg \
|
ffmpeg \
|
||||||
alsa-lib
|
alsa-lib \
|
||||||
|
openssl \
|
||||||
|
opus \
|
||||||
|
speex \
|
||||||
|
speexdsp
|
||||||
|
|
||||||
|
# Copy PJSIP from builder
|
||||||
|
COPY --from=builder /opt/pjsip /usr/local
|
||||||
|
COPY --from=builder /usr/lib/python3.*/site-packages/pjsua2* /usr/lib/python3.11/site-packages/
|
||||||
|
|
||||||
|
# Update library cache
|
||||||
|
RUN ldconfig /usr/local/lib || true
|
||||||
|
|
||||||
# Set working directory
|
# Set working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy requirements and install Python dependencies
|
# Copy requirements and install Python dependencies
|
||||||
COPY requirements.txt .
|
COPY requirements.txt .
|
||||||
RUN pip3 install --no-cache-dir -r requirements.txt
|
RUN pip3 install --no-cache-dir --break-system-packages -r requirements.txt
|
||||||
|
|
||||||
# Copy application files
|
# Copy application files
|
||||||
COPY run.sh .
|
COPY run.sh .
|
||||||
COPY sip_service.py .
|
COPY sip_service.py .
|
||||||
|
COPY services.yaml .
|
||||||
|
|
||||||
RUN chmod +x /app/run.sh
|
RUN chmod +x /app/run.sh
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user