-
Notifications
You must be signed in to change notification settings - Fork 16
/
Dockerfile
129 lines (99 loc) · 4.95 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
123
124
125
126
127
128
129
FROM ubuntu:22.04 AS upstream
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 upgrade --yes \
&& apt-get install --assume-yes --no-install-recommends python3-pip python-is-python3 gnupg fonts-dejavu-core
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 apt-transport-https gnupg curl ca-certificates
COPY .nvmrc /tmp
RUN --mount=type=cache,target=/var/lib/apt/lists \
--mount=type=cache,target=/var/cache,sharing=locked \
NODE_MAJOR="$(cat /tmp/.nvmrc)" \
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${NODE_MAJOR}.x nodistro main" > /etc/apt/sources.list.d/nodesource.list \
&& curl --silent https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor --output=/etc/apt/keyrings/nodesource.gpg \
&& apt-get update \
&& apt-get install --assume-yes --no-install-recommends "nodejs=${NODE_MAJOR}.*"
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 .
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 gnupg
COPY .nvmrc /tmp
COPY --from=tests-node-modules /etc/apt/sources.list.d/nodesource.list /etc/apt/sources.list.d/nodesource.list
COPY --from=tests-node-modules /etc/apt/keyrings/nodesource.gpg /etc/apt/keyrings/nodesource.gpg
RUN --mount=type=cache,target=/var/lib/apt/lists \
--mount=type=cache,target=/var/cache,sharing=locked \
NODE_MAJOR="$(cat /tmp/.nvmrc)" \
&& apt-get update \
&& apt-get install --assume-yes --no-install-recommends "nodejs=${NODE_MAJOR}.*" \
&& echo "For Chrome installed by Pupetter" \
&& DEBIAN_FRONTEND=noninteractive apt-get install --assume-yes --no-install-recommends \
libx11-6 libx11-xcb1 libxcomposite1 libxcursor1 \
libxdamage1 libxext6 libxi6 libxtst6 libnss3 libcups2 libxss1 libxrandr2 libasound2 libatk1.0-0 \
libatk-bridge2.0-0 libpangocairo-1.0-0 libgtk-3.0 libxcb-dri3-0 libgbm1 libxshmfence1
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