Skip to content

Commit 8adc874

Browse files
authored
Merge pull request #135 from andrius/asterisk-new-releases
New Asterisk Releases Update: 18.9-cert18 20.19.0 22.9.0 23.3.0
2 parents ece0863 + e6adb16 commit 8adc874

21 files changed

Lines changed: 2421 additions & 4 deletions
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
# Multi-stage optimized Asterisk Docker build
2+
# Asterisk 18.9-cert18 on Debian trixie
3+
# Generated from YAML configuration - DO NOT EDIT MANUALLY
4+
5+
# ==============================================================================
6+
# STAGE 1: Build Environment
7+
# ==============================================================================
8+
FROM debian:trixie AS asterisk-builder
9+
10+
LABEL maintainer="Andrius Kairiukstis <k@andrius.mobi>"
11+
LABEL org.opencontainers.image.title="Asterisk PBX Builder"
12+
LABEL org.opencontainers.image.description="Build stage for Asterisk 18.9-cert18"
13+
LABEL org.opencontainers.image.version="18.9-cert18"
14+
LABEL org.opencontainers.image.source="https://github.com/andrius/asterisk"
15+
16+
# Build arguments
17+
ARG ASTERISK_VERSION=18.9-cert18
18+
ARG JOBS=8
19+
ARG DEBIAN_FRONTEND=noninteractive
20+
ARG TARGETARCH
21+
22+
# Environment variables
23+
ENV ASTERISK_VERSION=${ASTERISK_VERSION}
24+
ENV DEBIAN_FRONTEND=${DEBIAN_FRONTEND}
25+
ENV TMPDIR="/tmp/asterisk_build"
26+
27+
# Create build directories first
28+
RUN mkdir -p \
29+
/usr/src/asterisk \
30+
${TMPDIR} \
31+
&& chmod 777 ${TMPDIR}
32+
33+
# EOL distribution setup (if needed)
34+
# Update package lists and install ca-certificates first, then build dependencies
35+
RUN apt-get update \
36+
&& apt-get install -y --no-install-recommends ca-certificates \
37+
&& apt-get install -y --no-install-recommends \
38+
build-essential autoconf binutils-dev curl file libcurl4-openssl-dev \
39+
libedit-dev libgsm1-dev libicu-dev libjansson-dev libncurses-dev libogg-dev \
40+
libpopt-dev libpqxx-dev libresample1-dev libspandsp-dev libspeex-dev \
41+
libspeexdsp-dev libsqlite3-dev libssl-dev libtool libvorbis-dev libxml2-dev \
42+
libxslt1-dev make odbcinst patch pkg-config portaudio19-dev procps \
43+
python3-dev unixodbc unixodbc-dev uuid uuid-dev xmlstarlet libsrtp2-dev \
44+
&& apt-get clean \
45+
&& rm -rf /var/lib/apt/lists/* \
46+
&& mkdir -p ${TMPDIR} && chmod 777 ${TMPDIR}
47+
48+
49+
WORKDIR /usr/src/asterisk
50+
51+
# Download and extract Asterisk source
52+
RUN curl -fsSL https://downloads.asterisk.org/pub/telephony/certified-asterisk/releases/asterisk-certified-18.9-cert18.tar.gz \
53+
| tar --strip-components=1 -xz
54+
55+
56+
# Configure Asterisk build (skip for very old versions that don't have configure script)
57+
RUN ./configure
58+
59+
# Generate menuselect configuration
60+
RUN make menuselect/menuselect menuselect-tree menuselect.makeopts
61+
62+
# Optimize build configuration for smaller image
63+
RUN sed -i 's/HAVE_XML2 = yes/HAVE_XML2 = no/' makeopts \
64+
&& sed -i 's/HAVE_XMLSTARLET = yes/HAVE_XMLSTARLET = no/' makeopts
65+
66+
# Copy and execute build script
67+
COPY build.sh /usr/src/asterisk/build.sh
68+
RUN chmod +x build.sh && ./build.sh
69+
70+
# ==============================================================================
71+
# STAGE 2: Runtime Environment
72+
# ==============================================================================
73+
FROM debian:trixie AS asterisk-runtime
74+
75+
LABEL maintainer="Andrius Kairiukstis <k@andrius.mobi>"
76+
LABEL org.opencontainers.image.title="Asterisk PBX Runtime"
77+
LABEL org.opencontainers.image.description="Runtime environment for Asterisk 18.9-cert18"
78+
79+
ARG DEBIAN_FRONTEND=noninteractive
80+
ARG TARGETARCH
81+
ENV DEBIAN_FRONTEND=${DEBIAN_FRONTEND}
82+
83+
# Install only runtime dependencies
84+
RUN apt-get update \
85+
&& apt-get install -y --no-install-recommends \
86+
binutils curl libedit2 libgsm1 libjansson4 libogg0 libopus0 libpopt0 \
87+
libresample1 libspandsp2 libspeex1 libspeexdsp1 libsqlite3-0 libvorbis0a \
88+
libxml2 libxslt1.1 odbcinst portaudio19-dev procps python3 unixodbc uuid \
89+
libcurl4t64 libssl3t64 libsrtp2-1 libncurses6 libpqxx-7.10 libicu76 \
90+
&& apt-get clean \
91+
&& rm -rf /var/lib/apt/lists/*
92+
93+
# Create asterisk user and required directories
94+
RUN useradd --uid 1000 --system --user-group \
95+
--home-dir /home/asterisk --create-home \
96+
asterisk \
97+
&& mkdir -p \
98+
/var/run/asterisk \
99+
/var/log/asterisk \
100+
/var/spool/asterisk/monitor \
101+
/var/spool/asterisk/outgoing \
102+
/var/spool/asterisk/tmp \
103+
/var/spool/asterisk/voicemail \
104+
/var/spool/asterisk/fax \
105+
/var/lib/asterisk/keys \
106+
/var/lib/asterisk/phoneprov \
107+
/var/lib/asterisk/sounds \
108+
/var/lib/asterisk/docs
109+
110+
# ==============================================================================
111+
# STAGE 3: Final Production Image
112+
# ==============================================================================
113+
FROM asterisk-runtime AS asterisk-production
114+
115+
LABEL maintainer="Andrius Kairiukstis <k@andrius.mobi>"
116+
LABEL org.opencontainers.image.title="Asterisk PBX"
117+
LABEL org.opencontainers.image.description="Production Asterisk PBX 18.9-cert18"
118+
LABEL org.opencontainers.image.version="18.9-cert18"
119+
LABEL org.opencontainers.image.source="https://github.com/andrius/asterisk"
120+
LABEL org.opencontainers.image.vendor="Andrius Kairiukstis <k@andrius.mobi>"
121+
122+
# Copy Asterisk binaries and configurations from builder
123+
COPY --from=asterisk-builder /usr/sbin/asterisk /usr/sbin/asterisk
124+
COPY --from=asterisk-builder /usr/lib/asterisk /usr/lib/asterisk
125+
COPY --from=asterisk-builder /var/lib/asterisk /var/lib/asterisk
126+
COPY --from=asterisk-builder /etc/asterisk /etc/asterisk
127+
128+
# Copy Asterisk shared libraries
129+
COPY --from=asterisk-builder /usr/lib/libasterisk*.so* /usr/lib/
130+
131+
# Copy healthcheck script
132+
COPY healthcheck.sh /usr/local/bin/healthcheck.sh
133+
RUN chmod +x /usr/local/bin/healthcheck.sh
134+
135+
# Set proper ownership and permissions
136+
RUN chown -R asterisk:asterisk \
137+
/etc/asterisk \
138+
/home/asterisk \
139+
/var/*/asterisk \
140+
/usr/lib*/asterisk 2>/dev/null || true \
141+
&& chmod -R 750 /var/spool/asterisk
142+
143+
# Runtime verification
144+
RUN asterisk -V || (echo "Error: Unable to run asterisk -V" && exit 1)
145+
146+
# Configure networking
147+
# EXPOSE 5060/udp
148+
# EXPOSE 5060/tcp
149+
# EXPOSE 5061/tcp
150+
# EXPOSE 10000-10099/udp
151+
152+
# Define volumes for persistent data
153+
VOLUME ["/var/lib/asterisk/sounds", "/var/lib/asterisk/keys", "/var/lib/asterisk/phoneprov", "/var/spool/asterisk", "/var/log/asterisk", "/etc/asterisk"]
154+
155+
# Add health check
156+
HEALTHCHECK --interval=30s \
157+
--timeout=10s \
158+
--start-period=30s \
159+
--retries=3 \
160+
CMD /usr/local/bin/healthcheck.sh
161+
162+
# Switch to non-root user
163+
USER asterisk
164+
165+
# Set working directory
166+
WORKDIR /home/asterisk
167+
168+
# Default command with production settings
169+
CMD ["/usr/sbin/asterisk", "-vvvdddf", "-T", "-W", "-U", "asterisk", "-p"]
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
#!/bin/bash
2+
# Asterisk build script
3+
# Generated from template for 18.9-cert18
4+
# Contains menuselect configuration and build commands
5+
6+
set -euo pipefail
7+
8+
# Color output for better readability
9+
GREEN='\033[0;32m'
10+
YELLOW='\033[1;33m'
11+
RED='\033[0;31m'
12+
NC='\033[0m' # No Color
13+
14+
log() {
15+
echo -e "${GREEN}[BUILD]${NC} $1"
16+
}
17+
18+
warn() {
19+
echo -e "${YELLOW}[WARN]${NC} $1"
20+
}
21+
22+
error() {
23+
echo -e "${RED}[ERROR]${NC} $1"
24+
}
25+
26+
log "Starting Asterisk 18.9-cert18 build process..."
27+
28+
# Set build parallelization (use Docker ARG or default)
29+
NPROC=$(nproc)
30+
JOBS=${JOBS:-8}
31+
log "Using $JOBS parallel jobs for compilation (detected $NPROC CPUs)"
32+
33+
# Configure Asterisk
34+
log "Configuring Asterisk with options..."
35+
./configure --with-pjproject-bundled --with-ssl=ssl --with-crypto
36+
37+
# Build menuselect tool
38+
log "Building menuselect tool..."
39+
make menuselect
40+
41+
# Configure Asterisk modules using menuselect
42+
log "Configuring Asterisk modules..."
43+
44+
# Disable BUILD_NATIVE optimization for container builds
45+
menuselect/menuselect --disable BUILD_NATIVE menuselect.makeopts
46+
47+
# Enable better backtraces for debugging
48+
menuselect/menuselect --enable BETTER_BACKTRACES menuselect.makeopts
49+
50+
# Disable sound packages to reduce image size
51+
menuselect/menuselect --disable-category MENUSELECT_CORE_SOUNDS menuselect.makeopts
52+
menuselect/menuselect --disable-category MENUSELECT_MOH menuselect.makeopts
53+
menuselect/menuselect --disable-category MENUSELECT_EXTRA_SOUNDS menuselect.makeopts
54+
55+
# Enable core applications
56+
menuselect/menuselect --enable app_voicemail menuselect.makeopts || warn "Module not found: $(echo 'menuselect/menuselect --enable app_voicemail menuselect.makeopts' | grep -o '[a-z_]*' | tail -1)"
57+
menuselect/menuselect --enable app_queue menuselect.makeopts || warn "Module not found: $(echo 'menuselect/menuselect --enable app_queue menuselect.makeopts' | grep -o '[a-z_]*' | tail -1)"
58+
menuselect/menuselect --enable app_confbridge menuselect.makeopts || warn "Module not found: $(echo 'menuselect/menuselect --enable app_confbridge menuselect.makeopts' | grep -o '[a-z_]*' | tail -1)"
59+
menuselect/menuselect --enable app_directory menuselect.makeopts || warn "Module not found: $(echo 'menuselect/menuselect --enable app_directory menuselect.makeopts' | grep -o '[a-z_]*' | tail -1)"
60+
menuselect/menuselect --enable app_dial menuselect.makeopts || warn "Module not found: $(echo 'menuselect/menuselect --enable app_dial menuselect.makeopts' | grep -o '[a-z_]*' | tail -1)"
61+
menuselect/menuselect --enable app_playback menuselect.makeopts || warn "Module not found: $(echo 'menuselect/menuselect --enable app_playback menuselect.makeopts' | grep -o '[a-z_]*' | tail -1)"
62+
menuselect/menuselect --enable app_record menuselect.makeopts || warn "Module not found: $(echo 'menuselect/menuselect --enable app_record menuselect.makeopts' | grep -o '[a-z_]*' | tail -1)"
63+
menuselect/menuselect --enable app_echo menuselect.makeopts || warn "Module not found: $(echo 'menuselect/menuselect --enable app_echo menuselect.makeopts' | grep -o '[a-z_]*' | tail -1)"
64+
menuselect/menuselect --enable app_mixmonitor menuselect.makeopts || warn "Module not found: $(echo 'menuselect/menuselect --enable app_mixmonitor menuselect.makeopts' | grep -o '[a-z_]*' | tail -1)"
65+
66+
# Enable CDR and CEL modules
67+
68+
# Enable channel drivers
69+
menuselect/menuselect --enable chan_pjsip menuselect.makeopts || warn "Module not found: $(echo 'menuselect/menuselect --enable chan_pjsip menuselect.makeopts' | grep -o '[a-z_]*' | tail -1)"
70+
menuselect/menuselect --enable chan_iax2 menuselect.makeopts || warn "Module not found: $(echo 'menuselect/menuselect --enable chan_iax2 menuselect.makeopts' | grep -o '[a-z_]*' | tail -1)"
71+
menuselect/menuselect --enable chan_local menuselect.makeopts || warn "Module not found: $(echo 'menuselect/menuselect --enable chan_local menuselect.makeopts' | grep -o '[a-z_]*' | tail -1)"
72+
menuselect/menuselect --enable chan_bridge_media menuselect.makeopts || warn "Module not found: $(echo 'menuselect/menuselect --enable chan_bridge_media menuselect.makeopts' | grep -o '[a-z_]*' | tail -1)"
73+
74+
# Enable resource modules
75+
menuselect/menuselect --enable res_musiconhold menuselect.makeopts || warn "Module not found: $(echo 'menuselect/menuselect --enable res_musiconhold menuselect.makeopts' | grep -o '[a-z_]*' | tail -1)"
76+
menuselect/menuselect --enable res_pjsip menuselect.makeopts || warn "Module not found: $(echo 'menuselect/menuselect --enable res_pjsip menuselect.makeopts' | grep -o '[a-z_]*' | tail -1)"
77+
menuselect/menuselect --enable res_pjsip_session menuselect.makeopts || warn "Module not found: $(echo 'menuselect/menuselect --enable res_pjsip_session menuselect.makeopts' | grep -o '[a-z_]*' | tail -1)"
78+
menuselect/menuselect --enable res_pjsip_outbound_registration menuselect.makeopts || warn "Module not found: $(echo 'menuselect/menuselect --enable res_pjsip_outbound_registration menuselect.makeopts' | grep -o '[a-z_]*' | tail -1)"
79+
menuselect/menuselect --enable res_pjsip_registrar menuselect.makeopts || warn "Module not found: $(echo 'menuselect/menuselect --enable res_pjsip_registrar menuselect.makeopts' | grep -o '[a-z_]*' | tail -1)"
80+
menuselect/menuselect --enable res_rtp_asterisk menuselect.makeopts || warn "Module not found: $(echo 'menuselect/menuselect --enable res_rtp_asterisk menuselect.makeopts' | grep -o '[a-z_]*' | tail -1)"
81+
menuselect/menuselect --enable res_timing_timerfd menuselect.makeopts || warn "Module not found: $(echo 'menuselect/menuselect --enable res_timing_timerfd menuselect.makeopts' | grep -o '[a-z_]*' | tail -1)"
82+
menuselect/menuselect --enable res_crypto menuselect.makeopts || warn "Module not found: $(echo 'menuselect/menuselect --enable res_crypto menuselect.makeopts' | grep -o '[a-z_]*' | tail -1)"
83+
84+
# Disable unwanted modules
85+
menuselect/menuselect --disable chan_dahdi menuselect.makeopts || warn "Module not found: $(echo 'menuselect/menuselect --disable chan_dahdi menuselect.makeopts' | grep -o '[a-z_]*' | tail -1)"
86+
menuselect/menuselect --disable chan_misdn menuselect.makeopts || warn "Module not found: $(echo 'menuselect/menuselect --disable chan_misdn menuselect.makeopts' | grep -o '[a-z_]*' | tail -1)"
87+
menuselect/menuselect --disable app_festival menuselect.makeopts || warn "Module not found: $(echo 'menuselect/menuselect --disable app_festival menuselect.makeopts' | grep -o '[a-z_]*' | tail -1)"
88+
89+
90+
log "Module configuration completed"
91+
92+
93+
# Build Asterisk
94+
log "Building Asterisk core (this may take several minutes)..."
95+
TMPDIR=${TMPDIR} make -j $JOBS all
96+
log "Installing Asterisk..."
97+
TMPDIR=${TMPDIR} make install
98+
log "Installing sample configurations..."
99+
TMPDIR=${TMPDIR} make samples
100+
101+
102+
103+
# Strip binaries to reduce size
104+
log "Stripping binaries to reduce image size..."
105+
find /usr/sbin /usr/lib/asterisk -type f -executable \
106+
-exec strip --strip-unneeded {} + 2>/dev/null || true
107+
108+
log "Asterisk 18.9-cert18 build completed successfully!"

0 commit comments

Comments
 (0)