commit 3c508a7b3adec213fb156a47fa81d81d84ba3636 Author: Jason Date: Mon Feb 14 16:48:10 2022 -0500 🦈🏠🐜❗ Initial Commit ❗🐜🦈🏠 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0448037 --- /dev/null +++ b/.gitignore @@ -0,0 +1,17 @@ +# gitignore created on 02/05/22 at 19:35 +# Disable reminder in prompt +ignoredirmessage + +# OS generated files +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db + +# Other +.installed +# ignore commit message +.gitcommit diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..48c97db --- /dev/null +++ b/Dockerfile @@ -0,0 +1,89 @@ +FROM casjaysdev/alpine:latest as build + +WORKDIR /app/src + +ENV \ + EMBEDDED_ASSETS="ON" \ + ENABLE_FLAC="ON" \ + ENABLE_IPV6="OFF" \ + ENABLE_LIBASAN="OFF" \ + ENABLE_SSL="ON" \ + MANPAGES="ON" \ + MYMPD_BUILDIR="build" \ + DESTDIR="/app/dist" \ + MYMPD_INSTALL_PREFIX="/usr" \ + MPD_HOST="172.17.0.1" \ + MPD_PORT="6600" + +RUN apk -U upgrade && \ + apk add --no-cache \ + cmake \ + perl \ + libid3tag-dev \ + flac-dev \ + lua5.4-dev \ + alpine-sdk \ + linux-headers \ + pkgconf \ + pcre2-dev \ + jq \ + g++ \ + make \ + libmpdclient-dev \ + openssl-dev \ + git \ + abuild \ + musl-dev + +RUN \ + git clone https://github.com/jcorporation/myMPD ./ && \ + bash ./build.sh installdeps && \ + bash ./build.sh releaseinstall \ + mkdir -p "$DESTDIR" + +COPY ./bin/. ${DESTDIR}/usr/local/bin/ + +FROM casjaysdev/alpine:latest +ARG BUILD_DATE="$(date +'%Y-%m-%d %H:%M')" + +LABEL \ + org.label-schema.name="ympd" \ + org.label-schema.description="Web interface to mpd" \ + org.label-schema.url="https://github.com/casjaysdev/ympd" \ + org.label-schema.vcs-url="https://github.com/casjaysdev/ympd" \ + org.label-schema.build-date=$BUILD_DATE \ + org.label-schema.version=$BUILD_DATE \ + org.label-schema.vcs-ref=$BUILD_DATE \ + org.label-schema.license="MIT" \ + org.label-schema.vcs-type="Git" \ + org.label-schema.schema-version="1.0" \ + org.label-schema.vendor="CasjaysDev" \ + maintainer="CasjaysDev " + +RUN apk -U upgrade && \ + apk add --no-cache \ + libmpdclient \ + openssl \ + libid3tag \ + flac \ + lua5.4 \ + pcre2 \ + mpc \ + mpd \ + pulseaudio-utils + +RUN addgroup -S mympd 2>/dev/null && \ + adduser -S -D -H -h /var/lib/mympd -s /sbin/nologin \ + -G mympd -g myMPD mympd 2>/dev/null + +EXPOSE 8082 6600 +ENV HOSTNAME="ympd" + +COPY --from=build /app/dist/. / +COPY ./config/mpd.conf /etc/mpd.conf +COPY ./config/mympd/. /var/lib/mympd/config/ +COPY ./config/pulse-client.conf /etc/pulse/client.conf + +VOLUME [ "/config", "/var/lib/mpd", "/var/lib/mympd", "/music", "/playlists" ] +HEALTHCHECK CMD ["/usr/local/bin/entrypoint-ympd.sh", "healthcheck"] +ENTRYPOINT ["/usr/local/bin/entrypoint-ympd.sh"] diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..86d4345 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,13 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2022 Jason Hempstead + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 1. You just DO WHAT THE FUCK YOU WANT TO. diff --git a/README.md b/README.md new file mode 100644 index 0000000..39e4f87 --- /dev/null +++ b/README.md @@ -0,0 +1,50 @@ +# 👋 ympd Readme 👋 + +ympd README + +## Run container + +### via command line + +```shell +docker run -d \ +--restart always \ +--name ympd \ +--device /dev/snd \ +-e HOSTNAME=ympd \ +-e TZ=${TIMEZONE:-America/New_York} \ +-e MYMPD_SSL=false \ +-v $PWD/ympd/data/mpd:/var/lib/mpd:z \ +-v $PWD/ympd/data/mympd:/var/lib/mympd:z \ +-v $PWD/ympd/config:/config:z \ +-v $HOME/Music:/music:z \ +-p 6600:600 \ +-p 8082:8082 \ +casjaysdev/ympd:latest +``` + +### via docker-compose + +```yaml +version: "2" +services: + ympd: + image: casjaysdev/ympd + container_name: ympd + environment: + - TZ=America/New_York + - HOSTNAME=ympd + volumes: + - $HOME/Music:/music + - $HOME/.local/share/docker/storage/ympd/data/mpd:/var/lib/mpd \ + - $HOME/.local/share/docker/storage/ympd/data/mympd:/var/lib/mympd \ + - $HOME/.local/share/docker/storage/ympd/config:/config \ + ports: + - 80:80 + restart: always +``` + +## Authors + +🤖 Casjay: [Github](https://github.com/casjay) [Docker](https://hub.docker.com/casjay) 🤖 +⛵ CasjaysDev: [Github](https://github.com/casjaysdev) [Docker](https://hub.docker.com/casjaysdev) ⛵ diff --git a/bin/entrypoint-ympd.sh b/bin/entrypoint-ympd.sh new file mode 100755 index 0000000..8db30a3 --- /dev/null +++ b/bin/entrypoint-ympd.sh @@ -0,0 +1,82 @@ +#!/usr/bin/env bash + +DOCKER_PORT="8082" +DOCKER_HOST="$(ip route | awk '/default/ { print $3 }')" +export TZ="${TZ:-America/New_York}" +export HOSTNAME="${HOSTNAME:-casjaysdev-ympd}" + +[ -n "${TZ}" ] && echo "${TZ}" >/etc/timezone +[ -n "${HOSTNAME}" ] && echo "${HOSTNAME}" >/etc/hostname +[ -n "${HOSTNAME}" ] && echo "127.0.0.1 $HOSTNAME localhost" >/etc/hosts +[ -f "/usr/share/zoneinfo/${TZ}" ] && ln -sf "/usr/share/zoneinfo/${TZ}" "/etc/localtime" +[ -d "/config/mympd" ] || mkdir -p "/config/mympd" + +if [ ! -f "/config/mympd/.env" ]; then + cat <"/config/mympd/.env" +# See https://jcorporation.github.io/myMPD/configuration/ for more information +export MPD_HOST=$DOCKER_HOST +export MPD_PORT=6600 +export MYMPD_HTTP_HOST="${MYMPD_HTTP_HOST:-0.0.0.0}" +export MYMPD_HTTP_PORT="${MYMPD_HTTP_PORT:-$DOCKER_PORT}" +export MYMPD_LOGLEVEL="${MYMPD_LOGLEVEL:-5}" +export MYMPD_SSL="${MYMPD_SSL:-false}" +export MYMPD_SSL_PORT="${MYMPD_SSL_PORT:-$DOCKER_PORT}" +export MYMPD_SSL_KEY="${MYMPD_SSL_KEY:-/config/certs/mympd.key}" +export MYMPD_SSL_CERT="${MYMPD_SSL_CERT:-/config/certs/mympd.crt}" +#export MYMPD_ACL="${MYMPD_ACL:-}" +#export MYMPD_SSL_SAN="${MYMPD_SSL_SAN:-}" +#export MYMPD_LUALIBS="${MYMPD_LUALIBS:-}" +#export MYMPD_SCRIPTACL="${MYMPD_SCRIPTACL:-}" +#export MYMPD_CUSTOM_CERT="${MYMPD_CUSTOM_CERT:-}" + +EOF +fi + +[ -f "/config/mympd/.env" ] && . "/config/mympd/.env" +[ -f "/config/mympd/ssl" ] || printf '%s' "$MYMPD_SSL" >"/config/mympd/ssl" +[ -f "/config/mympd/http_host" ] || printf '%s' "$MYMPD_HTTP_HOST" >"/config/mympd/http_host" +[ -f "/config/mympd/http_port" ] || printf '%s' "$MYMPD_HTTP_PORT" >"/config/mympd/http_port" + +[ -f "/config/pulse-client.conf" ] && cp -Rf "/config/pulse-client.conf" "/etc/pulse/client.conf" || + cp -Rf "/etc/pulse/client.conf" "/config/pulse-client.conf" +[ -f "/config/mpd.conf" ] && cp -Rf "/config/mpd.conf" "/etc/mpd.conf" || + cp -Rf "/etc/mpd.conf" "/config/mpd.conf" +[ -d "/config/mympd" ] && cp -Rf "/config/mympd/." "/var/lib/mympd/config/" || + cp -Rf "/var/lib/mympd/config/." "/config/mympd/" + +export MYMPD_USER="--user ${MYMPD_USER:-mympd}" +export MYMPD_DIR="--workdir ${MYMPD_DIR:-/var/lib/mympd}" +export MYMPD_CACHE="--cache ${MYMPD_CACHE:-/var/cache/mympd}" + +case "$1" in +healthcheck) + shift 1 + if curl -q -LSs --fail "localhost:$DOCKER_PORT"; then + echo '{"status": "ok" }' + exit 0 + else + echo '{"status": "fail" }' + exit 1 + fi + ;; + +bash | sh | shell) + shift 1 + exec bash -l "$@" + ;; + +*) + echo "Setting ympd options to: ${CMDOPTS:-none}" + if [[ $# = 0 ]]; then + echo "listening on http://$DOCKER_HOST:$DOCKER_PORT" + pacat -vvvv /dev/urandom + mpd --no-daemon /etc/mpd.conf + mympd $MYMPD_USER $MYMPD_DIR $MYMPD_CACHE $CMDOPTS + else + CMDOPTS="$*" + mympd $MYMPD_USER $MYMPD_DIR $MYMPD_CACHE $CMDOPTS + pacat -vvvv /dev/urandom + mpd --no-daemon /etc/mpd.conf + fi + ;; +esac diff --git a/config/mpd.conf b/config/mpd.conf new file mode 100644 index 0000000..071a86f --- /dev/null +++ b/config/mpd.conf @@ -0,0 +1,124 @@ +############################################################################### +music_directory "/music" +playlist_directory "/playlists" +state_file "/var/lib/mpd/state" +db_file "/var/lib/mpd/database.db" +sticker_file "/var/lib/mpd/sticker.sql" +log_file "/var/log/mpd/mpd.log" +pid_file "/run/mpd/pid" +bind_to_address "/run/mpd/socket" +############################################################################### +user "root" +group "root" +bind_to_address "any" +port "6600" +log_level "default" +gapless_mp3_playback "yes" +restore_paused "yes" +save_absolute_paths_in_playlists "no" +metadata_to_use "artist,album,title,track,name,genre,date,composer,performer,disc" +auto_update "yes" +auto_update_depth "5" +############################################################################### +follow_outside_symlinks "yes" +follow_inside_symlinks "yes" +############################################################################### +zeroconf_enabled "yes" +zeroconf_name "%h" +############################################################################### +#password "password@read,add,control,admin" +#default_permissions "read,add,control,admin" +############################################################################### +#database { +#plugin "proxy" +#host "other.mpd.host" +#port "6600" +#} +############################################################################### +input { +plugin "curl" +#proxy "proxy.isp.com:8080" +#proxy_user "user" +#proxy_password "password" +} +############################################################################### +audio_output { + type "alsa" + name "speakers" +} + +audio_output { +#type "shout" +#encoder "vorbis" # optional +#name "My Shout Stream" +#host "localhost" +#port "8000" +#mount "/mpd.ogg" +#password "hackme" +#quality "5.0" +#bitrate "128" +#format "44100:16:1" +#protocol "icecast2" # optional +#user "source" # optional +#description "My Stream Description" # optional +#url "http://example.com" # optional +#genre "jazz" # optional +#public "no" # optional +#timeout "2" # optional +#mixer_type "software" # optional +#} +############################################################################### +#audio_output { +# type "recorder" +# name "My recorder" +# encoder "vorbis" # optional, vorbis or lame +# path "/var/lib/mpd/recorder/mpd.ogg" +## quality "5.0" # do not define if bitrate is defined +# bitrate "128" # do not define if quality is defined +# format "44100:16:1" +#} +############################################################################### +audio_output { + type "httpd" + name "HTTP Stream" + encoder "lame" #to support safari on ios + port "8000" + bitrate "128" + format "44100:16:1" + always_on "yes" + tags "yes" +} +############################################################################### +audio_output { + type "pulse" + name "pulse" +#server "remote_server" +#sink "remote_server_sink" +#media_role "media_role" +} +# +############################################################################### +#audio_output { +# type "osx" +# name "My OS X Device" +# device "Built-in Output" # optional +# channel_map "-1,-1,0,1" # optional +#} +############################################################################### +#audio_output { +#type "pipe" +#name `"my pipe" +#command "aplay -f cd 2>/dev/null" +#command "AudioCompress -m | aplay -f cd 2>/dev/null" +#command "nc example.org 8765" +# format "44100:16:2" +#} +############################################################################### +#replaygain "album" +#replaygain_preamp "0" +#replaygain_missing_preamp "0" +#replaygain_limit "yes" +#volume_normalization "no" +############################################################################### +filesystem_charset "UTF-8" +############################################################################### diff --git a/config/pulse-client.conf b/config/pulse-client.conf new file mode 100644 index 0000000..06fd273 --- /dev/null +++ b/config/pulse-client.conf @@ -0,0 +1,9 @@ +# Connect to the host's server using the mounted UNIX socket +default-server = unix:/run/user/REPLACE_UUID/pulse/native + +# Prevent a server running in the container +autospawn = no +daemon-binary = /bin/true + +# Prevent the use of shared memory +enable-shm = false diff --git a/sed b/sed new file mode 100644 index 0000000..e69de29