From 8fcc14a55c0384275c02a45b00d8ad353be78b44 Mon Sep 17 00:00:00 2001 From: Marten Ringwelski Date: Tue, 7 Nov 2023 09:55:00 +0100 Subject: [PATCH] refactor: Make the Dockerfile a tiny bit cache friendlier Still not great as the whole installation happens after copying but at least not copying is not the first thing we do. Related #124 --- Dockerfile | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index ce0a40eb..e7978ab4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,25 @@ FROM phusion/baseimage:jammy-1.0.3 -WORKDIR /opt/app +RUN --mount=type=cache,target=/var/cache/apt \ +apt update && apt install -y \ + python3.11 \ + python3.11-dev \ + python3.11-venv \ + gcc -COPY . /opt/app +RUN python3.11 -m venv /venv +ENV PATH=/venv/bin:$PATH +ENV VIRTUAL_ENV=/venv -WORKDIR /opt/app/fact_extractor +ADD ./fact_extractor/install/pre_install.sh /app/fact_extractor/install/pre_install.sh +RUN --mount=type=cache,target=/var/cache/apt \ + --mount=type=cache,target=/root/.cache/pip \ +/app/fact_extractor/install/pre_install.sh -ARG USER=root -ARG DEBIAN_FRONTEND=noninteractive +ADD . /app +RUN --mount=type=cache,target=/var/cache/apt \ + --mount=type=cache,target=/root/.cache/pip \ +/app/fact_extractor/install.py -RUN install_clean python3.11 python3.11-dev python3.11-venv gcc -RUN python3.11 -m venv venv - -RUN . venv/bin/activate && install/pre_install.sh - -RUN . venv/bin/activate && venv/bin/python3.11 install.py - -ENV PATH=/opt/app/fact_extractor/venv/bin:$PATH - -ENTRYPOINT ["./docker_extraction.py"] +ENTRYPOINT ["/app/fact_extractor/docker_extraction.py"]