From 77629f68ce5f9071d942ff6d867d8b04a72a0a4e Mon Sep 17 00:00:00 2001 From: Pratik Raj Date: Fri, 31 Dec 2021 10:01:06 +0530 Subject: [PATCH] chore : 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 --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2e5adee7..7b9177d7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ RUN export GIT_COMMIT=$(git rev-list -1 HEAD) && \ CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo \ -ldflags "-X main.OECCommitVersion=$GIT_COMMIT -X main.OECVersion=1.0.1" -o nocgo -o /oec . FROM python:alpine3.12 as base -RUN pip install requests +RUN pip --no-cache-dir install requests RUN addgroup -S opsgenie && \ adduser -S opsgenie -G opsgenie && \ apk update && \ @@ -16,4 +16,4 @@ RUN mkdir -p /var/log/opsgenie && \ chown -R opsgenie:opsgenie /var/log/opsgenie && \ chown -R opsgenie:opsgenie /opt/oec USER opsgenie -ENTRYPOINT ["/opt/oec"] \ No newline at end of file +ENTRYPOINT ["/opt/oec"]