diff --git a/.gitignore b/.gitignore index 4316c66..612d60f 100644 --- a/.gitignore +++ b/.gitignore @@ -47,5 +47,8 @@ coverage # Vitest __screenshots__/ +icecast2/fallback_music/ +!icecast2/fallback_music/.gitkeep + .deploy *.xcf diff --git a/docker-compose.yml b/docker-compose.yml index e178638..dd9bdbc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -80,6 +80,10 @@ services: - app-network env_file: - ./.env + volumes: + - ./icecast2/fallback_music:/music:ro + ports: + - "${LIQUIDSOAP_HARBOR_PORT:-8001}:${LIQUIDSOAP_HARBOR_PORT:-8001}" gitea-runner: image: gitea/act_runner:latest diff --git a/icecast2/Dockerfile b/icecast2/Dockerfile index 2474b0e..50d8603 100644 --- a/icecast2/Dockerfile +++ b/icecast2/Dockerfile @@ -1,19 +1,13 @@ -FROM debian:latest as builder - -WORKDIR /app - - +FROM savonet/liquidsoap:v2.3.2 +USER root RUN apt-get update \ - && apt-get install --yes icecast2 gettext media-types -# RUN apt-get install --yes liquidsoap - + && apt-get install --yes icecast2 gettext media-types \ + && rm -rf /var/lib/apt/lists/* RUN useradd radio -RUN chown -R radio:radio /etc/icecast2 /var/log/icecast2 -# RUN chown -R radio:radio /etc/liquidsoap /var/log/liquidsoap +RUN mkdir -p /music +RUN chown -R radio:radio /etc/icecast2 /var/log/icecast2 /music USER radio - COPY icecast.xml.template /etc/icecast2/icecast.xml.template -# COPY stream.liq.template /etc/liquidsoap/stream.liq.template +COPY stream.liq.template /etc/liquidsoap/stream.liq.template COPY entrypoint.sh /entrypoint.sh - ENTRYPOINT [ "/entrypoint.sh" ] diff --git a/icecast2/entrypoint.sh b/icecast2/entrypoint.sh index 19510bc..fbfdcc1 100755 --- a/icecast2/entrypoint.sh +++ b/icecast2/entrypoint.sh @@ -1,11 +1,12 @@ -#!/bin/sh +#!/bin/bash set -e -# Substitute environment variables into template envsubst < /etc/icecast2/icecast.xml.template > /etc/icecast2/icecast.xml -# envsubst < /etc/liquidsoap/stream.liq.template > /etc/liquidsoap/stream.liq +envsubst < /etc/liquidsoap/stream.liq.template > /etc/liquidsoap/stream.liq -# Run icecast with the generated config -exec icecast2 -c /etc/icecast2/icecast.xml -# exec liquidsoap /etc/liquidsoap/stream.liq -# wait -n +icecast2 -c /etc/icecast2/icecast.xml & +sleep 2 +liquidsoap /etc/liquidsoap/stream.liq & +wait -n +kill $(jobs -p) 2>/dev/null || true +exit 1 diff --git a/icecast2/stream.liq.template b/icecast2/stream.liq.template index edca4ff..498c3ef 100644 --- a/icecast2/stream.liq.template +++ b/icecast2/stream.liq.template @@ -1,24 +1,16 @@ -[general] -duration = 0 # 0 = run forever -bufferSecs = 5 # buffer size in seconds -reconnect = yes # reconnect on failure -reconnectDelay = 5 +settings.server.telnet.set(false) -[input] -device = pulse # PulseAudio input -sampleRate = 44100 # in Hz -bitsPerSample = 16 -channel = 2 +music = playlist("/music", mode="randomize", reload_mode="watch") -[icecast2-0] -bitrateMode = cbr -bitrate = 128 # kbps -format = mp3 -server = ${ICECAST_HOST} -port = ${ICECAST_PORT} -password = ${ICECAST_SOURCE_PASSWORD} -mountPoint = ${ICECAST_MOUNT} -name = "Live DJ stream" -description = "Live microphone stream" -genre = "Various" -public = yes +live = input.harbor("${LIQUIDSOAP_HARBOR_MOUNT}", port=${LIQUIDSOAP_HARBOR_PORT}, password="${ICECAST_SOURCE_PASSWORD}") + +radio = fallback(track_sensitive=false, [live, music, blank()]) + +output.icecast( + %mp3, + host="localhost", + port=${ICECAST_PORT}, + password="${ICECAST_SOURCE_PASSWORD}", + mount="${ICECAST_MOUNT}", + radio +)