Skip to content

Commit 967e44f

Browse files
maringuujstucke
authored andcommitted
refactor: Make the Dockerfile a tiny bit cache friendlier
Still not great as the whole installation happens after copying but at least copying is not the first thing we do anymore. Related #124
1 parent 92288e3 commit 967e44f

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

Dockerfile

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
FROM phusion/baseimage:jammy-1.0.3
22

3-
WORKDIR /opt/app
4-
5-
COPY . /opt/app
6-
7-
WORKDIR /opt/app/fact_extractor
8-
9-
ARG USER=root
10-
ARG DEBIAN_FRONTEND=noninteractive
11-
12-
RUN install_clean python3.11 python3.11-dev python3.11-venv gcc
13-
14-
RUN python3.11 -m venv venv
15-
16-
RUN . venv/bin/activate && install/pre_install.sh
17-
18-
RUN . venv/bin/activate && venv/bin/python3.11 install.py
19-
20-
ENV PATH=/opt/app/fact_extractor/venv/bin:$PATH
21-
22-
ENTRYPOINT ["./docker_extraction.py"]
3+
RUN --mount=type=cache,target=/var/cache/apt \
4+
apt update && apt install -y \
5+
python3.11 \
6+
python3.11-dev \
7+
python3.11-venv \
8+
gcc
9+
10+
RUN python3.11 -m venv /venv
11+
ENV PATH=/venv/bin:$PATH \
12+
VIRTUAL_ENV=/venv \
13+
PYTHONPATH=/app/fact_extractor
14+
15+
ADD ./fact_extractor/install/pre_install.sh /app/fact_extractor/install/pre_install.sh
16+
RUN --mount=type=cache,target=/var/cache/apt \
17+
--mount=type=cache,target=/root/.cache/pip \
18+
/app/fact_extractor/install/pre_install.sh
19+
20+
ADD . /app
21+
RUN --mount=type=cache,target=/var/cache/apt \
22+
--mount=type=cache,target=/root/.cache/pip \
23+
/app/fact_extractor/install.py
24+
25+
26+
ENTRYPOINT ["/app/fact_extractor/docker_extraction.py"]

0 commit comments

Comments
 (0)