Skip to content

Commit

Permalink
Improve liquisoap
Browse files Browse the repository at this point in the history
- Add tests
- Add documentation
- Fix typos
  • Loading branch information
mblaschke committed Apr 7, 2017
1 parent 93a4fb8 commit afe4e0c
Show file tree
Hide file tree
Showing 10 changed files with 141 additions and 60 deletions.
24 changes: 12 additions & 12 deletions docker/liquidsoap/latest/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,27 @@ RUN /usr/local/bin/apt-install \
&& /usr/local/bin/docker-image-cleanup

ENV LIQUIDSOAP_USER "liquidsoap"
ENV LIQUIBASE_TELNET "1"
ENV LIQUIDSOAP_TELNET "1"

ENV LIQUIDSOAP_SCRIPT "/opt/docker/etc/liquidsoap/default.liq"
ENV LIQUIDSOAP_TEMPLATE "/opt/docker/etc/liquidsoap/default.liq"

ENV LIQUIBASE_STREAM_INPUT "http://icecast:8000/live"
ENV LIQUIDSOAP_STREAM_INPUT "http://icecast:8000/live"

ENV LIQUIBASE_PLAYLIST_DEFAULT "audio_to_stereo(single('/opt/docker/etc/liquidsoap/default.mp3'))"
ENV LIQUIDSOAP_PLAYLIST_DEFAULT "audio_to_stereo(single('/opt/docker/etc/liquidsoap/default.mp3'))"

ENV LIQUIBASE_PLAYLIST_DAY "playlist('/opt/docker/etc/liquidsoap/playlist-day.pls')"
ENV LIQUIBASE_PLAYLIST_DAY_TIMERANGE "4h-2h"
ENV LIQUIDSOAP_PLAYLIST_DAY "playlist('/opt/docker/etc/liquidsoap/playlist-day.pls')"
ENV LIQUIDSOAP_PLAYLIST_DAY_TIMERANGE "4h-2h"

ENV LIQUIBASE_PLAYLIST_NIGHT "playlist('/opt/docker/etc/liquidsoap/playlist-night.pls')"
ENV LIQUIBASE_PLAYLIST_NIGHT_TIMERANGE "2h-14h"
ENV LIQUIDSOAP_PLAYLIST_NIGHT "playlist('/opt/docker/etc/liquidsoap/playlist-night.pls')"
ENV LIQUIDSOAP_PLAYLIST_NIGHT_TIMERANGE "2h-14h"

ENV LIQUIBASE_OUTPUT "output.icecast(%mp3(bitrate=128),host='localhost',port=8000,password='secretpassword',mount='liquidsoap-128',name=META_name,genre=META_genre,url=META_url,description=META_desc,ALL_input)"
ENV LIQUIDSOAP_OUTPUT "output.icecast(%mp3(bitrate=128),host='localhost',port=8000,password='secretpassword',mount='liquidsoap-128',name=META_name,genre=META_genre,url=META_url,description=META_desc,ALL_input)"

ENV LIQUIBASE_META_NAME "Liquidsoap Docker"
ENV LIQUIBASE_META_GENRE ""
ENV LIQUIBASE_META_URL ""
ENV LIQUIBASE_META_DESCRIPTION ""
ENV LIQUIDSOAP_META_NAME "Liquidsoap Docker"
ENV LIQUIDSOAP_META_GENRE ""
ENV LIQUIDSOAP_META_URL ""
ENV LIQUIDSOAP_META_DESCRIPTION ""

COPY conf/ /opt/docker/

Expand Down
24 changes: 12 additions & 12 deletions docker/liquidsoap/latest/Dockerfile.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@ RUN /usr/local/bin/apt-install \
{{ docker.cleanup() }}

ENV LIQUIDSOAP_USER "liquidsoap"
ENV LIQUIBASE_TELNET "1"
ENV LIQUIDSOAP_TELNET "1"

ENV LIQUIDSOAP_SCRIPT "/opt/docker/etc/liquidsoap/default.liq"
ENV LIQUIDSOAP_TEMPLATE "/opt/docker/etc/liquidsoap/default.liq"

ENV LIQUIBASE_STREAM_INPUT "http://icecast:8000/live"
ENV LIQUIDSOAP_STREAM_INPUT "http://icecast:8000/live"

ENV LIQUIBASE_PLAYLIST_DEFAULT "audio_to_stereo(single('/opt/docker/etc/liquidsoap/default.mp3'))"
ENV LIQUIDSOAP_PLAYLIST_DEFAULT "audio_to_stereo(single('/opt/docker/etc/liquidsoap/default.mp3'))"

