|
| 1 | +# Alpine Asterisk image - installs prebuilt, signed apks from the sibling |
| 2 | +# project's Cloudsmith repository (andrius/asterisk-alpine). There is no build |
| 3 | +# stage: the .apk already contains the compiled, module-selected Asterisk. |
| 4 | +# Generated from YAML configuration - DO NOT EDIT MANUALLY |
| 5 | +FROM alpine:3.24 |
| 6 | + |
| 7 | +LABEL maintainer="Andrius Kairiukstis <k@andrius.mobi>" |
| 8 | +LABEL org.opencontainers.image.title="Asterisk PBX" |
| 9 | +LABEL org.opencontainers.image.description="Asterisk PBX 22.8-cert4 on Alpine (apk)" |
| 10 | +LABEL org.opencontainers.image.version="22.8-cert4" |
| 11 | +LABEL org.opencontainers.image.source="https://github.com/andrius/asterisk" |
| 12 | +LABEL org.opencontainers.image.vendor="Andrius Kairiukstis <k@andrius.mobi>" |
| 13 | + |
| 14 | +# Trust the Cloudsmith repository signing key (vendored; copied into the build |
| 15 | +# context alongside this Dockerfile). |
| 16 | +COPY cloudsmith-asterisk-alpine.rsa.pub /etc/apk/keys/alpine@asterisk-25B0C9A992BE0CEF.rsa.pub |
| 17 | + |
| 18 | +# Add the pinned apk repository and install Asterisk + the selected subpackages |
| 19 | +# at an exact version, plus the runtime tools the entrypoint/healthcheck need. |
| 20 | +# The @andrius-asterisk tag keeps these from clashing with Alpine's own |
| 21 | +# asterisk in the main repo; the exact "=version-rN" pin makes rebuilds |
| 22 | +# reproducible (or fail loudly if the apk was pruned). |
| 23 | +RUN echo "@andrius-asterisk https://dl.cloudsmith.io/public/asterisk/alpine/alpine/v3.24/main" >>/etc/apk/repositories \ |
| 24 | + && apk add --no-cache \ |
| 25 | + "asterisk@andrius-asterisk=22.8.0.4-r1" \ |
| 26 | + "asterisk-sample-config@andrius-asterisk=22.8.0.4-r1" \ |
| 27 | + "asterisk-opus@andrius-asterisk=22.8.0.4-r1" \ |
| 28 | + "asterisk-srtp@andrius-asterisk=22.8.0.4-r1" \ |
| 29 | + "asterisk-curl@andrius-asterisk=22.8.0.4-r1" \ |
| 30 | + "asterisk-speex@andrius-asterisk=22.8.0.4-r1" \ |
| 31 | + "asterisk-fax@andrius-asterisk=22.8.0.4-r1" \ |
| 32 | + "asterisk-odbc@andrius-asterisk=22.8.0.4-r1" \ |
| 33 | + "asterisk-mobile@andrius-asterisk=22.8.0.4-r1" \ |
| 34 | + bash \ |
| 35 | + shadow \ |
| 36 | + gettext \ |
| 37 | + procps \ |
| 38 | + ca-certificates \ |
| 39 | + curl \ |
| 40 | + tzdata \ |
| 41 | + && asterisk -V |
| 42 | + |
| 43 | +# The asterisk apk creates the asterisk user (uid 100, home /var/lib/asterisk). |
| 44 | +# Normalize it to the Debian image's identity (uid/gid 1000, home |
| 45 | +# /home/asterisk, bash shell) so both image families behave identically and |
| 46 | +# cloud/orchestration setups see a consistent uid. The entrypoint's PUID/PGID |
| 47 | +# remap then no-ops on the default, exactly as on Debian. |
| 48 | +RUN groupmod -g 1000 asterisk \ |
| 49 | + && usermod -u 1000 -g 1000 -d /home/asterisk -s /bin/bash asterisk \ |
| 50 | + && mkdir -p \ |
| 51 | + /home/asterisk \ |
| 52 | + /var/run/asterisk \ |
| 53 | + /var/log/asterisk \ |
| 54 | + /var/spool/asterisk/monitor \ |
| 55 | + /var/spool/asterisk/outgoing \ |
| 56 | + /var/spool/asterisk/tmp \ |
| 57 | + /var/spool/asterisk/voicemail \ |
| 58 | + /var/spool/asterisk/fax \ |
| 59 | + /var/lib/asterisk/keys \ |
| 60 | + /var/lib/asterisk/phoneprov \ |
| 61 | + /var/lib/asterisk/sounds \ |
| 62 | + /var/lib/asterisk/docs |
| 63 | + |
| 64 | +# Healthcheck + entrypoint (the shared bash partials; bash + shadow are |
| 65 | +# installed above so usermod/groupmod PUID/PGID remap works unchanged). |
| 66 | +COPY healthcheck.sh /usr/local/bin/healthcheck.sh |
| 67 | +COPY entrypoint.sh /usr/local/bin/entrypoint.sh |
| 68 | +RUN chmod +x /usr/local/bin/healthcheck.sh /usr/local/bin/entrypoint.sh \ |
| 69 | + && chown -R asterisk:asterisk \ |
| 70 | + /etc/asterisk \ |
| 71 | + /home/asterisk \ |
| 72 | + /var/lib/asterisk \ |
| 73 | + /var/log/asterisk \ |
| 74 | + /var/spool/asterisk \ |
| 75 | + /var/run/asterisk \ |
| 76 | + && chmod -R 750 /var/spool/asterisk |
| 77 | + |
| 78 | +# Networking (documented; publish explicitly at run time). |
| 79 | +# EXPOSE 5060/udp |
| 80 | +# EXPOSE 5060/tcp |
| 81 | +# EXPOSE 10000-20000/udp |
| 82 | +VOLUME ["/var/lib/asterisk/sounds", "/var/lib/asterisk/keys", "/var/lib/asterisk/phoneprov", "/var/spool/asterisk", "/var/log/asterisk", "/etc/asterisk"] |
| 83 | +# Health check |
| 84 | +HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \ |
| 85 | + CMD /usr/local/bin/healthcheck.sh |
| 86 | + |
| 87 | +# Entrypoint runs as root, remaps the asterisk uid/gid to PUID/PGID, then execs |
| 88 | +# CMD. Asterisk drops privileges itself via the -U/-p flags below. |
| 89 | +ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] |
| 90 | +WORKDIR /home/asterisk |
| 91 | +CMD ["/usr/sbin/asterisk", "-vvvdddf", "-T", "-W", "-U", "asterisk", "-p"] |
0 commit comments