Skip to content

Commit 607bce7

Browse files
committed
use --no-cache-dir flag to pip in dockerfiles to save space
using "--no-cache-dir" flag in pip install ,make sure downloaded packages by pip don't cached on system . This is a best practice which make sure to fetch from repo instead of using local cached one . Further , in case of Docker Containers , by restricting caching , we can reduce image size. In term 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 reduce a lot by don't caching pip packages. Further , more detail information can be found at https://medium.com/sciforce/strategies-of-docker-images-optimization-2ca9cc5719b6 Signed-off-by: Pratik Raj <[email protected]>
1 parent ae53701 commit 607bce7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

docker/aws_lambda_layer/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ WORKDIR /install
44
RUN yum install -y amazon-linux-extras
55
RUN amazon-linux-extras enable python3.8
66
RUN yum install -y python38 python38-devel python3-pip zip gcc
7-
RUN python3.8 -m pip install --upgrade pip && \
8-
python3.8 -m pip install virtualenv
7+
RUN python3.8 -m pip install --no-cache-dir --upgrade pip && \
8+
python3.8 -m pip install --no-cache-dir virtualenv
99
RUN python3.8 -m venv lambda
1010
RUN source lambda/bin/activate
1111
# Python dependencies to be included in output zip file:
12-
RUN python3.8 -m pip install influxdb-client[ciso] -t /install/python
12+
RUN python3.8 -m pip install --no-cache-dir influxdb-client[ciso] -t /install/python
1313
# Create zip file
1414
RUN zip -r /install/python.zip python/
1515
VOLUME ["/install"]

0 commit comments

Comments
 (0)