From 007167f4cbcc644483ef5c5784193a5c1ca67d36 Mon Sep 17 00:00:00 2001 From: ale Date: Fri, 29 May 2020 19:11:38 +0200 Subject: [PATCH] share pulseaudio --- README.md | 5 +++++ docker-compose.yml | 5 ++++- wahay/Dockerfile | 18 ++++++++++++++---- wahay/pulseaudio.client.conf | 6 ++++++ 4 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 wahay/pulseaudio.client.conf diff --git a/README.md b/README.md index 48bb0e1..c186e2c 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,11 @@ Needs `docker` and `docker-compose` xhost +"local:docker@" ``` +### Change your local user UID in the next line of `docker-compose.yml` for pulseaudio (default 1000) +``` +- /run/user/[UID]/pulse:/run/user/1000/pulse +``` + ### Execute with compose ``` docker-compose up -d diff --git a/docker-compose.yml b/docker-compose.yml index cb63a43..ac9039f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,6 +6,9 @@ services: hostname: wahay container_name: wahay environment: - - DISPLAY + - DISPLAY=unix$DISPLAY + - PULSE_SERVER=unix:/run/user/1000/pulse/native volumes: - /tmp/.X11-unix:/tmp/.X11-unix:ro + - /run/user/1000/pulse:/run/user/1000/pulse + - ./wahay/pulseaudio.client.conf:/etc/pulse/client.conf:ro diff --git a/wahay/Dockerfile b/wahay/Dockerfile index 093cae8..f3a1dc9 100644 --- a/wahay/Dockerfile +++ b/wahay/Dockerfile @@ -1,8 +1,18 @@ FROM golang -RUN apt update && apt upgrade -y && apt install -y curl lsb-release dirmngr +ENV UNAME mumble +RUN apt update && apt upgrade -y && apt install -y curl lsb-release dirmngr pulseaudio-utils && apt clean RUN curl -s https://dl.autonomia.digital/debian/keys.asc | apt-key add - RUN echo deb https://dl.autonomia.digital/debian $(lsb_release -c | cut -f 2) main | tee /etc/apt/sources.list.d/wahay.list RUN echo deb-src https://dl.autonomia.digital/debian $(lsb_release -c | cut -f 2) main | tee -a /etc/apt/sources.list.d/wahay.list -RUN apt update && apt install -y wahay -ENTRYPOINT ["wahay"] - +RUN apt update && apt install -y wahay && apt clean +RUN export UNAME=$UNAME UID=1000 GID=1000 && \ + mkdir -p "/home/${UNAME}" && \ + echo "${UNAME}:x:${UID}:${GID}:${UNAME} User,,,:/home/${UNAME}:/bin/bash" >> /etc/passwd && \ + echo "${UNAME}:x:${UID}:" >> /etc/group && \ + mkdir -p /etc/sudoers.d && \ + echo "${UNAME} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/${UNAME} && \ + chmod 0440 /etc/sudoers.d/${UNAME} && \ + chown ${UID}:${GID} -R /home/${UNAME} && \ + gpasswd -a ${UNAME} audio +USER ${UNAME} +ENTRYPOINT [ "wahay" ] \ No newline at end of file diff --git a/wahay/pulseaudio.client.conf b/wahay/pulseaudio.client.conf new file mode 100644 index 0000000..bb266f2 --- /dev/null +++ b/wahay/pulseaudio.client.conf @@ -0,0 +1,6 @@ +default-server = unix:/run/user/1000/pulse/native +# Prevent a server running in the container +autospawn = no +daemon-binary = /bin/true +# Prevent the use of shared memory +enable-shm = false \ No newline at end of file