Skip to content

Commit

Permalink
Dockerfile: disable pip cache in deployment
Browse files Browse the repository at this point in the history
Tell pip to not write the cache when
in the deployment image.

Also disable the version check on
the remaining uses of pip, this saves
some time since it avoids a HTTP
request on startup.
  • Loading branch information
pjonsson authored and omad committed Apr 9, 2024
1 parent b3a4798 commit 0ad23f0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ ARG ENVIRONMENT=deployment
# ARG ENVIRONMENT=test

RUN echo "Environment is: $ENVIRONMENT" && \
[ "$ENVIRONMENT" = "deployment" ] || pip install pip-tools pytest-cov
[ "$ENVIRONMENT" = "deployment" ] || \
pip install --disable-pip-version-check pip-tools pytest-cov

# Set up a nice workdir and add the live code
ENV APPDIR=/code
Expand All @@ -64,10 +65,10 @@ RUN python3.10 -m pip --disable-pip-version-check -q install *.whl && \
# then we want to link the source (with the -e flag) and if we're in prod, we
# want to delete the stuff in the /code folder to keep it simple.
RUN if [ "$ENVIRONMENT" = "deployment" ] ; then\
pip install .[$ENVIRONMENT]; \
pip --no-cache-dir --disable-pip-version-check install .[$ENVIRONMENT]; \
rm -rf /code/* /code/.git* ; \
else \
pip install --editable .[$ENVIRONMENT]; \
pip --disable-pip-version-check install --editable .[$ENVIRONMENT]; \
fi && \
pip freeze && \
([ "$ENVIRONMENT" != "deployment" ] || \
Expand Down

0 comments on commit 0ad23f0

Please sign in to comment.