ENV LIQUIBASE_PLAYLIST_DAY "playlist('/opt/docker/etc/liquidsoap/playlist-day.pls')"
ENV LIQUIBASE_PLAYLIST_DAY_TIMERANGE "4h-2h"
ENV LIQUIDSOAP_PLAYLIST_DAY "playlist('/opt/docker/etc/liquidsoap/playlist-day.pls')"
ENV LIQUIDSOAP_PLAYLIST_DAY_TIMERANGE "4h-2h"

ENV LIQUIBASE_PLAYLIST_NIGHT "playlist('/opt/docker/etc/liquidsoap/playlist-night.pls')"
ENV LIQUIBASE_PLAYLIST_NIGHT_TIMERANGE "2h-14h"
ENV LIQUIDSOAP_PLAYLIST_NIGHT "playlist('/opt/docker/etc/liquidsoap/playlist-night.pls')"
ENV LIQUIDSOAP_PLAYLIST_NIGHT_TIMERANGE "2h-14h"

ENV LIQUIBASE_OUTPUT "output.icecast(%mp3(bitrate=128),host='localhost',port=8000,password='secretpassword',mount='liquidsoap-128',name=META_name,genre=META_genre,url=META_url,description=META_desc,ALL_input)"
ENV LIQUIDSOAP_OUTPUT "output.icecast(%mp3(bitrate=128),host='localhost',port=8000,password='secretpassword',mount='liquidsoap-128',name=META_name,genre=META_genre,url=META_url,description=META_desc,ALL_input)"

ENV LIQUIBASE_META_NAME "Liquidsoap Docker"
ENV LIQUIBASE_META_GENRE ""
ENV LIQUIBASE_META_URL ""
ENV LIQUIBASE_META_DESCRIPTION ""
ENV LIQUIDSOAP_META_NAME "Liquidsoap Docker"
ENV LIQUIDSOAP_META_GENRE ""
ENV LIQUIDSOAP_META_URL ""
ENV LIQUIDSOAP_META_DESCRIPTION ""

{{ docker.copy('conf/', '/opt/docker/') }}

Expand Down
4 changes: 2 additions & 2 deletions docker/liquidsoap/latest/conf/bin/entrypoint.d/liquidsoap.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env bash

#############################################
## Configure and run liquibase
## Configure and run liquidsoap
#############################################

if [[ -n "$LIQUIDSOAP_TEMPLATE" ]]; then
go-replace --mode=template -s Foobar -r Foobar -- "$LIQUIDSOAP_TEMPLATE"
go-replace --mode=template -- "$LIQUIDSOAP_TEMPLATE"
fi

exec gosu "$LIQUIDSOAP_USER" liquidsoap "$LIQUIDSOAP_SCRIPT"
68 changes: 35 additions & 33 deletions docker/liquidsoap/latest/conf/etc/liquidsoap/default.liq
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,26 @@ set("log.file.path","/dev/null")
set("log.stdout", true)

# Use the telnet server for requests
{{if .Env.LIQUIBASE_TELNET}}
{{if .Env.LIQUIDSOAP_TELNET}}
set("server.telnet", true)
{{else}}
set("server.telnet", false)
{{end}}

##################
# Settings
##################

DJ_stream = "{{.Env.LIQUIBASE_STREAM_INPUT}}"
DJ_stream = "{{.Env.LIQUIDSOAP_STREAM_INPUT}}"

PLAYLIST_default = {{.Env.LIQUIBASE_PLAYLIST_DEFAULT}}
PLAYLIST_day = {{.Env.LIQUIBASE_PLAYLIST_DAY}}
PLAYLIST_night = {{.Env.LIQUIBASE_PLAYLIST_NIGHT}}
PLAYLIST_default = {{.Env.LIQUIDSOAP_PLAYLIST_DEFAULT}}
PLAYLIST_day = {{.Env.LIQUIDSOAP_PLAYLIST_DAY}}
PLAYLIST_night = {{.Env.LIQUIDSOAP_PLAYLIST_NIGHT}}

META_name = "{{.Env.LIQUIBASE_META_NAME}}"
META_genre = "{{.Env.LIQUIBASE_META_GENRE}}"
META_url = "{{.Env.LIQUIBASE_META_URL}}"
META_desc = "{{.Env.LIQUIBASE_META_DESCRIPTION}}"
META_name = "{{.Env.LIQUIDSOAP_META_NAME}}"
META_genre = "{{.Env.LIQUIDSOAP_META_GENRE}}"
META_url = "{{.Env.LIQUIDSOAP_META_URL}}"
META_desc = "{{.Env.LIQUIDSOAP_META_DESCRIPTION}}"

