Dockerfile 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. FROM ubuntu:focal AS build-asterisk
  2. ENV DEBIAN_FRONTEND=noninteractive
  3. ARG ASTERISK_VER=18.10.0
  4. ARG BCG729_VER=1.1.1
  5. ARG ASTERISK_G72X_VER=master
  6. WORKDIR /usr/src
  7. RUN apt-get update && \
  8. apt-get install --no-install-recommends --yes \
  9. git build-essential subversion checkinstall autoconf automake bison flex graphviz cmake curl ca-certificates libresample1-dev libiksemel-dev libopus-dev pkg-config
  10. RUN cd /usr/src && \
  11. mkdir asterisk && \
  12. curl -fSL --connect-timeout 30 http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-${ASTERISK_VER}.tar.gz | tar xz --strip 1 -C asterisk && \
  13. cd asterisk && \
  14. ./contrib/scripts/get_mp3_source.sh && \
  15. ./contrib/scripts/install_prereq install
  16. RUN cd /usr/src/asterisk && git clone https://github.com/felipem1210/asterisk-res_json.git && ./asterisk-res_json/install.sh
  17. RUN cd /usr/src/asterisk && ./configure --prefix=/usr --libdir=/usr/lib --with-pjproject-bundled --with-jansson-bundled --with-resample --with-ssl=ssl --with-srtp && \
  18. make menuselect/menuselect menuselect-tree menuselect.makeopts && \
  19. menuselect/menuselect \
  20. --enable-category MENUSELECT_ADDONS \
  21. --enable-category MENUSELECT_CHANNELS \
  22. --enable-category MENUSELECT_APPS \
  23. --enable-category MENUSELECT_CDR \
  24. --enable-category MENUSELECT_FORMATS \
  25. --enable-category MENUSELECT_FUNCS \
  26. --enable-category MENUSELECT_PBX \
  27. --enable-category MENUSELECT_RES \
  28. --enable-category MENUSELECT_CEL \
  29. \
  30. menuselect/menuselect \
  31. --enable BETTER_BACKTRACES \
  32. --enable DONT_OPTIMIZE \
  33. --enable app_confbridge \
  34. --enable app_macro \
  35. --enable app_meetme \
  36. --enable app_mysql \
  37. --enable app_page \
  38. --enable binaural_rendering_in_bridge_softmix \
  39. --enable chan_motif \
  40. --enable codec_silk \
  41. --enable codec_opus \
  42. --enable format_mp3 \
  43. --enable res_ari \
  44. --enable res_chan_stats \
  45. --enable res_calendar \
  46. --enable res_calendar_caldav \
  47. --enable res_calendar_icalendar \
  48. --enable res_endpoint_stats \
  49. --enable res_pktccops \
  50. --enable res_snmp \
  51. --enable res_srtp \
  52. --enable res_xmpp \
  53. --disable-category MENUSELECT_CORE_SOUNDS \
  54. --disable-category MENUSELECT_EXTRA_SOUNDS \
  55. --disable-category MENUSELECT_MOH \
  56. --disable BUILD_NATIVE \
  57. --disable app_ivrdemo \
  58. --disable app_meetme \
  59. --disable app_saycounted \
  60. --disable app_skel \
  61. --disable cdr_pgsql \
  62. --disable cel_pgsql \
  63. --disable cdr_sqlite3_custom \
  64. --disable cel_sqlite3_custom \
  65. --disable cdr_mysql \
  66. --disable cdr_tds \
  67. --disable cel_tds \
  68. --disable cdr_radius \
  69. --disable cel_radius \
  70. --disable cdr_syslog \
  71. --disable chan_alsa \
  72. --disable chan_console \
  73. --disable chan_oss \
  74. --disable chan_mgcp \
  75. --disable chan_skinny \
  76. --disable chan_ooh323 \
  77. --disable chan_mobile \
  78. --disable chan_unistim \
  79. --disable res_digium_phone \
  80. --disable res_calendar_ews \
  81. --disable res_calendar_exchange \
  82. --disable res_stasis_mailbox \
  83. --disable res_mwi_external \
  84. --disable res_mwi_external_ami \
  85. --disable res_config_pgsql \
  86. --disable res_config_mysql \
  87. --disable res_config_ldap \
  88. --disable res_config_sqlite3 \
  89. --disable res_phoneprov \
  90. --disable res_pjsip_phoneprov_provider \
  91. && \
  92. make && \
  93. checkinstall --install=yes --default --pakdir=/usr/src/packages --pkgname=asterisk-iczr --pkgversion=${ASTERISK_VER} && \
  94. checkinstall --install=yes --default --pakdir=/usr/src/packages --pkgname=asterisk-iczr-dev --pkgversion=${ASTERISK_VER} make install-headers && \
  95. checkinstall --install=yes --default --pakdir=/usr/src/packages --pkgname=asterisk-iczr-config --pkgversion=${ASTERISK_VER} make config && \
  96. checkinstall --install=yes --default --pakdir=/usr/src/packages --pkgname=asterisk-iczr-samples --pkgversion=${ASTERISK_VER} make samples && \
  97. ldconfig && \
  98. cd /usr/src && \
  99. mkdir bcg729 && \
  100. curl -fSL --connect-timeout 30 https://github.com/BelledonneCommunications/bcg729/archive/${BCG729_VER}.tar.gz | tar xz --strip 1 -C bcg729 && \
  101. cd bcg729 && \
  102. cmake . -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_PREFIX_PATH=/usr && \
  103. make && \
  104. checkinstall --install=yes --default --pakdir=/usr/src/packages --pkgname=bcg729-iczr --pkgversion=${BCG729_VER} --spec=none && \
  105. ldconfig && \
  106. cd /usr/src && \
  107. mkdir asterisk-g72x && \
  108. curl -fSL --connect-timeout 30 https://bitbucket.org/arkadi/asterisk-g72x/get/${ASTERISK_G72X_VER}.tar.gz | tar xz --strip 1 -C asterisk-g72x && \
  109. cd asterisk-g72x && \
  110. ./autogen.sh && \
  111. ./configure --prefix=/usr --with-bcg729 --enable-penryn && \
  112. make && \
  113. checkinstall --install=yes --default --pakdir=/usr/src/packages --pkgname=asterisk-g72x-iczr --pkgversion=0.${ASTERISK_G72X_VER} && \
  114. ldconfig
  115. FROM ubuntu:focal AS iczr-freepbx
  116. ENV DEBIAN_FRONTEND=noninteractive
  117. ARG ASTERISK_VER=18.10.0
  118. ARG BCG729_VER=1.1.1
  119. ARG ASTERISK_G72X_VER=master
  120. ARG FREEPBX_VER=15.0
  121. ENV APP_PORT_HTTP 80
  122. ENV APP_PORT_HTTPS 443
  123. ENV APP_PORT_PJSIP 5160
  124. ENV APP_PORT_SIP 5060
  125. ENV APP_PORT_IAX 4569
  126. ENV APP_PORT_RTP_START 10000
  127. ENV APP_PORT_RTP_END 10200
  128. ENV APP_PORT_MYSQL 3306
  129. ENV APP_UID=1000
  130. ENV APP_GID=1000
  131. ENV APP_USR="asterisk"
  132. ENV APP_GRP="asterisk"
  133. COPY --from=build-asterisk /usr/src/packages /usr/src/packages
  134. RUN apt-get update && \
  135. apt-get install --no-install-recommends --yes gpg gpg-agent dirmngr && \
  136. apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C && \
  137. echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu focal main" >> /etc/apt/sources.list.d/ondrej-php.list && \
  138. echo "deb http://ppa.launchpad.net/ondrej/apache2/ubuntu focal main" >> /etc/apt/sources.list.d/ondrej-apache2.list && \
  139. apt-get update && \
  140. apt-get upgrade --yes && \
  141. dpkg -i /usr/src/packages/*.deb && \
  142. apt-get install --no-install-recommends --yes \
  143. apache2 \
  144. binutils \
  145. certbot \
  146. codec2 \
  147. cron \
  148. curl \
  149. fail2ban \
  150. ffmpeg \
  151. file \
  152. freetds-bin \
  153. freetds-common \
  154. iptables \
  155. jq \
  156. lame \
  157. libaudiofile1 \
  158. libc-client2007e \
  159. libcap2 \
  160. libcfg7 \
  161. libcpg4 \
  162. libdbd-mysql \
  163. libdbi-perl\
  164. libeditline0 \
  165. libevent-2.1-7 \
  166. libfftw3-3 \
  167. libfftw3-bin \
  168. libgmime-3.0-0 \
  169. libical3 \
  170. libicu66 \
  171. libiksemel3 \
  172. libjansson4 \
  173. libjpeg-turbo8 \
  174. libltdl7 \
  175. libncurses5 \
  176. libneon27 \
  177. libnewt0.52 \
  178. libopus0 \
  179. libosptk4 \
  180. libportaudio2 \
  181. libproxy1v5 \
  182. libresample1 \
  183. libsensors5 \
  184. libsndfile1 \
  185. libsnmp35 \
  186. libsnmp-base \
  187. libspandsp2 \
  188. libspeexdsp1 \
  189. libsrtp2-1 \
  190. libtiff5 \
  191. libtiff-tools \
  192. libunbound8 \
  193. liburiparser1 \
  194. libvpb1 \
  195. libxml2 \
  196. lm-sensors \
  197. logrotate \
  198. lsof \
  199. mariadb-client \
  200. mpg123 \
  201. netcat \
  202. net-tools \
  203. nodejs \
  204. npm \
  205. odbc-mariadb \
  206. openssl \
  207. php7.3 \
  208. php7.3-mysql \
  209. php7.3-curl \
  210. php7.3-gd \
  211. php7.3-json \
  212. php7.3-mbstring \
  213. php7.3-xml \
  214. postfix \
  215. rsync \
  216. sox \
  217. speex \
  218. sqlite3 \
  219. strace \
  220. sudo \
  221. supervisor \
  222. unixodbc \
  223. unzip \
  224. uuid \
  225. wget \
  226. whois \
  227. zip
  228. RUN groupadd -g ${APP_GID} ${APP_GRP} && \
  229. useradd -u ${APP_UID} -c "Asterisk User" -g ${APP_GRP} -s /sbin/nologin ${APP_USR} && \
  230. usermod -aG sudo,www-data ${APP_USR} && \
  231. mkdir -p \
  232. /etc/pki/pbx \
  233. /home/asterisk \
  234. /var/lib/asterisk/moh \
  235. /var/lib/asterisk/sounds \
  236. /var/spool/asterisk \
  237. /var/run/fail2ban && \
  238. chown -R ${APP_USR}:${APP_GRP} \
  239. /etc/asterisk \
  240. /home/asterisk \
  241. /var/lib/asterisk \
  242. /var/spool/asterisk && \
  243. openssl req -subj '/CN=pbx/O=ICZR/C=RU' -new -newkey rsa:2048 -sha256 -days 36500 -nodes -x509 -keyout /etc/pki/pbx/iczrpbx.key -out /etc/pki/pbx/iczrpbx.crt
  244. RUN cd /usr/src && \
  245. mkdir freepbx && \
  246. curl -fSL --connect-timeout 30 http://mirror.freepbx.org/modules/packages/freepbx/freepbx-${FREEPBX_VER}-latest.tgz | tar xz --strip 1 -C freepbx && \
  247. cd freepbx && \
  248. curl -fSL --connect-timeout 30 http://mirror1.freepbx.org/modules-${FREEPBX_VER}.xml -o modules-${FREEPBX_VER}.xml && \
  249. mkdir -p amp_conf/htdocs/admin/modules/_cache && \
  250. for MODULE in \
  251. announcement \
  252. arimanager \
  253. asteriskinfo \
  254. backup \
  255. calendar \
  256. callforward \
  257. callwaiting \
  258. cel \
  259. certman \
  260. cidlookup \
  261. contactmanager \
  262. daynight \
  263. donotdisturb \
  264. filestore \
  265. findmefollow \
  266. iaxsettings \
  267. ivr \
  268. manager \
  269. miscapps \
  270. miscdests \
  271. parking \
  272. phonebook \
  273. presencestate \
  274. printextensions \
  275. queues \
  276. soundlang \
  277. timeconditions \
  278. userman \
  279. ucp \
  280. bulkhandler \
  281. speeddial \
  282. weakpasswords \
  283. asterisk-cli \
  284. blacklist \
  285. configedit \
  286. pm2 \
  287. ; do \
  288. mkdir -p amp_conf/htdocs/admin/modules/$MODULE && \
  289. MODULE_VER=$(php -r "echo json_encode(simplexml_load_file('modules-${FREEPBX_VER}.xml'));" | jq -r ".module[] | select(.rawname == \"${MODULE}\") | {version}".version) && \
  290. curl -sfSL --connect-timeout 30 http://mirror.freepbx.org/modules/packages/$MODULE/$MODULE-${MODULE_VER}.tgz | tar xz --strip 1 -C amp_conf/htdocs/admin/modules/$MODULE/ && \
  291. curl -sfSL --connect-timeout 30 http://mirror.freepbx.org/modules/packages/$MODULE/$MODULE-${MODULE_VER}.tgz.gpg -o amp_conf/htdocs/admin/modules/_cache/$MODULE-${MODULE_VER}.tgz.gpg \
  292. ; done && \
  293. su - ${APP_USR} -s /bin/bash -c "gpg --refresh-keys --keyserver hkp://keyserver.ubuntu.com:80" && \
  294. su - ${APP_USR} -s /bin/bash -c "gpg --import /usr/src/freepbx/amp_conf/htdocs/admin/libraries/BMO/1588A7366BD35B34.key" && \
  295. su - ${APP_USR} -s /bin/bash -c "gpg --import /usr/src/freepbx/amp_conf/htdocs/admin/libraries/BMO/3DDB2122FE6D84F7.key" && \
  296. su - ${APP_USR} -s /bin/bash -c "gpg --import /usr/src/freepbx/amp_conf/htdocs/admin/libraries/BMO/86CE877469D2EAD9.key" && \
  297. su - ${APP_USR} -s /bin/bash -c "gpg --import /usr/src/freepbx/amp_conf/htdocs/admin/libraries/BMO/9F9169F4B33B4659.key"
  298. EXPOSE ${APP_PORT_HTTP}/tcp \
  299. ${APP_PORT_HTTPS}/tcp \
  300. ${APP_PORT_PJSIP}/tcp \
  301. ${APP_PORT_PJSIP}/udp \
  302. ${APP_PORT_IAX}/tcp \
  303. ${APP_PORT_IAX}/udp \
  304. ${APP_PORT_SIP}/tcp \
  305. ${APP_PORT_SIP}/udp \
  306. ${APP_PORT_RTP_START}-${APP_PORT_RTP_END}/udp \
  307. ${APP_PORT_MYSQL}/tcp
  308. ADD filesystem /
  309. ENTRYPOINT ["/entrypoint.sh"]
  310. CMD ["supervisord", "-n", "-c", "/etc/supervisor/supervisord.conf"]