From a7bc5e235dfd9d2897d1a075f16c4f495ac5a2b4 Mon Sep 17 00:00:00 2001 From: pre-commit fix Vito Zanotelli Date: Tue, 2 Jan 2024 17:34:27 +0100 Subject: [PATCH] Reorder 'USER' command This makes sure the 'venv' is initalized using the correct user, preventing permission errors Closes issue #2198 --- docker/jukebox.Dockerfile | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/docker/jukebox.Dockerfile b/docker/jukebox.Dockerfile index 3249edcb8..e7a7a45b1 100644 --- a/docker/jukebox.Dockerfile +++ b/docker/jukebox.Dockerfile @@ -25,13 +25,18 @@ RUN apt-get update && apt-get install -qq -y \ espeak mpc mpg123 git ffmpeg spi-tools netcat \ python3 python3-venv python3-dev python3-mutagen +# Copy in the source code using the correct permissions +COPY --chown=${USER}:${USER} . ${INSTALLATION_PATH}/ + +# Switch to the `$USER` (typically `pi`) +USER ${USER} +WORKDIR ${HOME} + +# Initialize venv ENV VIRTUAL_ENV=${INSTALLATION_PATH}/.venv RUN python3 -m venv $VIRTUAL_ENV ENV PATH="$VIRTUAL_ENV/bin:$PATH" -USER ${USER} -WORKDIR ${HOME} -COPY --chown=${USER}:${USER} . ${INSTALLATION_PATH}/ RUN pip install --no-cache-dir -r ${INSTALLATION_PATH}/requirements.txt