Browse Source

use environment variables for creds and add stations

Steven Jacobs 2 years ago
parent
commit
247e13f84b
5 changed files with 61 additions and 17 deletions
  1. 3 0
      docker-compose.yml
  2. 7 8
      icecast/Dockerfile
  3. 8 0
      icecast/docker-entrypoint.sh
  4. 6 6
      icecast/icecast.xml
  5. 37 3
      liquidsoap/radio.liq

+ 3 - 0
docker-compose.yml

@@ -2,6 +2,9 @@ version: '2'
 
 services:
   icecast:
+    env_file: .env
+    build:
+      context: icecast/
     image: vitiman/alpine-icecast:latest
     ports:
       - "8000:8000"

+ 7 - 8
icecast/Dockerfile

@@ -1,21 +1,17 @@
-FROM alpine:3.3
-MAINTAINER @VITIMan https://github.com/VITIMan 
+FROM alpine:3.6
 
-ENV ICECAST_VERSION 2.4.2-r1
-
-# https://docs.docker.com/engine/reference/builder/#arg
-# docker run -p 8000:8000 --net music_stack --name=icecast -d alpine-icecast:dev
 ARG user=icecast
 ARG group=icecast
 # ARG uid=1000
 # ARG gid=1000
 
 RUN apk -q update \
-    && apk -q --no-progress add icecast="$ICECAST_VERSION" \
+    && apk -q --no-progress add icecast \
     && rm -rf /var/cache/apk/*
 
+COPY docker-entrypoint.sh /usr/local/bin/
 COPY silence.ogg /usr/share/icecast/silence.ogg
-COPY icecast.xml /usr/share/icecast/icecast.xml
+COPY icecast.xml.template /usr/share/icecast/icecast.xml.template
 
 RUN mkdir -p /var/log/icecast \
     && chown -R ${user}:${group} /usr/share/icecast \
@@ -24,4 +20,7 @@ RUN mkdir -p /var/log/icecast \
 EXPOSE 8000
 
 USER ${user}
+
+ENTRYPOINT ["docker-entrypoint.sh"]
+
 CMD ["icecast", "-c", "/usr/share/icecast/icecast.xml"]

+ 8 - 0
icecast/docker-entrypoint.sh

@@ -0,0 +1,8 @@
+#!/bin/sh
+set -e
+
+if ls "/usr/share/icecast/icecast.xml.template" 1> /dev/null 2>&1; then
+    sed "s/{{ ICECAST_PASSWORD }}/${ICECAST_PASSWORD}/g" /usr/share/icecast/icecast.xml.template >| /usr/share/icecast/icecast.xml
+fi
+
+exec "$@"

+ 6 - 6
icecast/icecast.xml

@@ -7,14 +7,14 @@
 
     <limits>
         <clients>100</clients>
-        <sources>2</sources>
+        <sources>5</sources>
         <threadpool>5</threadpool>
         <queue-size>524288</queue-size>
         <client-timeout>30</client-timeout>
         <header-timeout>15</header-timeout>
         <source-timeout>10</source-timeout>
-        <!-- If enabled, this will provide a burst of data when a client 
-             first connects, thereby significantly reducing the startup 
+        <!-- If enabled, this will provide a burst of data when a client
+             first connects, thereby significantly reducing the startup
              time for listeners that do substantial buffering. However,
              it also significantly increases latency between the source
              client and listening client.  For low-latency setups, you
@@ -28,13 +28,13 @@
 
     <authentication>
         <!-- Sources log in with username 'source' -->
-        <source-password>hackme</source-password>
+        <source-password>{{ ICECAST_PASSWORD }}</source-password>
         <!-- Relays log in username 'relay' -->
-        <relay-password>hackme</relay-password>
+        <relay-password>{{ ICECAST_PASSWORD }}</relay-password>
 
         <!-- Admin logs in with the username given below -->
         <admin-user>admin</admin-user>
-        <admin-password>hackme</admin-password>
+        <admin-password>{{ ICECAST_PASSWORD }}</admin-password>
     </authentication>
 
     <!-- set the mountpoint for a shoutcast source to use, the default if not

+ 37 - 3
liquidsoap/radio.liq

@@ -13,10 +13,44 @@ m = on_metadata(apply_metadata,music)
 
 output.icecast(
     %vorbis,
-    id="radio",
+    id="music",
     host="icecast",
     port=8000,
-    password="hackme",
+    password=getenv("ICECAST_PASSWORD"),
     fallible=true,
-    mount="radio.ogg",
+    mount="music.ogg",
     m)
+
+random = playlist(
+    "/srv/audio/music/.playlists/random.m3u",
+    prefix="/srv/audio/music/",
+    conservative=true)
+
+r = on_metadata(apply_metadata,random)
+
+output.icecast(
+    %vorbis,
+    id="random",
+    host="icecast",
+    port=8000,
+    password=getenv("ICECAST_PASSWORD"),
+    fallible=true,
+    mount="random.ogg",
+    r)
+
+outdoors = playlist(
+    "/srv/audio/music/.playlists/outdoors.m3u",
+    prefix="/srv/audio/music/",
+    conservative=true)
+
+o = on_metadata(apply_metadata,outdoors)
+
+output.icecast(
+    %vorbis,
+    id="outdoors",
+    host="icecast",
+    port=8000,
+    password=getenv("ICECAST_PASSWORD"),
+    fallible=true,
+    mount="outdoors.ogg",
+    o)