Skip to content

Music player container - a streaming Jukebox setup made from MPD

Notifications You must be signed in to change notification settings

craig-m/mpcontainer

Repository files navigation

MPContainer

Music Player Container 🔊 - A streaming Jukebox setup built around MPD.

Moving the CLI programs I like, and refuse to give up, into the modern world of browsers and containers. For learning and fun, not profit.

See screenshots of the front and admin web interfaces.

build status

linting security-scans CodeQL docker-hub-release

Thanks to Github Actions each time this repo changes the images in the registry are updated too.

build-container-mpd

build-container-hpx

build-container-web

build-container-shell

build-containers-pyapp

App Architecture

mpcontainer.mermaid

containers

What runs in each of the 5 different container types.

📦 mpd

Music Player Daemon is a music server that can be controlled with a client over an API (mpc protocol). Can output vorbis audio stream over http.

📦 haproxy

haproxy is the frontend proxy, handle L7 redirects to backend services.

📦 Nginx

nginx web server is used for hosting static files. Hosts bootstrap + jquery frameworks (installed with npm). This is the default haproxy backend.

A Multi-stage build is done, npm is not included in the final image.

📦 admin-shell

ttyd lets you run a terminal in your browser. From tmux (a terminal multiplexer) you can use ncmpcpp (an ncurses MPD client app) to control the MPD server.

Access to this should be restricted on public deployments, don't put this on the open internet without changing the password variables. This web shell is for trusted users only so they can control the music.

📦 Python-App

A python flask web app, run from Gunicorn.

Connects to the MPD api (with a read only user) to get stream and other dynamic information about MPD.

Use

On MacOS or Windows Docker Desktop makes for a nice container experience, especially with VSCode (get the Docker, yaml and kubernetes extensions).

Put some music into .\music\db\ so you can use the Jukebox, these files will be exluded from Git.

docker-compose

Starting MPContainer in prod/dev.

development

If you're deving and want to mount config files from the repo and expose ports etc:

docker-compose -f docker-compose.yml -f docker-compose.dev.yml up --build

Or for a contained local Dev environment there is a VM managed by Vagrant here

production

Start the MPContainer with images on docker hub:

docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d

check on it

Check on everything:

docker-compose ps
docker-compose top

By default MPContainer is available on port 3000 of your local interface.

The admin shell is password protected, and the HAPX_US_USER & HAPX_US_PASS can be set to override the defaults (set in docker-compose and haproxy.conf).

manually build images

For manually updating first create a Personal Access Token (pat) for git, then add create environment vars for this and your username.

export GIT_TOKE="xxxxx"
export GIT_UN="<git username>"

login to registry:

echo $GIT_TOKE | docker login https://ghcr.io/ -u $GIT_UN --password-stdin

Build and push Images:

make build
make publish

Kubernetes

For steps to run in Kubernetes see this README