-
Notifications
You must be signed in to change notification settings - Fork 16
/
Dockerfile
122 lines (90 loc) · 4.13 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
FROM ubuntu:24.04 AS upstream
RUN --mount=type=cache,target=/var/lib/apt/lists \
--mount=type=cache,target=/var/cache,sharing=locked \
apt-get update \
&& apt-get upgrade --yes \
&& DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install --assume-yes --no-install-recommends tzdata
FROM upstream AS base-all
SHELL ["/bin/bash", "-o", "pipefail", "-cux"]
RUN --mount=type=cache,target=/var/lib/apt/lists \
--mount=type=cache,target=/var/cache,sharing=locked \
apt-get update \
&& apt-get install --assume-yes --no-install-recommends fonts-dejavu-core gnupg python-is-python3 python3-pip python3-venv \
&& python3 -m venv /venv
ENV PATH=/venv/bin:$PATH
FROM base-all AS poetry
ENV POETRY_DYNAMIC_VERSIONING_BYPASS=0.0.0.dev
WORKDIR /tmp
COPY requirements.txt ./
RUN --mount=type=cache,target=/root/.cache \
python3 -m pip install --disable-pip-version-check --requirement=requirements.txt \
&& rm requirements.txt
COPY poetry.lock pyproject.toml ./
RUN poetry export --extras=process --output=requirements.txt \
&& poetry export --with=dev --output=requirements-dev.txt
RUN --mount=type=cache,target=/var/lib/apt/lists \
--mount=type=cache,target=/var/cache,sharing=locked \
apt-get update \
&& apt-get install --assume-yes --no-install-recommends curl
FROM base-all AS base-dist
RUN --mount=type=cache,target=/var/lib/apt/lists \
--mount=type=cache,target=/var/cache,sharing=locked \
apt-get update \
&& apt-get install --assume-yes --no-install-recommends \
graphicsmagick pdftk-java \
tesseract-ocr tesseract-ocr-fra tesseract-ocr-deu tesseract-ocr-eng \
libimage-exiftool-perl software-properties-common ghostscript optipng pngquant libzbar0
RUN --mount=type=cache,target=/root/.cache \
--mount=type=bind,from=poetry,source=/tmp,target=/tmp \
python3 -m pip install --disable-pip-version-check --no-deps --requirement=/tmp/requirements.txt \
&& python3 -m pip freeze > /requirements.txt \
&& mkdir -p /source /destination /scan-codes
VOLUME /source \
/destination \
/scan-codes
WORKDIR /opt
ARG VERSION
ENV VERSION=$VERSION
FROM base-dist AS tests-dist
RUN --mount=type=cache,target=/var/lib/apt/lists \
--mount=type=cache,target=/var/cache,sharing=locked \
apt-get update \
&& apt-get install --assume-yes --no-install-recommends poppler-utils ghostscript graphviz
RUN --mount=type=cache,target=/root/.cache \
--mount=type=bind,from=poetry,source=/tmp,target=/tmp \
python3 -m pip install --disable-pip-version-check --no-deps --requirement=/tmp/requirements-dev.txt
FROM base-dist AS base
COPY scan_to_paperless scan_to_paperless/
COPY pyproject.toml README.md ./
RUN --mount=type=cache,target=/root/.cache \
python3 -m pip install --disable-pip-version-check --no-deps --editable . \
&& pip freeze --all > /requirements.txt
ENV SCHEMA_BRANCH=master
CMD ["scan-process"]
FROM upstream AS tests-node-modules
SHELL ["/bin/bash", "-o", "pipefail", "-cux"]
WORKDIR /src
RUN --mount=type=cache,target=/var/lib/apt/lists \
--mount=type=cache,target=/var/cache,sharing=locked \
apt-get update \
&& apt-get install --assume-yes --no-install-recommends npm curl ca-certificates
FROM tests-dist AS tests
SHELL ["/bin/bash", "-o", "pipefail", "-cux"]
COPY . ./
RUN --mount=type=cache,target=/root/.cache \
python3 -m pip install --disable-pip-version-check --no-deps --editable .
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
RUN --mount=type=cache,target=/var/lib/apt/lists \
--mount=type=cache,target=/var/cache,sharing=locked \
apt-get update \
&& apt-get install --assume-yes --no-install-recommends software-properties-common \
&& add-apt-repository ppa:savoury1/pipewire \
&& add-apt-repository ppa:savoury1/chromium \
&& apt-get update \
&& apt-get install --assume-yes --no-install-recommends chromium-browser npm
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
FROM base AS all
RUN --mount=type=cache,target=/var/lib/apt/lists \
--mount=type=cache,target=/var/cache,sharing=locked \
apt-get update \
&& apt-get install --assume-yes --no-install-recommends tesseract-ocr-all