Skip to content

Commit

Permalink
Overhaul Dockerfile
Browse files Browse the repository at this point in the history
Switch from ubuntu:focal to debian:bookworm-slim for smaller image and newer
opam.

Add ffmpeg and ssl support.

Two-stage build to remove build dependencies from final image.
  • Loading branch information
cdhowie committed Jul 19, 2024
1 parent 70b04f4 commit 65f29d8
Showing 1 changed file with 57 additions and 18 deletions.
75 changes: 57 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
FROM ubuntu:focal

LABEL maintainer="Kirill Plotnikov <[email protected]>" \
github="https://github.com/pltnk/docker-liquidsoap"
FROM debian:bookworm-slim AS builder

ENV DEBIAN_FRONTEND=noninteractive

Expand All @@ -10,11 +7,20 @@ RUN apt update && apt upgrade -y && \
apt install -y \
opam \
gcc \
libavcodec-dev \
libavdevice-dev \
libavfilter-dev \
libavformat-dev \
libavutil-dev \
libswresample-dev \
libswscale-dev \
libcurl4-gnutls-dev \
libmad0-dev \
libmp3lame-dev \
libogg-dev \
libpcre3-dev \
libsamplerate0-dev \
libssl-dev \
libtag1-dev \
libvorbis-dev \
m4 \
Expand All @@ -24,26 +30,59 @@ RUN apt update && apt upgrade -y && \
apt autoremove && apt clean && \
rm -rf /var/lib/apt/lists/*

# add user for liquidsoap and create necessary directories
RUN groupadd -g 999 radio && \
useradd -m -r -u 999 -s /bin/bash -g radio radio && \
mkdir /etc/liquidsoap /music && \
chown -R radio /etc/liquidsoap /music

ARG LIQUIDSOAP_VERSION
ARG OPAM_PACKAGES="liquidsoap${LIQUIDSOAP_VERSION:+.$LIQUIDSOAP_VERSION} taglib mad lame vorbis cry samplerate"

USER radio
ARG OPAM_PACKAGES="liquidsoap${LIQUIDSOAP_VERSION:+.$LIQUIDSOAP_VERSION} taglib mad lame vorbis cry samplerate ssl ffmpeg"

# setup opam
RUN opam init -a -y --disable-sandboxing && \
eval $(opam env) && \
opam install -y depext
RUN opam init -a -y --disable-sandboxing

# install liquidsoap
RUN opam depext -y ${OPAM_PACKAGES} && \
opam install -y ${OPAM_PACKAGES} && \
RUN opam install -y ${OPAM_PACKAGES} && \
eval $(opam env) && \
opam clean -acryv --logs --unused-repositories

CMD eval $(opam env) && liquidsoap /etc/liquidsoap/script.liq


FROM debian:bookworm-slim

LABEL maintainer="Kirill Plotnikov <[email protected]>" \
github="https://github.com/pltnk/docker-liquidsoap"

ENV DEBIAN_FRONTEND=noninteractive

RUN apt update && apt upgrade -y && \
apt install -y \
libavcodec59 \
libavdevice59 \
libavfilter8 \
libavformat59 \
libavutil57 \
libcurl3-gnutls \
libmad0 \
libmp3lame0 \
libogg0 \
libpcre3 \
libsamplerate0 \
libssl3 \
libswresample4 \
libswscale6 \
libtag1v5-vanilla \
libvorbis0a \
libvorbisenc2 \
libvorbisfile3 \
&& \
apt autoremove && apt clean && \
rm -rf /var/lib/apt/lists/*

COPY --from=builder /root/.opam/default/bin/liquidsoap /usr/local/bin

# add user for liquidsoap and create necessary directories
RUN groupadd -g 999 radio && \
useradd -m -r -u 999 -s /bin/bash -g radio radio && \
mkdir /etc/liquidsoap /music && \
chown -R radio /etc/liquidsoap /music

USER radio

CMD liquidsoap /etc/liquidsoap/script.liq

0 comments on commit 65f29d8

Please sign in to comment.