Dockerfile: Install dependencies globally instead of using a virtualenv
This commit is contained in:
parent
252c15acbd
commit
0d4fbef13d
|
|
@ -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"]
|
||||
|
|
|
|||
Loading…
Reference in New Issue