Skip to content

Instantly share code, notes, and snippets.

@mosquito
Created July 20, 2023 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mosquito/a1f0596c0fe0edfb95b0f94cd30dfc94 to your computer and use it in GitHub Desktop.
Save mosquito/a1f0596c0fe0edfb95b0f94cd30dfc94 to your computer and use it in GitHub Desktop.
Asterisk 20 with opus g729 on archlinux
##############################################################################
FROM archlinux as build
RUN pacman -Syyu --noconfirm
RUN pacman -S --noconfirm git base-devel
RUN useradd -m builder
RUN mkdir -p /root/packages
USER root
RUN pacman -S --noconfirm \
alsa-lib curl jansson libedit libvorbis libxml2 libxslt \
opus opusfile libopusenc popt speex \
gsm sqlite3 gsm libsrtp lua51 postgresql
USER builder
WORKDIR /home/builder
RUN git clone https://aur.archlinux.org/asterisk.git
WORKDIR asterisk
RUN makepkg -s --noconfirm
USER root
RUN ls; pwd
RUN pacman -U --noconfirm *.pkg.tar.zst
RUN cp *.pkg.tar.zst /root/packages/
USER root
RUN pacman -S --noconfirm opusfile libopusenc
USER builder
WORKDIR /home/builder
RUN git clone https://aur.archlinux.org/asterisk-codec_opus.git
WORKDIR asterisk-codec_opus
RUN makepkg -s --noconfirm
USER root
RUN pacman -U --noconfirm *.pkg.tar.zst
RUN cp *.pkg.tar.zst /root/packages/
USER root
RUN pacman -S --noconfirm bcg729
USER builder
WORKDIR /home/builder
RUN git clone https://aur.archlinux.org/asterisk-g729.git
WORKDIR asterisk-g729
RUN makepkg -s --noconfirm
USER root
RUN pacman -U --noconfirm *.pkg.tar.zst
RUN cp *.pkg.tar.zst /root/packages/
USER root
RUN pacman -S --noconfirm unixodbc
USER builder
WORKDIR /home/builder
RUN git clone https://aur.archlinux.org/psqlodbc.git
WORKDIR psqlodbc
RUN makepkg -s --noconfirm
USER root
RUN pacman -U --noconfirm *.pkg.tar.zst
RUN cp *.pkg.tar.zst /root/packages/
USER root
RUN pacman -S --noconfirm sqlite
USER builder
WORKDIR /home/builder
RUN git clone https://aur.archlinux.org/sqliteodbc.git
WORKDIR sqliteodbc
RUN makepkg -s --noconfirm
USER root
RUN pacman -U --noconfirm *.pkg.tar.zst
RUN cp *.pkg.tar.zst /root/packages/
USER root
RUN pacman -S --noconfirm cmake mariadb-libs
USER builder
WORKDIR /home/builder
RUN git clone https://aur.archlinux.org/mariadb-connector-odbc.git
WORKDIR mariadb-connector-odbc
RUN makepkg -s --noconfirm
USER root
RUN pacman -U --noconfirm *.pkg.tar.zst
RUN cp *.pkg.tar.zst /root/packages/
RUN mkdir -p /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-en-alaw-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-en-g722-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-en-g729-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-en-gsm-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-en-siren14-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-en-siren7-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-en-sln16-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-en-ulaw-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-en-wav-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-ru-alaw-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-ru-g722-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-ru-g729-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-ru-gsm-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-ru-siren14-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-ru-siren7-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-ru-sln16-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-ru-ulaw-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-ru-wav-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-alaw-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-g722-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-g729-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-gsm-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-siren14-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-siren7-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-sln16-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-ulaw-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-wav-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-moh-opsound-alaw-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-moh-opsound-g722-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-moh-opsound-g729-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-moh-opsound-gsm-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-moh-opsound-siren14-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-moh-opsound-siren7-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-moh-opsound-sln16-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-moh-opsound-ulaw-current.tar.gz /tmp/sounds
ADD http://downloads.asterisk.org/pub/telephony/sounds/asterisk-moh-opsound-wav-current.tar.gz /tmp/sounds
RUN mkdir -p /var/lib/asterisk/sounds/{en,ru}
WORKDIR /var/lib/asterisk/sounds/en
RUN find /tmp/sounds -iname "*-en-*.tar.gz" -exec tar -xvf {} \;
WORKDIR /var/lib/asterisk/sounds/ru
RUN find /tmp/sounds -iname "*-ru-*.tar.gz" -exec tar -xvf {} \;
WORKDIR /var/lib/asterisk/moh
RUN find /tmp/sounds -iname "*-moh-*.tar.gz" -exec tar -xvf {} \;
##############################################################################
FROM archlinux as target
COPY --from=build /root/packages/*.pkg.tar.zst /tmp/
RUN pacman -Syyu --noconfirm unixodbc python sox lame && pacman -U --noconfirm /tmp/*.pkg.tar.zst && rm -fr /var/cache/packman
COPY --from=build /var/lib/asterisk/sounds/en /var/lib/asterisk/sounds/en
COPY --from=build /var/lib/asterisk/sounds/ru /var/lib/asterisk/sounds/ru
COPY --from=build /var/lib/asterisk/moh /var/lib/asterisk/moh
CMD ["asterisk", "-f", "-U", "asterisk", "-G", "asterisk"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment