forked from tiredofit/docker-freepbx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
312 lines (308 loc) · 11.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
300
301
302
303
304
305
306
307
308
309
310
311
312
FROM tiredofit/debian:buster
LABEL maintainer="Dave Conroy (dave at tiredofit dot ca)"
### Set defaults
ENV ASTERISK_VERSION=17.9.4 \
BCG729_VERSION=1.0.4 \
DONGLE_VERSION=20200610 \
G72X_CPUHOST=penryn \
G72X_VERSION=0.1 \
MONGODB_VERSION=4.2 \
PHP_VERSION=5.6 \
SPANDSP_VERSION=20180108 \
RTP_START=18000 \
RTP_FINISH=20000
### Pin libxml2 packages to Debian repositories
RUN echo "Package: libxml2*" > /etc/apt/preferences.d/libxml2 && \
echo "Pin: release o=Debian,n=buster" >> /etc/apt/preferences.d/libxml2 && \
echo "Pin-Priority: 501" >> /etc/apt/preferences.d/libxml2 && \
APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=TRUE && \
\
### Install dependencies
set -x && \
curl -sSLk https://packages.sury.org/php/apt.gpg | apt-key add - && \
curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - && \
echo "deb https://deb.nodesource.com/node_10.x $(cat /etc/os-release |grep "VERSION=" | awk 'NR>1{print $1}' RS='(' FS=')') main" > /etc/apt/sources.list.d/nodejs.list && \
echo "deb https://packages.sury.org/php/ buster main" > /etc/apt/sources.list.d/deb.sury.org.list && \
curl -sSLk https://www.mongodb.org/static/pgp/server-${MONGODB_VERSION}.asc | apt-key add - && \
echo "deb http://repo.mongodb.org/apt/debian buster/mongodb-org/${MONGODB_VERSION} main" > /etc/apt/sources.list.d/mongodb-org.list && \
echo "deb http://ftp.us.debian.org/debian/ buster-backports main" > /etc/apt/sources.list.d/backports.list && \
echo "deb-src http://ftp.us.debian.org/debian/ buster-backports main" >> /etc/apt/sources.list.d/backports.list && \
apt-get update && \
apt-get -o Dpkg::Options::="--force-confold" upgrade -y && \
\
### Install development dependencies
ASTERISK_BUILD_DEPS='\
autoconf \
automake \
bison \
binutils-dev \
build-essential \
doxygen \
flex \
graphviz \
libasound2-dev \
libbluetooth-dev \
libc-client2007e-dev \
libcfg-dev \
libcodec2-dev \
libcorosync-common-dev \
libcpg-dev \
libcurl4-openssl-dev \
libedit-dev \
libfftw3-dev \
libgmime-2.6-dev \
libgsm1-dev \
libical-dev \
libiksemel-dev \
libjansson-dev \
libldap2-dev \
liblua5.2-dev \
libmariadb-dev \
libmariadbclient-dev \
libmp3lame-dev \
libncurses5-dev \
libneon27-dev \
libnewt-dev \
libogg-dev \
libopus-dev \
libosptk-dev \
libpopt-dev \
libradcli-dev \
libresample1-dev \
libsndfile1-dev \
libsnmp-dev \
libspeex-dev \
libspeexdsp-dev \
libsqlite3-dev \
libsrtp2-dev \
libssl-dev \
libtiff-dev \
libtool-bin \
libunbound-dev \
liburiparser-dev \
libvorbis-dev \
libvpb-dev \
libxml2-dev \
libxslt1-dev \
portaudio19-dev \
python-dev \
subversion \
unixodbc-dev \
uuid-dev \
zlib1g-dev' && \
\
### Install runtime dependencies
apt-get install --no-install-recommends -y \
$ASTERISK_BUILD_DEPS \
apache2 \
composer \
fail2ban \
ffmpeg \
flite \
freetds-dev \
git \
g++ \
iptables \
lame \
libavahi-client3 \
libbluetooth3 \
libc-client2007e \
libcfg7 \
libcpg4 \
libgmime-2.6 \
libical3 \
libiodbc2 \
libiksemel3 \
libicu63 \
libicu-dev \
libneon27 \
libosptk4 \
libresample1 \
libsnmp30 \
libspeexdsp1 \
libsrtp2-1 \
libunbound8 \
liburiparser1 \
libvpb1 \
locales \
locales-all \
make \
mariadb-client \
mariadb-server \
mongodb-org \
mpg123 \
nodejs \
odbc-mariadb \
php${PHP_VERSION} \
php${PHP_VERSION}-curl \
php${PHP_VERSION}-cli \
php${PHP_VERSION}-mysql \
php${PHP_VERSION}-gd \
php${PHP_VERSION}-mbstring \
php${PHP_VERSION}-intl \
php${PHP_VERSION}-bcmath \
php${PHP_VERSION}-ldap \
php${PHP_VERSION}-xml \
php${PHP_VERSION}-zip \
php${PHP_VERSION}-sqlite3 \
php-pear \
pkg-config \
sipsak \
sngrep \
socat \
sox \
sqlite3 \
tcpdump \
tcpflow \
unixodbc \
uuid \
wget \
whois \
xmlstarlet && \
\
### Add users
addgroup --gid 2600 asterisk && \
adduser --uid 2600 --gid 2600 --gecos "Asterisk User" --disabled-password asterisk && \
\
### Build SpanDSP
mkdir -p /usr/src/spandsp && \
curl -ssLk http://sources.buildroot.net/spandsp/spandsp-${SPANDSP_VERSION}.tar.gz | tar xvfz - --strip 1 -C /usr/src/spandsp && \
cd /usr/src/spandsp && \
./configure --prefix=/usr && \
make && \
make install && \
\
### Build Asterisk
cd /usr/src && \
mkdir -p asterisk && \
curl -sSLk http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-${ASTERISK_VERSION}.tar.gz | tar xvfz - --strip 1 -C /usr/src/asterisk && \
cd /usr/src/asterisk/ && \
make distclean && \
contrib/scripts/get_mp3_source.sh && \
cd /usr/src/asterisk && \
./configure \
--with-jansson-bundled \
--with-pjproject-bundled \
--with-bluetooth \
--with-codec2 \
--with-crypto \
--with-gmime \
--with-iconv \
--with-iksemel \
--with-inotify \
--with-ldap \
--with-libxml2 \
--with-libxslt \
--with-lua \
--with-ogg \
--with-opus \
--with-resample \
--with-spandsp \
--with-speex \
--with-sqlite3 \
--with-srtp \
--with-unixodbc \
--with-uriparser \
--with-vorbis \
--with-vpb \
&& \
\
make menuselect/menuselect menuselect-tree menuselect.makeopts && \
menuselect/menuselect --disable BUILD_NATIVE \
--enable-category MENUSELECT_ADDONS \
--enable-category MENUSELECT_APPS \
--enable-category MENUSELECT_CHANNELS \
--enable-category MENUSELECT_CODECS \
--enable-category MENUSELECT_FORMATS \
--enable-category MENUSELECT_FUNCS \
--enable-category MENUSELECT_RES \
--enable BETTER_BACKTRACES \
--disable MOH-OPSOUND-WAV \
--enable MOH-OPSOUND-GSM \
--disable app_voicemail_imap \
--disable app_voicemail_odbc \
--disable res_digium_phone \
--disable codec_g729a && \
make && \
make install && \
make install-headers && \
make config && \
\
#### Add G729 codecs
git clone https://github.com/BelledonneCommunications/bcg729 /usr/src/bcg729 && \
cd /usr/src/bcg729 && \
git checkout tags/$BCG729_VERSION && \
./autogen.sh && \
./configure --prefix=/usr --libdir=/lib && \
make && \
make install && \
\
mkdir -p /usr/src/asterisk-g72x && \
curl -sSLk https://bitbucket.org/arkadi/asterisk-g72x/get/master.tar.gz | tar xvfz - --strip 1 -C /usr/src/asterisk-g72x && \
cd /usr/src/asterisk-g72x && \
./autogen.sh && \
./configure --prefix=/usr --with-bcg729 --enable-$G72X_CPUHOST && \
make && \
make install && \
\
#### Add USB Dongle support
git clone https://github.com/rusxakep/asterisk-chan-dongle /usr/src/asterisk-chan-dongle && \
cd /usr/src/asterisk-chan-dongle && \
git checkout tags/$DONGLE_VERSION && \
./bootstrap && \
./configure --with-astversion=$ASTERISK_VERSION && \
make && \
make install && \
\
ldconfig && \
\
### Cleanup
mkdir -p /var/run/fail2ban && \
cd / && \
rm -rf /usr/src/* /tmp/* /etc/cron* && \
apt-get purge -y $ASTERISK_BUILD_DEPS && \
apt-get -y autoremove && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
\
### FreePBX hacks
sed -i -e "s/memory_limit = 128M/memory_limit = 256M/g" /etc/php/${PHP_VERSION}/apache2/php.ini && \
sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php/${PHP_VERSION}/apache2/php.ini && \
a2disconf other-vhosts-access-log.conf && \
a2enmod rewrite && \
a2enmod headers && \
rm -rf /var/log/* && \
mkdir -p /var/log/asterisk && \
mkdir -p /var/log/apache2 && \
mkdir -p /var/log/httpd && \
update-alternatives --set php /usr/bin/php${PHP_VERSION} && \
\
### Zabbix setup
echo '%zabbix ALL=(asterisk) NOPASSWD:/usr/sbin/asterisk' >> /etc/sudoers && \
\
### Setup for data persistence
mkdir -p /assets/config/var/lib/ /assets/config/home/ && \
mv /home/asterisk /assets/config/home/ && \
ln -s /data/home/asterisk /home/asterisk && \
mv /var/lib/asterisk /assets/config/var/lib/ && \
ln -s /data/var/lib/asterisk /var/lib/asterisk && \
ln -s /data/usr/local/fop2 /usr/local/fop2 && \
mkdir -p /assets/config/var/run/ && \
mv /var/run/asterisk /assets/config/var/run/ && \
mv /var/lib/mysql /assets/config/var/lib/ && \
mkdir -p /assets/config/var/spool && \
mv /var/spool/cron /assets/config/var/spool/ && \
ln -s /data/var/spool/cron /var/spool/cron && \
mkdir -p /var/run/mongodb && \
rm -rf /var/lib/mongodb && \
ln -s /data/var/lib/mongodb /var/lib/mongodb && \
ln -s /data/var/run/asterisk /var/run/asterisk && \
rm -rf /var/spool/asterisk && \
ln -s /data/var/spool/asterisk /var/spool/asterisk && \
rm -rf /etc/asterisk && \
ln -s /data/etc/asterisk /etc/asterisk && \
ln -s /usr/sbin/crontab /usr/bin/crontab
### Networking configuration
EXPOSE 80 443 4445 4569 5060/udp 5160/udp 5061 5161 8001 8003 8008 8009 8025 ${RTP_START}-${RTP_FINISH}/udp
### Files add
ADD install /