idhub: optimize size

applies optimizations because use of: apt, pip (python)

debian:bookworm-slim 1.21GB
python:3.11.7-slim-bookworm 880 MiB
This commit is contained in:
pedro 2024-01-25 14:54:12 +01:00
parent a9022ae8d4
commit 07376ba0b1
1 changed files with 19 additions and 9 deletions

View File

@ -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 # 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 \ RUN apt update && \
python3-minimal \ apt-get install -y \
python3-pip \
python3-dev \
python-is-python3 \
git \ git \
sqlite3 \ sqlite3 \
jq \ 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 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 <<END
[install]
compile = no
[global]
no-cache-dir = True
END
RUN pip install --upgrade pip
COPY ssikit_trustchain/didkit-0.3.2-cp311-cp311-manylinux_2_34_x86_64.whl /opt/idhub COPY ssikit_trustchain/didkit-0.3.2-cp311-cp311-manylinux_2_34_x86_64.whl /opt/idhub
COPY IdHub/requirements.txt /opt/idhub COPY IdHub/requirements.txt /opt/idhub
RUN pip install -r requirements.txt --break-system-packages RUN pip install -r requirements.txt
COPY docker/idhub.entrypoint.sh / COPY docker/idhub.entrypoint.sh /
ENTRYPOINT sh /idhub.entrypoint.sh ENTRYPOINT sh /idhub.entrypoint.sh