Skip to content

Commit

Permalink
feat: support multiarch optimized images
Browse files Browse the repository at this point in the history
  • Loading branch information
davidecavestro committed Dec 30, 2024
1 parent e6169d0 commit 564b34b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 39 deletions.
45 changes: 12 additions & 33 deletions .github/workflows/build_and_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,42 +50,21 @@ jobs:
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ github.ref_name }}-huge
ghcr.io/${{ github.repository }}:${{ github.ref_name }}
${{ github.repository }}:${{ github.ref_name }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Setup jq
uses: dcarbone/install-jq-action@v3
with:
version: "1.7"
force: true

- name: Squash the image
run: |
docker pull ghcr.io/${{ github.repository }}:${{ github.ref_name }}-huge && \
docker pull debian:bookworm && \
FROM_LAYER=$(docker inspect --format='{{json .RootFS.Layers}}' ghcr.io/${{ github.repository }}:${{ github.ref_name }}-huge \
| jq -r --arg layer $(docker inspect --format='{{json .RootFS.Layers}}' debian:bookworm \
| jq -r '.[-1]') ' . as $layers | ($layers | index($layer) + 1) as $start | ($layers | length - $start)'\
) && \
echo "FROM_LAYER: $FROM_LAYER" && \
docker-squash \
--from-layer $FROM_LAYER \
--tag ghcr.io/${{ github.repository }}:${{ github.ref_name }} \
ghcr.io/${{ github.repository }}:${{ github.ref_name }}-huge
- name: Push squashed image
run: |
docker push ghcr.io/${{ github.repository }}:${{ github.ref_name }} && \
docker tag ghcr.io/${{ github.repository }}:${{ github.ref_name }} ${{ github.repository }}:${{ github.ref_name }} && \
docker push ${{ github.repository }}:${{ github.ref_name }}

- name: Push latest image
run: |
docker tag ghcr.io/${{ github.repository }}:${{ github.ref_name }} ghcr.io/${{ github.repository }}:latest && \
docker push ghcr.io/${{ github.repository }}:latest && \
docker tag ghcr.io/${{ github.repository }}:${{ github.ref_name }} ${{ github.repository }}:latest && \
docker push ${{ github.repository }}:latest
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ github.repository }}:latest
${{ github.repository }}:latest
cache-from: type=gha
if: startsWith(github.ref, 'refs/tags/')

- name: Docker Hub Description
Expand Down
32 changes: 26 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,24 @@ RUN \
&& mv /etc/asterisk/* /opt/asterisk-samples/

# Cleanup
RUN \
make dist-clean \
&& make clean
# RUN \
# make dist-clean \
# && make clean

FROM debian:bookworm

COPY --from=builder /etc/asterisk /etc/asterisk
COPY --from=builder /run/asterisk /run/asterisk
COPY --from=builder /run/asterisk /run/asterisk
COPY --from=builder /usr/lib/asterisk /usr/lib/asterisk
COPY --from=builder /usr/lib/libasterisk* /usr/lib/
COPY --from=builder /usr/sbin /usr/sbin
COPY --from=builder /usr/share/man /usr/share/man
COPY --from=builder /var/cache/asterisk /var/cache/asterisk
COPY --from=builder /var/lib/asterisk /var/lib/asterisk
COPY --from=builder /var/log/asterisk /var/log/asterisk
COPY --from=builder /var/spool/asterisk /var/spool/asterisk
COPY --from=builder /opt/asterisk-samples /opt/asterisk-samples

# Postinstall
RUN \
Expand All @@ -159,11 +174,16 @@ RUN \
&& chmod -R 750 /var/spool/asterisk
# Optional packages
RUN \
apt-get update && \
apt-get install -y --no-install-recommends \
sendemail libnet-ssleay-perl \
libio-socket-ssl-perl libcap2-bin curl sox

RUN \
libio-socket-ssl-perl libcap2-bin curl sox \
uuid libxml2 libxslt1.1 libresample1 libc-client2007e binutils libgsm1 doxygen zlib1g libsndfile1 \
libunbound8 libfftw3-bin libfftw3-single3 libcodec2-1.0 libsrtp2-1 libc-client2007e libspandsp2 gir1.2-ical-3.0 libical3 \
libpopt0 libnewt0.52 libcfg7 libcorosync-common4 libiksemel3 libcap2 libjack-jackd2-0 libradcli4 libbluetooth3 libssl3 \
liburiparser1 liblua5.2-0 libgmime-3.0-0 gir1.2-gmime-3.0 libneon27 libpq5 xmlstarlet bison flex \
libcurl4 libportaudio2 libportaudiocpp0 libasound2 libvorbis0a libvorbisenc2 libvorbisfile3 libogg0 libspeexdsp1 libspeex1 \
&& \
rm -rf /var/lib/apt/lists/*

EXPOSE 5060/udp 5061/udp 5062/udp
Expand Down

0 comments on commit 564b34b

Please sign in to comment.