From a1279be8684a2f48d900824e5aec5949ab636d3c Mon Sep 17 00:00:00 2001 From: Andrey Arapov Date: Sat, 30 Apr 2016 14:56:38 +0200 Subject: [PATCH] first commit --- Dockerfile | 30 ++++++++++++++++++++++++++++++ Dockerfile.alpineKO | 34 ++++++++++++++++++++++++++++++++++ README.md | 22 ++++++++++++++++++++++ docker-compose.yml | 11 +++++++++++ 4 files changed, 97 insertions(+) create mode 100644 Dockerfile create mode 100644 Dockerfile.alpineKO create mode 100644 README.md create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..48d8b30 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +FROM ubuntu:xenial +MAINTAINER Andrey Arapov + +RUN apt-get update && \ + apt-get -y install python3 virtualenv mpv + +# Workaround: pulseaudio client library likes to remove /dev/shm/pulse-shm-* +# files created by the host, causing sound to stop working. +# To fix this, we either want to disable the shm or mount /dev/shm +# in read-only mode when starting the container. +RUN echo "enable-shm = no" >> /etc/pulse/client.conf + +ENV USER user +ENV UID 1000 +ENV GROUPS audio +ENV HOME /home/$USER +RUN useradd -u $UID -m -d $HOME -s /usr/sbin/nologin -G $GROUPS $USER + +USER $USER +WORKDIR $HOME + +RUN virtualenv -p python3 venv && \ + . venv/bin/activate && \ + pip install --upgrade pip && \ + pip install mps-youtube youtube-dl && \ + deactivate &&\ + mkdir $HOME/.config + +VOLUME [ "/tmp", "$HOME/.config" ] +ENTRYPOINT [ "./venv/bin/mpsyt" ] diff --git a/Dockerfile.alpineKO b/Dockerfile.alpineKO new file mode 100644 index 0000000..a592c9e --- /dev/null +++ b/Dockerfile.alpineKO @@ -0,0 +1,34 @@ +# Problem: mpv neither mplayer compiled with the pulseaudio +# + +FROM alpine:3.3 +MAINTAINER Andrey Arapov + +RUN echo '@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories && \ + apk update && \ + apk add python3 py-virtualenv ca-certificates mpv pulseaudio@testing + +# Workaround: pulseaudio client library likes to remove /dev/shm/pulse-shm-* +# files created by the host, causing sound to stop working. +# To fix this, we either want to disable the shm or mount /dev/shm +# in read-only mode when starting the container. +RUN echo "enable-shm = no" >> /etc/pulse/client.conf + +ENV USER user +ENV UID 1000 +ENV GROUPS audio +ENV HOME /home/$USER +RUN adduser -D -h $HOME -s /bin/false -G $GROUPS -u $UID $USER + +USER $USER +WORKDIR $HOME + +RUN virtualenv -p python3 venv && \ + . venv/bin/activate && \ + pip install --upgrade pip && \ + pip install mps-youtube youtube-dl && \ + deactivate &&\ + mkdir $HOME/.config + +VOLUME [ "/tmp", "$HOME/.config" ] +ENTRYPOINT [ "./venv/bin/mpsyt" ] diff --git a/README.md b/README.md new file mode 100644 index 0000000..fe28024 --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# mps-youtube in Docker + +Running [mps-youtube](https://github.com/mps-youtube/mps-youtube) in Docker + + +## Launching mps-youtube + +### with Docker Compose + +``` +docker-compose run --rm mps-youtube +``` + +### with Docker + +``` +docker run --rm -ti \ + --read-only=true \ + -v $XDG_RUNTIME_DIR/pulse:/run/user/1000/pulse:ro \ + -e PULSE_SERVER=unix:$XDG_RUNTIME_DIR/pulse/native \ + andrey01/mps-youtube +``` diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..fe3bc99 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +version: '2' + +services: + mps-youtube: + image: andrey01/mps-youtube + read_only: true + network_mode: bridge + volumes: + - $XDG_RUNTIME_DIR/pulse:/run/user/1000/pulse:ro + environment: + - PULSE_SERVER=unix:$XDG_RUNTIME_DIR/pulse/native