Add fallback music to icecast server
Some checks failed
Deploy with Docker Compose / deploy (push) Has been cancelled

This commit is contained in:
2026-03-10 12:58:53 +00:00
parent cd1bcc7f39
commit 469a225860
5 changed files with 36 additions and 42 deletions

3
.gitignore vendored
View File

@@ -47,5 +47,8 @@ coverage
# Vitest
__screenshots__/
icecast2/fallback_music/
!icecast2/fallback_music/.gitkeep
.deploy
*.xcf

View File

@@ -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

View File

@@ -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" ]

View File

@@ -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

View File

@@ -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
)