From 52c13625d7d5469704705a6ac7b8a498d9f33d64 Mon Sep 17 00:00:00 2001 From: yenien Date: Sat, 30 May 2020 08:42:32 +0000 Subject: [PATCH] Configurable user parameters (#2) Update README Configurable user parameters Co-authored-by: Francesc Gordillo Reviewed-on: http://gitea.hatthieves.es/manalejandro/docker-wahay/pulls/2 --- .gitignore | 1 + README.md | 10 ++++++---- docker-compose.yml | 12 +++++++++--- wahay/Dockerfile | 13 ++++++++++--- 4 files changed, 26 insertions(+), 10 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c49bd7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env diff --git a/README.md b/README.md index c186e2c..f055a35 100644 --- a/README.md +++ b/README.md @@ -9,9 +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 +### Add your local user UID and GID in the `.env` file: + +```bash +echo "UID=${UID}" > .env +echo "GID=${UID}" >> .env ``` ### Execute with compose @@ -21,4 +23,4 @@ docker-compose up -d ### License -MIT \ No newline at end of file +MIT diff --git a/docker-compose.yml b/docker-compose.yml index ac9039f..7946692 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,8 +1,14 @@ -version: "2" +version: "3" services: wahay: - build: ./wahay + build: + dockerfile: ./wahay/Dockerfile + context: . + args: + UID: ${UID:-1000} + GID: ${GID:-1000} + UNAME: ${UNAME:-mumble} hostname: wahay container_name: wahay environment: @@ -10,5 +16,5 @@ services: - PULSE_SERVER=unix:/run/user/1000/pulse/native volumes: - /tmp/.X11-unix:/tmp/.X11-unix:ro - - /run/user/1000/pulse:/run/user/1000/pulse + - /run/user/${UID:-1000}/pulse:/run/user/${UID:-1000}/pulse - ./wahay/pulseaudio.client.conf:/etc/pulse/client.conf:ro diff --git a/wahay/Dockerfile b/wahay/Dockerfile index f3a1dc9..6dcb985 100644 --- a/wahay/Dockerfile +++ b/wahay/Dockerfile @@ -1,11 +1,18 @@ FROM golang -ENV UNAME mumble +ARG UID=1000 +ARG GID=1000 +ARG UNAME=mumble + +ENV UID=${UID} \ + GID=${GID} \ + UNAME=${UNAME} + 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 && apt clean -RUN export UNAME=$UNAME UID=1000 GID=1000 && \ +RUN export UNAME=$UNAME UID=$UID GID=$GID && \ mkdir -p "/home/${UNAME}" && \ echo "${UNAME}:x:${UID}:${GID}:${UNAME} User,,,:/home/${UNAME}:/bin/bash" >> /etc/passwd && \ echo "${UNAME}:x:${UID}:" >> /etc/group && \ @@ -15,4 +22,4 @@ RUN export UNAME=$UNAME UID=1000 GID=1000 && \ chown ${UID}:${GID} -R /home/${UNAME} && \ gpasswd -a ${UNAME} audio USER ${UNAME} -ENTRYPOINT [ "wahay" ] \ No newline at end of file +ENTRYPOINT [ "wahay" ]