Skip to content

Commit

Permalink
Use virtualenv in dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
jstockwin committed May 14, 2021
1 parent c3752bb commit b478289
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@ RUN apt-get update && \
apt-get -y install software-properties-common \
python3-dev \
python3-pip \
python3-virtualenv \
libmagickwand-dev \
xvfb && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

ENV VIRTUAL_ENV_DIR /.venv
RUN python3 -m virtualenv --python=python3.8 $VIRTUAL_ENV_DIR
# Set the virtual environment as the main Python directory
ENV PATH $VIRTUAL_ENV_DIR/bin:$PATH

RUN --mount=type=cache,target=/root/.cache/pip pip3 install --upgrade pip

# Create src dir
Expand All @@ -26,8 +32,9 @@ ADD ./setup.py $PROJECT_DIR/setup.py
ADD ./README.md $PROJECT_DIR/README.md
RUN --mount=type=cache,target=/root/.cache/pip pip3 install -e $PROJECT_DIR[dev]
RUN --mount=type=cache,target=/root/.cache/pip pip3 install -e $PROJECT_DIR[test]
RUN chown -R app_user:app_user $VIRTUAL_ENV_DIR

# Copy code, chown and switch user
ADD ./ $PROJECT_DIR
RUN chown -R app_user: $PROJECT_DIR
RUN chown -R app_user:app_user $PROJECT_DIR
USER app_user

0 comments on commit b478289

Please sign in to comment.