## fetch dj stream
DJ_input = input.http(DJ_stream)
Expand All @@ -39,8 +41,8 @@ DJ_input = input.http(DJ_stream)
# otherwise one of our playlists,
# and the default file if anything goes wrong.
PLAYLIST_input = fallback([
switch([({ {{.Env.LIQUIBASE_PLAYLIST_DAY_TIMERANGE}} }, PLAYLIST_day),
({ {{.Env.LIQUIBASE_PLAYLIST_NIGHT_TIMERANGE}} }, PLAYLIST_night)]),
switch([({ {{.Env.LIQUIDSOAP_PLAYLIST_DAY_TIMERANGE}} }, PLAYLIST_day),
({ {{.Env.LIQUIDSOAP_PLAYLIST_NIGHT_TIMERANGE}} }, PLAYLIST_night)]),
PLAYLIST_default
])

Expand All @@ -51,7 +53,7 @@ PLAYLIST_input = smart_crossfade(fade_out=0.5, fade_in=0.5, PLAYLIST_input)
PLAYLIST_input = rewrite_metadata(
[
("title", "$(title)"),
("comment", "{{.Env.LIQUIBASE_META_URL}}")
("comment", "{{.Env.LIQUIDSOAP_META_URL}}")
],
PLAYLIST_input
)
Expand All @@ -63,24 +65,24 @@ ALL_input = fallback(track_sensitive=false, [DJ_input, PLAYLIST_input])
# Output
#################

{{.Env.LIQUIBASE_OUTPUT}}
{{.Env.LIQUIBASE_OUTPUT_1}}
{{.Env.LIQUIBASE_OUTPUT_2}}
{{.Env.LIQUIBASE_OUTPUT_3}}
{{.Env.LIQUIBASE_OUTPUT_4}}
{{.Env.LIQUIBASE_OUTPUT_5}}
{{.Env.LIQUIBASE_OUTPUT_6}}
{{.Env.LIQUIBASE_OUTPUT_7}}
{{.Env.LIQUIBASE_OUTPUT_8}}
{{.Env.LIQUIBASE_OUTPUT_9}}
{{.Env.LIQUIBASE_OUTPUT_10}}
{{.Env.LIQUIBASE_OUTPUT_11}}
{{.Env.LIQUIBASE_OUTPUT_12}}
{{.Env.LIQUIBASE_OUTPUT_13}}
{{.Env.LIQUIBASE_OUTPUT_14}}
{{.Env.LIQUIBASE_OUTPUT_15}}
{{.Env.LIQUIBASE_OUTPUT_16}}
{{.Env.LIQUIBASE_OUTPUT_17}}
{{.Env.LIQUIBASE_OUTPUT_18}}
{{.Env.LIQUIBASE_OUTPUT_19}}
{{.Env.LIQUIBASE_OUTPUT_20}}
{{.Env.LIQUIDSOAP_OUTPUT}}
{{.Env.LIQUIDSOAP_OUTPUT_1}}
{{.Env.LIQUIDSOAP_OUTPUT_2}}
{{.Env.LIQUIDSOAP_OUTPUT_3}}
{{.Env.LIQUIDSOAP_OUTPUT_4}}
{{.Env.LIQUIDSOAP_OUTPUT_5}}
{{.Env.LIQUIDSOAP_OUTPUT_6}}
{{.Env.LIQUIDSOAP_OUTPUT_7}}
{{.Env.LIQUIDSOAP_OUTPUT_8}}
{{.Env.LIQUIDSOAP_OUTPUT_9}}
{{.Env.LIQUIDSOAP_OUTPUT_10}}
{{.Env.LIQUIDSOAP_OUTPUT_11}}
{{.Env.LIQUIDSOAP_OUTPUT_12}}
{{.Env.LIQUIDSOAP_OUTPUT_13}}
{{.Env.LIQUIDSOAP_OUTPUT_14}}
{{.Env.LIQUIDSOAP_OUTPUT_15}}
{{.Env.LIQUIDSOAP_OUTPUT_16}}
{{.Env.LIQUIDSOAP_OUTPUT_17}}
{{.Env.LIQUIDSOAP_OUTPUT_18}}
{{.Env.LIQUIDSOAP_OUTPUT_19}}
{{.Env.LIQUIDSOAP_OUTPUT_20}}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ Environment variable Description Default
====================== ============================= ================
``LOG_STDOUT`` Destination of daemon output *empty* (stdout)
``LOG_STDERR`` Destination of daemon errors *empty* (stdout)
====================== ============================= =================
====================== ============================= ================
53 changes: 53 additions & 0 deletions documentation/docs/content/DockerImages/dockerfiles/liquidsoap.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
====================
webdevops/liquidsoap
====================

