From 07376ba0b1ed90d1e8668a5f18bc9dba6fbd9e48 Mon Sep 17 00:00:00 2001 From: pedro Date: Thu, 25 Jan 2024 14:54:12 +0100 Subject: [PATCH] idhub: optimize size applies optimizations because use of: apt, pip (python) debian:bookworm-slim 1.21GB python:3.11.7-slim-bookworm 880 MiB --- docker/idhub.Dockerfile | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/docker/idhub.Dockerfile b/docker/idhub.Dockerfile index f9dd11c..345b265 100644 --- a/docker/idhub.Dockerfile +++ b/docker/idhub.Dockerfile @@ -1,23 +1,33 @@ -FROM debian:bookworm-slim +FROM python:3.11.7-slim-bookworm # last line is dependencies for weasyprint (for generating pdfs in lafede pilot) https://doc.courtbouillon.org/weasyprint/stable/first_steps.html#debian-11 -RUN apt update && apt-get install -y \ - python3-minimal \ - python3-pip \ - python3-dev \ - python-is-python3 \ +RUN apt update && \ + apt-get install -y \ git \ sqlite3 \ jq \ - python3-pip python3-cffi python3-brotli libpango-1.0-0 libpangoft2-1.0-0 + libpango-1.0-0 libpangoft2-1.0-0 \ + && pip install cffi brotli \ + && rm -rf /var/lib/apt/lists/* WORKDIR /opt/idhub -RUN python3 -m pip install --upgrade pip --break-system-packages +# reduce size (python specifics) -> src https://stackoverflow.com/questions/74616667/removing-pip-cache-after-installing-dependencies-in-docker-image +ENV PYTHONDONTWRITEBYTECODE=1 +# here document in dockerfile src https://stackoverflow.com/questions/40359282/launch-a-cat-command-unix-into-dockerfile +RUN cat > /etc/pip.conf <