From 0d4fbef13da0f42eefa13dda330f2467f8f937cd Mon Sep 17 00:00:00 2001 From: binaryDiv Date: Sun, 24 Apr 2022 17:49:03 +0200 Subject: [PATCH] Dockerfile: Install dependencies globally instead of using a virtualenv --- Dockerfile.dev | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Dockerfile.dev b/Dockerfile.dev index e67e44c..99f9c4c 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -1,22 +1,21 @@ FROM python:3.10 -# Install pipenv container-wide as root -RUN pip install pipenv - # Create unprivileged user with UID as specified by the build argument DEV_USER_UID, defaulting to 1000. # (This should match the UID of your local user. If it doesn't, use an ".env" file to overwrite this variable.) ARG DEV_USER_UID=1000 RUN echo Creating dev user with UID $DEV_USER_UID && \ - useradd -m -u $DEV_USER_UID dev + useradd -m -d /home/dev -u $DEV_USER_UID dev USER dev +ENV PATH="/home/dev/.local/bin:${PATH}" -## Create virtual environment using pipenv +# Install pipenv to generate requirements.txt from Pipfile +RUN pip install pipenv + +# Generate requirements.txt and install dependencies with pip WORKDIR /app COPY Pipfile Pipfile.lock ./ -RUN pipenv install --dev --deploy - -# Set entrypoint to always run commands inside virtual environment -ENTRYPOINT ["pipenv", "run"] +RUN pipenv lock --requirements --dev > tmp_requirements.txt && \ + pip install -r tmp_requirements.txt # Set default command CMD ["bash"]