From 20e671da46e0bfcadf0176be553dfb884a598bc5 Mon Sep 17 00:00:00 2001 From: Peter Dave Hello Date: Thu, 8 Aug 2024 04:57:41 +0800 Subject: [PATCH] Optimize Dockerfile to reduce image size Implement best practices for package management to minimize unnecessary data in Docker image. Remove APT cache after installation and prevent pip from creating cache files. These changes result in a smaller and more efficient Docker image. --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index a034374..2556fc4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,8 +13,9 @@ RUN apt-get update \ wkhtmltopdf \ texlive \ build-essential python3-dev python3-pip python3-setuptools python3-wheel python3-cffi libcairo2 libpango-1.0-0 libpangocairo-1.0-0 libgdk-pixbuf2.0-0 libffi-dev shared-mime-info \ + && rm -rf /var/lib/apt/lists/* \ # https://stackoverflow.com/questions/75608323/how-do-i-solve-error-externally-managed-environment-every-time-i-use-pip-3 - && pip3 install --break-system-packages weasyprint \ + && pip3 install --no-cache-dir --break-system-packages weasyprint \ && pandoc --version COPY --from=builder /usr/local/cargo/bin/md-to-pdf /usr/local/bin/md-to-pdf