From c38c488642cdecaaee75466ef239a47a6d716613 Mon Sep 17 00:00:00 2001 From: Konstantin Demin Date: Thu, 10 Oct 2024 00:23:55 +0300 Subject: [PATCH] image: improve Python cache copying --- Dockerfile | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index cf18aca..6c487cc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -64,6 +64,12 @@ RUN d="@$(date '+%s')" ; \ find /usr/local/lib/ -name '*.pyc' -exec touch -m -d "$d" {} + ; \ find /usr/local/lib/ -name __pycache__ -exec touch -m -d "$d" {} + +WORKDIR /pycache +RUN find /usr/local/ -type f -name '*.py[co]' -printf '%P\0' \ + | sort -zV \ + | tar -C /usr/local --null -T - -cf - \ + | tar -xf - + ## --- FROM deps @@ -76,12 +82,10 @@ COPY /Dockerfile /usr/local/share/ COPY --from=setup /etc/apt/keyrings/angie.gpg.asc /etc/apt/keyrings/ COPY --from=setup /etc/apt/sources.list.d/angie.sources /etc/apt/sources.list.d/ -## RFC: Python cache -## TODO: reduce load by selecting only __pycache__ directories in either way -COPY --from=pycache /usr/local/lib/ /usr/local/lib/ +COPY /j2cfg/ /usr/local/lib/j2cfg/ -## already copied by statement above -# COPY /j2cfg/ /usr/local/lib/j2cfg/ +## RFC: Python cache +COPY --from=pycache /pycache/ /usr/local/ ENV ANGIE_MODULES_DIR=/usr/lib/angie/modules