Skip to content

Commit

Permalink
feat : use --no-cache-dir flag to pip in dockerfiles to save space (#826
Browse files Browse the repository at this point in the history
)

using the "--no-cache-dir" flag in pip install, make sure downloaded packages by pip don't cache on the system. This is a best practice that makes sure to fetch from a repo instead of using a local cached one. Further, in the case of Docker Containers, by restricting caching, we can reduce image size. In terms of stats, it depends upon the number of python packages multiplied by their respective size. e.g for heavy packages with a lot of dependencies it reduces a lot by don't cache pip packages.

Further, more detailed information can be found at

https://medium.com/sciforce/strategies-of-docker-images-optimization-2ca9cc5719b6

Signed-off-by: Pratik Raj <[email protected]>
  • Loading branch information
Rajpratik71 authored Jun 20, 2024
1 parent b3fe7d1 commit 2a4091f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM quay.io/operator-framework/ansible-operator:v1.32.0
USER root

COPY requirements.yml ${HOME}/requirements.yml
RUN python3 -m pip install jmespath
RUN python3 -m pip install --no-cache-dir jmespath
RUN ansible-galaxy collection install community.general
RUN ansible-galaxy collection list
RUN ansible-galaxy collection install -r ${HOME}/requirements.yml \
Expand Down

0 comments on commit 2a4091f

Please sign in to comment.