The liquidsoap images are based on ``webdevops/base`` with liquidsoap multimedia streaming server with most plugins.

Docker image tags
-----------------

====================== =============================================
Tag Distribution name
====================== =============================================
``latest`` Based on `webdevops/base:latest` (Ubuntu)
====================== =============================================

Environment variables
---------------------

.. include:: include/environment-base.rst


Liquisoap environment variables
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
====================================================== ===================================== ==============================================
Environment variable Description Default
====================================================== ===================================== ==============================================
``LIQUIDSOAP_USER`` Daemon user ID ``liquidsoap``
``LIQUIDSOAP_TELNET`` Open telnet (port 1234) ``1`` (enabled)
``LIQUIDSOAP_SCRIPT`` Configuration script for liquidsoap ``/opt/docker/etc/liquidsoap/default.liq``
``LIQUIDSOAP_TEMPLATE`` Apply template to config script ``1/opt/docker/etc/liquidsoap/default.liq``

``LIQUIDSOAP_STREAM_INPUT`` Input stream (eg. icecast) ``http://icecast:8000/live``

``LIQUIDSOAP_PLAYLIST_DEFAULT`` Default stream when no other stream ``audio_to_stereo(single('/opt/docker/etc/liquidsoap/default.mp3'))``
is active

``LIQUIDSOAP_PLAYLIST_DAY`` Day input stream/playlist ``playlist('/opt/docker/etc/liquidsoap/playlist-day.pls')``
``LIQUIDSOAP_PLAYLIST_DAY_TIMERANGE`` Timerange for day playlist ``4h-2h``

``LIQUIDSOAP_PLAYLIST_NIGHT`` Night input stream/playlist ``playlist('/opt/docker/etc/liquidsoap/playlist-night.pls')``
``LIQUIDSOAP_PLAYLIST_NIGHT_TIMERANGE`` Timerange for night playlist ``2h-14h``

``LIQUIDSOAP_OUTPUT`` Output stream (eg. icecast) ``output.icecast(%mp3(bitrate=128),host='localhost',port=8000,password='secretpassword',mount='liquidsoap-128',name=META_name,genre=META_genre,url=META_url,description=META_desc,ALL_input)``

``LIQUIDSOAP_OUTPUT_1`` ... ``LIQUIDSOAP_OUTPUT_20`` More output stream lines *empty*


``LIQUIDSOAP_META_NAME`` Station name ``Liquidsoap Docker``
``LIQUIDSOAP_META_GENRE`` Station genre *empty*
``LIQUIDSOAP_META_URL`` Station url *empty*
``LIQUIDSOAP_META_DESCRIPTION`` Station description *empty*
====================================================== ===================================== ==============================================

1 change: 1 addition & 0 deletions documentation/docs/content/DockerImages/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Docker images
dockerfiles/hhvm-apache
dockerfiles/hhvm-nginx
dockerfiles/liquibase
dockerfiles/liquidsoap
dockerfiles/mail-sandbox
dockerfiles/nginx
dockerfiles/nginx-dev
Expand Down
4 changes: 4 additions & 0 deletions tests/serverspec/spec/collection/liquidsoap.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
shared_examples 'collection::liquidsoap' do
include_examples 'liquidsoap::listening::public'
end

14 changes: 14 additions & 0 deletions tests/serverspec/spec/docker/liquidsoap_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require 'serverspec'
require 'docker'
require 'spec_init'

describe "Dockerfile" do
before(:all) do
set :docker_image, ENV['DOCKERIMAGE_ID']
end

include_examples 'collection::bootstrap'
include_examples 'collection::base'
include_examples 'collection::liquidsoap'

end
7 changes: 7 additions & 0 deletions tests/serverspec/spec/shared/liquidsoap/listening.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
shared_examples 'liquidsoap::listening::public' do
describe port(1234) do
it "hhvm should be listening", :retry => 20, :retry_wait => 3 do
should be_listening.with('tcp')
end
end
end

0 comments on commit afe4e0c

Please sign in to comment.