-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Dockerfile
299 lines (275 loc) · 10.7 KB
/
Dockerfile
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# https://github.com/hassio-addons/addon-debian-base/releases
FROM ghcr.io/hassio-addons/debian-base:7.3.3 AS base
SHELL [ "/bin/bash", "-euxo", "pipefail", "-c" ]
# https://github.com/PhracturedBlue/asterisk_mbox_server/commits/master
ARG ASTERISK_MBOX_SERVER_VERSION="99038a4aa69d30b1deaf7895a868d68f47a3acba"
RUN export DEBIAN_FRONTEND=noninteractive; \
apt-get update; \
apt-get install -y --no-install-recommends --no-install-suggests \
gcc \
g++ \
libc6-dev \
python3-dev \
libbinutils \
file \
ca-certificates \
curl \
libcurl4 \
libedit2 \
libgsm1 \
libogg0 \
libopus0 \
libopusfile0 \
libpopt0 \
libresample1 \
libspandsp2 \
libspeex1 \
libspeexdsp1 \
libsqlite3-0 \
libsrtp2-1 \
libssl3 \
libvorbis0a \
libvorbisenc2 \
libvorbisfile3 \
libxml2 \
libxslt1.1 \
libncurses5 ncurses-bin ncurses-term \
# for res_resolver_unbound \
libunbound8 \
procps \
python3-pip \
rsync \
sipgrep \
tcpdump \
uuid \
xmlstarlet \
php \
php-cli \
# for googletts \
perl \
libwww-perl \
liblwp-protocol-https-perl \
sox \
mpg123 \
# for speech-recog \
libjson-perl \
libio-socket-ssl-perl \
flac \
# for downloading additional sounds \
unzip \
# for asterisk_mbox_server \
lame; \
\
pip3 install --no-cache-dir --break-system-packages https://github.com/PhracturedBlue/asterisk_mbox_server/archive/${ASTERISK_MBOX_SERVER_VERSION}.tar.gz; \
\
# Dependencies only used to build asterisk_mbox_server \
apt-get purge -y --auto-remove gcc g++ libc6-dev python3-dev; \
\
rm -rf /var/lib/apt/lists/*
FROM base AS build
# Install dependencies
RUN export DEBIAN_FRONTEND=noninteractive; \
apt-get update; \
apt-get install -y --no-install-recommends --no-install-suggests \
autoconf \
automake \
build-essential \
binutils-dev \
libcurl4-openssl-dev \
libedit-dev \
libgsm1-dev \
libogg-dev \
libopus-dev \
libopusfile-dev \
libpopt-dev \
libresample1-dev \
libspandsp-dev \
libspeex-dev \
libspeexdsp-dev \
libsqlite3-dev \
libsrtp2-dev \
libssl-dev \
# for res_resolver_unbound \
libunbound-dev \
libvorbis-dev \
libxml2-dev \
libxslt1-dev \
procps \
subversion \
uuid-dev; \
rm -rf /var/lib/apt/lists/*
# Taken from https://metadata.ftp-master.debian.org/changelogs/main/a/asterisk/unstable_changelog
# (replace all ~ with _ and remove final -)
ARG ASTERISK_OPUS_VERSION="20.5.2_dfsg+_cs6.13.40431414"
WORKDIR /usr/src/asterisk-opus
RUN curl -fsSL "https://salsa.debian.org/pkg-voip-team/asterisk/-/archive/upstream/${ASTERISK_OPUS_VERSION}/asterisk-upstream-${ASTERISK_OPUS_VERSION}.tar.gz?path=Xopus" | \
tar --strip-components 2 -xz
# https://github.com/asterisk/asterisk/tags
# https://www.asterisk.org/downloads/asterisk/all-asterisk-versions/
ARG ASTERISK_VERSION="20.5.2"
WORKDIR /usr/src/asterisk
RUN curl -fsSL "http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-${ASTERISK_VERSION}.tar.gz" | \
tar --strip-components 1 -xz
# copy codec_opus_open_source files
# res/* and include/asterisk/* are not needed as asterisk is new enough
RUN cp --verbose ../asterisk-opus*/codecs/* codecs; \
cp --verbose ../asterisk-opus*/formats/* formats; \
patch -p1 < ../asterisk-opus*/asterisk.patch
## Install app_rtsp_sip
WORKDIR /usr/src/app_rtsp_sip
COPY patches/app_rtsp_sip/*.patch ./
# https://github.com/tommyjlong/app_rtsp_sip/commits/master
ARG APP_RTSP_SIP_VERSION="d0fb18b4813e4ae8940029a8a62030443d9feaec"
ARG TARGETARCH
# hadolint ignore=DL3003,SC2164
RUN if [[ "${TARGETARCH}" == "amd64" || "${TARGETARCH}" == "i386" ]]; then \
curl -fsSL "https://github.com/tommyjlong/app_rtsp_sip/archive/${APP_RTSP_SIP_VERSION}.tar.gz" | \
tar --strip-components 1 -xz; \
patch -p1 < disable_auth.patch; \
patch -p1 < remove_sudo.patch; \
cp -f app_rtsp_sip.c /usr/src/asterisk/apps; \
cp -f rtsp_sip_links.sh /usr/src/asterisk; \
cd /usr/src/asterisk; \
./rtsp_sip_links.sh; \
fi
# Copy patches specific for this addon
COPY patches/asterisk/*.patch /usr/src/asterisk-patches/
WORKDIR /usr/src/asterisk
# Increase the number of format entries in SDPs to 128
RUN patch -p1 < /usr/src/asterisk-patches/increase_max_number_of_sdp_format_entries.patch
RUN \
# Recreate the configure script as we patched it above for the new formats \
./bootstrap.sh; \
\
./configure \
--with-jansson-bundled \
--with-pjproject-bundled \
--with-opus \
--with-opusfile \
--with-resample \
--with-unbound \
--without-asound \
--without-bluetooth \
--without-dahdi \
--without-gtk2 \
--without-jack \
--without-portaudio \
--without-postgres \
--without-pri \
--without-radius \
--without-sdl \
--without-ss7 \
--without-tds \
--without-unixodbc \
--without-x11; \
\
make menuselect/menuselect menuselect-tree menuselect.makeopts; \
# channels \
menuselect/menuselect --disable-category MENUSELECT_CHANNELS \
--enable chan_audiosocket \
--enable chan_bridge_media \
--enable chan_iax2 \
--enable chan_pjsip \
--enable chan_rtp \
--enable chan_sip ; \
# enable good things \
menuselect/menuselect --enable BETTER_BACKTRACES menuselect.makeopts; \
# applications \
menuselect/menuselect --disable app_adsiprog menuselect.makeopts; \
menuselect/menuselect --disable app_getcpeid menuselect.makeopts; \
# call detail recording \
menuselect/menuselect --disable cdr_sqlite3_custom menuselect.makeopts; \
# call event logging \
menuselect/menuselect --disable cel_sqlite3_custom menuselect.makeopts; \
# formats \
menuselect/menuselect --enable format_mp3 menuselect.makeopts; \
# codecs \
menuselect/menuselect --enable codec_a_mu menuselect.makeopts; \
menuselect/menuselect --enable codec_adpcm menuselect.makeopts; \
menuselect/menuselect --enable codec_alaw menuselect.makeopts; \
menuselect/menuselect --enable codec_codec2 menuselect.makeopts; \
menuselect/menuselect --enable codec_g722 menuselect.makeopts; \
menuselect/menuselect --enable codec_g726 menuselect.makeopts; \
menuselect/menuselect --enable codec_gsm menuselect.makeopts; \
menuselect/menuselect --enable codec_ilbc menuselect.makeopts; \
menuselect/menuselect --enable codec_resample menuselect.makeopts; \
menuselect/menuselect --enable codec_speex menuselect.makeopts; \
menuselect/menuselect --enable codec_ulaw menuselect.makeopts; \
menuselect/menuselect --enable codec_opus_open_source menuselect.makeopts; \
# pbx modules \
menuselect/menuselect --disable pbx_spool menuselect.makeopts; \
# resource modules \
menuselect/menuselect --disable res_config_sqlite3 menuselect.makeopts; \
menuselect/menuselect --disable res_monitor menuselect.makeopts; \
menuselect/menuselect --disable res_adsi menuselect.makeopts; \
# utilities \
menuselect/menuselect --disable astdb2sqlite3 menuselect.makeopts; \
menuselect/menuselect --disable astdb2bdb menuselect.makeopts; \
# download more sounds \
for i in CORE-SOUNDS-EN MOH-OPSOUND EXTRA-SOUNDS-EN; do \
for j in ULAW ALAW G722 GSM SLN16; do \
menuselect/menuselect --enable $i-$j menuselect.makeopts; \
done; \
done; \
\
# We require this for module format_mp3.so \
contrib/scripts/get_mp3_source.sh
ENV INSTALL_DIR="/opt/asterisk"
RUN \
# disable BUILD_NATIVE to avoid platform issues \
# for some reason, this needs to be set just before calling make (see #128) \
menuselect/menuselect --disable BUILD_NATIVE menuselect.makeopts; \
# 1.5 jobs per core works out okay \
JOBS=$(( $(nproc) + $(nproc) / 2 )); \
make -j ${JOBS} all; \
# install asterisk binaries and modules \
DESTDIR="${INSTALL_DIR}" make install; \
# install example configuration \
DESTDIR="${INSTALL_DIR}" make samples
## Install chan-gongle
WORKDIR /usr/src/asterisk-chan-dongle
# https://github.com/wdoekes/asterisk-chan-dongle/commits/master
ARG CHAN_DONGLE_VERSION="503dba87d726854b74b49e70679e64e6e86d5812"
RUN curl -fsSL "https://github.com/wdoekes/asterisk-chan-dongle/archive/${CHAN_DONGLE_VERSION}.tar.gz" | \
tar --strip-components 1 -xz
RUN ./bootstrap; \
./configure \
DESTDIR="${INSTALL_DIR}/usr/lib/asterisk/modules" \
--with-astversion="${ASTERISK_VERSION}" \
--with-asterisk="/usr/src/asterisk/include"; \
make all; \
make install; \
cp -f etc/dongle.conf "${INSTALL_DIR}/etc/asterisk/"
## Install googletts
WORKDIR /usr/src/asterisk-googletts
COPY patches/googletts/change_tmp_dir.patch .
# https://github.com/zaf/asterisk-googletts/commits/master
ARG GOOGLETTS_VERSION="5566ddc42e99d15cfaee2c4b8882e171ada2e479"
RUN curl -fsSL "https://github.com/zaf/asterisk-googletts/archive/${GOOGLETTS_VERSION}.tar.gz" | \
tar --strip-components 1 -xz; \
patch -p1 < change_tmp_dir.patch
RUN cp -f googletts.agi "${INSTALL_DIR}/var/lib/asterisk/agi-bin"
## Install speech-recog
WORKDIR /usr/src/asterisk-speech-recog
COPY patches/speech-recog/change_tmp_dir.patch .
# https://github.com/zaf/asterisk-speech-recog/commits/master
ARG SPEECH_RECOG_VERSION="dbc933bca1074514963a2294c52e617ef539a90a"
RUN curl -fsSL "https://github.com/zaf/asterisk-speech-recog/archive/${SPEECH_RECOG_VERSION}.tar.gz" | \
tar --strip-components 1 -xz; \
patch -p1 < change_tmp_dir.patch
RUN cp -f speech-recog.agi "${INSTALL_DIR}/var/lib/asterisk/agi-bin"
# Debian has a symlink from /var/run to /run, so here we move contents
# directly to /run. Otherwise we run into https://github.com/docker/buildx/issues/150.
RUN mv -f "${INSTALL_DIR}/var/run" "${INSTALL_DIR}/run"
FROM base
COPY --from=build /opt/asterisk/ /
COPY rootfs /
# Without this, the STDIN script never gets executed
ENV S6_CMD_WAIT_FOR_SERVICES=0
ENTRYPOINT [ "/entrypoint.sh" ]
CMD [ "/stdin.sh" ]
LABEL \
org.opencontainers.image.title="Home Assistant Add-on: Asterisk" \
org.opencontainers.image.description="PBX server for SIP devices like doorbells and phones." \
org.opencontainers.image.source="https://github.com/TECH7Fox/asterisk-hass-addons" \
org.opencontainers.image.licenses="MIT"