forked from sbs20/scanservjs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
86 lines (72 loc) · 2.41 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
# Builder image.
FROM arm64v8/node:14-alpine AS builder
ENV APP_DIR=/app
WORKDIR "$APP_DIR"
COPY package*.json "$APP_DIR/"
COPY packages/server/package*.json "$APP_DIR/packages/server/"
COPY packages/client/package*.json "$APP_DIR/packages/client/"
RUN npm run install
COPY packages/client/ "$APP_DIR/packages/client/"
COPY packages/server/ "$APP_DIR/packages/server/"
RUN npm run build
# production image
FROM arm64v8/node:14-buster-slim
# Make it possible to override the UID/GID/username of the user running scanservjs
ARG UID=2001
ARG GID=2001
ARG UNAME=scanservjs
ENV APP_DIR=/app
WORKDIR "$APP_DIR"
RUN apt-get update \
&& apt-get install -yq curl gpg \
&& echo 'deb http://download.opensuse.org/repositories/home:/pzz/Debian_10/ /' \
| tee /etc/apt/sources.list.d/home:pzz.list \
&& curl -fsSL https://download.opensuse.org/repositories/home:pzz/Debian_10/Release.key \
| gpg --dearmor \
| tee /etc/apt/trusted.gpg.d/home:pzz.gpg \
> /dev/null \
&& apt-get update \
&& apt-get install -yq \
imagemagick \
sane \
sane-utils \
sane-airscan \
tesseract-ocr \
tesseract-ocr-por \
&& sed -i \
's/policy domain="coder" rights="none" pattern="PDF"/policy domain="coder" rights="read | write" pattern="PDF"'/ \
/etc/ImageMagick-6/policy.xml \
&& sed -i \
's/policy domain="resource" name="disk" value="1GiB"/policy domain="resource" name="disk" value="8GiB"'/ \
/etc/ImageMagick-6/policy.xml \
&& npm install -g npm@7.11.2
# Add Hp drivers
RUN apt-get install -yq libsane-hpaio
RUN adduser root lp
# Create a known user
RUN groupadd -g $GID -o $UNAME
RUN useradd -o -u $UID -g $GID -m -s /bin/bash $UNAME
ENV \
# This goes into /etc/sane.d/net.conf
SANED_NET_HOSTS="" \
# This gets added to /etc/sane.d/airscan.conf
AIRSCAN_DEVICES="" \
# This directs scanserv not to bother querying `scanimage -L`
SCANIMAGE_LIST_IGNORE="" \
# This gets added to scanservjs/server/config.js:devices
DEVICES="" \
# Override OCR language
OCR_LANG="" \
# Restart DBus workaround
DBUS_WORKAROUND="false"
# Copy entry point
COPY run.sh /run.sh
RUN ["chmod", "+x", "/run.sh"]
ENTRYPOINT [ "/run.sh" ]
# Copy the code and install
COPY --from=builder "$APP_DIR/dist" "$APP_DIR/"
RUN npm install --production
# Change the ownership of config and data since we need to write there
RUN chown -R $UID:$GID config data /etc/sane.d/net.conf /etc/sane.d/airscan.conf
USER root
EXPOSE 8080