Trim comments to the non-obvious why
Drop narration, history and restated-code comments across the repo, keep short ones for security boundaries, upstream quirks and ordering constraints, and record the convention in CLAUDE.md. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
+2
-28
@@ -1,31 +1,5 @@
|
||||
# =============================================================================
|
||||
# Radio image — liquidsoap base with icecast2 added on top.
|
||||
#
|
||||
# BASE CHOICE: savonet/liquidsoap:v2.3.2, pinned. Liquidsoap is by far the
|
||||
# harder of the two to install (OCaml toolchain, many audio codecs), so the
|
||||
# image starts from the official liquidsoap build and adds icecast2 from apt,
|
||||
# rather than the other way round. Both daemons then run in one container so
|
||||
# liquidsoap can reach icecast on localhost — see icecast2/entrypoint.sh.
|
||||
#
|
||||
# PACKAGES
|
||||
# icecast2 the streaming server itself
|
||||
# gettext provides `envsubst` for rendering the two config templates
|
||||
# media-types the /etc/mime.types database; without it icecast serves the
|
||||
# stream and its status pages with wrong content types
|
||||
#
|
||||
# THE USER SWITCH: apt needs root, so the image switches to root, installs,
|
||||
# creates an unprivileged `radio` user, chowns everything the two daemons will
|
||||
# need to write (icecast config, its logs, the music dir, the liquidsoap config
|
||||
# dir) and then drops back to `radio` for the rest. Neither daemon runs as
|
||||
# root, which is also why icecast.xml sets <chroot>0</chroot> — an unprivileged
|
||||
# process cannot chroot anyway.
|
||||
#
|
||||
# The chown of /music matters even though it is mounted read-only at runtime:
|
||||
# the mount inherits ownership from the host, and the directory must exist
|
||||
# before the mount lands.
|
||||
#
|
||||
# The apt install is Debian-based and multi-arch; no platform pin needed on the Pi.
|
||||
# =============================================================================
|
||||
# liquidsoap base (the hard one to install) plus icecast2. media-types gives
|
||||
# icecast correct content types. Both daemons run as `radio`, hence chroot 0.
|
||||
FROM savonet/liquidsoap:v2.3.2
|
||||
USER root
|
||||
RUN apt-get update \
|
||||
|
||||
+3
-48
@@ -1,52 +1,7 @@
|
||||
#!/bin/bash
|
||||
# =============================================================================
|
||||
# icecast2 entrypoint — runs the streaming server AND its audio source together.
|
||||
#
|
||||
# WHAT IT DOES
|
||||
# This one container holds two cooperating daemons:
|
||||
# icecast2 - the HTTP streaming server listeners connect to. Caddy
|
||||
# proxies /radio/ to it.
|
||||
# liquidsoap - the *source*: it decides what audio to play and pushes a
|
||||
# single MP3 stream into icecast's mount point.
|
||||
# They are colocated because liquidsoap connects to icecast over
|
||||
# host="localhost" (see stream.liq.template) — no network hop, and the source
|
||||
# password never leaves the container.
|
||||
#
|
||||
# WHEN IT RUNS
|
||||
# Container start (ENTRYPOINT), in both dev and production.
|
||||
#
|
||||
# THE TEMPLATING STEP
|
||||
# Both configs are rendered by bare `envsubst` (no allow-list) because unlike
|
||||
# the old nginx templates, neither icecast.xml nor stream.liq has any legitimate
|
||||
# dollar-token of its own — every ${VAR} in them is meant to be substituted,
|
||||
# so an unrestricted envsubst is safe here. NOTE the consequence: any
|
||||
# referenced variable that is unset silently becomes an empty string, which
|
||||
# for a password field means "empty password" rather than an error.
|
||||
#
|
||||
# STARTUP ORDER AND THE sleep 2
|
||||
# liquidsoap's output.icecast connects to icecast as a client on startup and
|
||||
# there is no readiness check available, so the script backgrounds icecast,
|
||||
# waits a fixed 2 seconds for it to bind its port, then starts liquidsoap.
|
||||
# It is a race, not a guarantee — but `fallible=true` in stream.liq means
|
||||
# liquidsoap retries the connection rather than dying if it loses.
|
||||
#
|
||||
# PROCESS SUPERVISION
|
||||
# `wait -n` returns as soon as EITHER daemon exits. We then kill whatever is
|
||||
# still running and exit 1, so a half-dead container (icecast up, liquidsoap
|
||||
# dead = silence forever) becomes a full crash that docker's
|
||||
# `restart: always` will recycle. Exiting non-zero is deliberate.
|
||||
#
|
||||
# ENV VARS REQUIRED (from ./.env)
|
||||
# ICECAST_SOURCE_PASSWORD shared by icecast (accepts) and liquidsoap (sends)
|
||||
# ICECAST_RELAY_PASSWORD for relay clients
|
||||
# ICECAST_ADMIN_USER / ICECAST_ADMIN_PASSWORD icecast web admin
|
||||
# ICECAST_HOST / ICECAST_PORT / ICECAST_MOUNT listener-facing stream
|
||||
# LIQUIDSOAP_HARBOR_MOUNT / LIQUIDSOAP_HARBOR_PORT live DJ input
|
||||
#
|
||||
# ASSUMES EXISTS
|
||||
# /music - read-only bind mount of ./icecast2/fallback_music, the fallback
|
||||
# playlist. If it is empty the stream falls through to silence.
|
||||
# =============================================================================
|
||||
# Runs icecast2 and liquidsoap together (liquidsoap feeds icecast over
|
||||
# localhost). Bare envsubst: an unset variable becomes "", including passwords.
|
||||
# If either daemon exits the container exits 1, so restart: always recycles it.
|
||||
set -e
|
||||
|
||||
envsubst < /etc/icecast2/icecast.xml.template > /etc/icecast2/icecast.xml
|
||||
|
||||
@@ -1,41 +1,7 @@
|
||||
# =============================================================================
|
||||
# stream.liq.template — liquidsoap source script for the internet radio.
|
||||
#
|
||||
# RENDERED BY icecast2/entrypoint.sh with bare envsubst into
|
||||
# /etc/liquidsoap/stream.liq at container start. Every VAR placeholder below comes from
|
||||
# ./.env; an unset one silently becomes an empty string.
|
||||
#
|
||||
# WHAT IT BUILDS, bottom of the fallback chain upward:
|
||||
# blank() - digital silence; the last resort so the mount is never dropped.
|
||||
# music - the fallback playlist read from the /music bind mount
|
||||
# (./icecast2/fallback_music on the host). reload_mode="watch"
|
||||
# means adding or removing an MP3 on the host is picked up live,
|
||||
# with no container restart.
|
||||
# live - a *harbor* input: liquidsoap itself listens on
|
||||
# LIQUIDSOAP_HARBOR_PORT and accepts an incoming source
|
||||
# connection. This is the "go live" path — a broadcasting client
|
||||
# on the LAN/internet connects with ICECAST_SOURCE_PASSWORD and
|
||||
# starts talking. It is the one reason icecast2 publishes a host
|
||||
# port in docker-compose.yml.
|
||||
#
|
||||
# fallback(track_sensitive=false, [live, music, blank()])
|
||||
# Picks the first available source in list order, so a live DJ pre-empts
|
||||
# the playlist automatically. track_sensitive=false is the important flag:
|
||||
# it makes the switch happen IMMEDIATELY rather than politely waiting for
|
||||
# the current track to finish — otherwise going live could take minutes.
|
||||
#
|
||||
# amplify(0.7, ...) - a fixed -3dB or so trim, because the fallback MP3s are
|
||||
# mastered loud and were clipping against the live input.
|
||||
#
|
||||
# OUTPUT
|
||||
# Pushes to icecast on localhost (same container) at ICECAST_MOUNT, which is
|
||||
# what Caddy exposes at /radio/. fallible=true tells liquidsoap this output
|
||||
# is allowed to fail and be retried, instead of aborting the script — that is
|
||||
# what makes the `sleep 2` startup race in the entrypoint survivable.
|
||||
#
|
||||
# settings.server.telnet := false — the liquidsoap control socket is off; there
|
||||
# is no interactive way to poke the running stream.
|
||||
# =============================================================================
|
||||
# Rendered by entrypoint.sh. Fallback chain: live harbor input, then the
|
||||
# watched /music playlist, then silence. track_sensitive=false switches to a
|
||||
# live DJ immediately. amplify trims the loud fallback MP3s. fallible=true
|
||||
# survives the entrypoint's startup race.
|
||||
settings.server.telnet := false
|
||||
|
||||
music = playlist("/music", mode="randomize", reload_mode="watch")
|
||||
|
||||
Reference in New Issue
Block a user