forked from signalwire/freeswitch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase-image-from-source.Dockerfile
More file actions
167 lines (131 loc) · 5.18 KB
/
Copy pathbase-image-from-source.Dockerfile
File metadata and controls
167 lines (131 loc) · 5.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# Dockerfile for building Debian base-image with FreeSWITCH dependencies (sources)
# Available build arguments:
# BUILD_NUMBER - Package build number (default: 42)
# LIBBROADVOICE_REF - Git ref for libbroadvoice (default: HEAD)
# LIBILBC_REF - Git ref for libilbc (default: HEAD)
# LIBSILK_REF - Git ref for libsilk (default: HEAD)
# SPANDSP_REF - Git ref for spandsp (default: HEAD)
# SOFIASIP_REF - Git ref for sofia-sip (default: HEAD)
# LIBKS_REF - Git ref for libks (default: HEAD)
# SIGNALWIRE_C_REF - Git ref for signalwire-c (default: HEAD)
# LIBV8_PACKAGING_REF - Git ref for libv8-packaging (default: HEAD)
#
# Build the image:
# docker build -t fs-base-image -f docker/build/base-image-from-source.Dockerfile .
#
# Build with specific tags:
# docker build -t fs-base-image \
# --build-arg LIBKS_REF=v1.0.0 \
# --build-arg BUILD_NUMBER=123 \
# -f docker/build/base-image-from-source.Dockerfile .
#
# Run the container with output directory mounted to host:
# mkdir -p "$HOME/DEBs"
# docker run -it --rm -v "$HOME/DEBs:/var/local/deb" -v "$(pwd):/usr/local/src/freeswitch" fs-base-image scripts/packaging/build/fsdeb.sh -b 42 -o /var/local/deb
# Stage 1: Build dependencies layer
FROM debian:bookworm AS builder
# Set bash as the default shell
SHELL ["/bin/bash", "-c"]
# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive
ENV OUTPUT_DIR="/var/local/deb"
# Define build arguments with default
ARG BUILD_NUMBER=42
# Define tag arguments with defaults to HEAD
ARG LIBBROADVOICE_REF=HEAD
ARG LIBILBC_REF=HEAD
ARG LIBSILK_REF=HEAD
ARG SPANDSP_REF=HEAD
ARG SOFIASIP_REF=HEAD
ARG LIBKS_REF=HEAD
ARG SIGNALWIRE_C_REF=HEAD
ARG LIBV8_PACKAGING_REF=HEAD
# Install minimal requirements
RUN apt-get update && apt-get install -y \
git \
lsb-release
# Configure git to trust all directories
RUN git config --global --add safe.directory '*'
# Set base dir for cloned repositories
WORKDIR /usr/src
# Clone libbroadvoice
RUN [ -d "libbroadvoice" ] || (git clone https://github.com/freeswitch/libbroadvoice.git && \
cd libbroadvoice && git checkout $LIBBROADVOICE_REF)
# Clone libilbc
RUN [ -d "libilbc" ] || (git clone https://github.com/freeswitch/libilbc.git && \
cd libilbc && git checkout $LIBILBC_REF)
# Clone libsilk
RUN [ -d "libsilk" ] || (git clone https://github.com/freeswitch/libsilk.git && \
cd libsilk && git checkout $LIBSILK_REF)
# Clone spandsp (packages branch)
RUN [ -d "spandsp" ] || (git clone --branch packages https://github.com/freeswitch/spandsp.git && \
cd spandsp && git checkout $SPANDSP_REF)
# Clone sofia-sip
RUN [ -d "sofia-sip" ] || (git clone https://github.com/freeswitch/sofia-sip.git && \
cd sofia-sip && git checkout $SOFIASIP_REF)
# Clone libks
RUN [ -d "libks" ] || (git clone https://github.com/signalwire/libks.git && \
cd libks && git checkout $LIBKS_REF)
# Clone signalwire-c
RUN [ -d "signalwire-c" ] || (git clone https://github.com/signalwire/signalwire-c.git && \
cd signalwire-c && git checkout $SIGNALWIRE_C_REF)
# Clone libv8-packaging
RUN [ -d "libv8-packaging" ] || (git clone https://github.com/freeswitch/libv8-packaging.git && \
cd libv8-packaging && git checkout $LIBV8_PACKAGING_REF)
# Copy the build dependencies script
COPY scripts/packaging/build/dependencies/build-dependencies.sh /usr/local/bin/build-dependencies.sh
RUN chmod +x /usr/local/bin/build-dependencies.sh
# Create directories
RUN mkdir -p "${OUTPUT_DIR}" /usr/src/freeswitch
# Copy FreeSWITCH source tree
COPY . /usr/src/freeswitch
# Build the dependency packages
RUN /usr/local/bin/build-dependencies.sh -b "$BUILD_NUMBER" -o "$OUTPUT_DIR" -p "/usr/src" -s -a -r
# Stage 2: Install packages layer
FROM debian:bookworm AS installer
# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive
WORKDIR /root
# Copy only the DEB files from builder stage
COPY --from=builder /var/local/deb/*.deb /tmp/debs/
# Install required tools for setting up local repo
RUN apt-get update && \
apt-get install -y --no-install-recommends \
apt-utils \
dpkg-dev \
gnupg \
ca-certificates \
lsb-release \
procps \
locales
# Create local repository directory
RUN mkdir -p /var/local/repo && \
cp /tmp/debs/*.deb /var/local/repo/
# Generate package index
RUN cd /var/local/repo && \
dpkg-scanpackages . > Packages && \
gzip -9c Packages > Packages.gz
# Configure local repository
RUN echo "deb [trusted=yes] file:/var/local/repo ./" > /etc/apt/sources.list.d/local.list && \
apt-get update
# Install all available packages from local repo
RUN ls -1 /var/local/repo/*.deb | sed -e 's|.*/||' -e 's|_.*||' | grep -Pv "\-dbgsym$" | xargs apt-get install -y --allow-downgrades -f
# Clean up
RUN apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/debs && \
rm -rf /var/local/repo && \
rm -f /etc/apt/sources.list.d/local.list
# Set locale
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
locale-gen
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
# Stage 3: Final image
FROM debian:bookworm
# Copy everything from the installer stage
COPY --from=installer / /
# Set working directory
WORKDIR /usr/local/src/freeswitch
# Set command to bash directly
SHELL ["/bin/bash", "-c"]