-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
99 lines (81 loc) · 2.98 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
FROM ubuntu:jammy
ARG DEBIAN_FRONTEND=noninteractive
ARG TZ=America/Los_Angeles
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
software-properties-common \
wget \
xvfb \
libxss1 \
dbus \
dbus-x11 \
git \
openssh-client \
&& rm -rf /var/lib/apt/lists/*
# Install ghostscript
RUN apt-get update && apt-get install -y \
build-essential make gcc g++ \
python3 \
ghostscript \
libgs-dev \
&& rm -rf /var/lib/apt/lists/*
# Update Freetype
COPY docker-font.conf /etc/fonts/local.conf
ENV FREETYPE_PROPERTIES="truetype:interpreter-version=35"
# Install fonts
# from https://github.com/browserless/browserless/blob/main/docker/chrome/Dockerfile#L11-L27
RUN echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true" | debconf-set-selections && \
apt-get -y -qq install software-properties-common &&\
apt-add-repository "deb http://archive.canonical.com/ubuntu $(lsb_release -sc) partner" && \
apt-get -y -qq --no-install-recommends install \
fontconfig \
fonts-freefont-ttf \
fonts-gfs-neohellenic \
fonts-indic \
fonts-ipafont-gothic \
fonts-kacst \
fonts-liberation \
fonts-noto-cjk \
fonts-noto-color-emoji \
fonts-roboto \
fonts-thai-tlwg \
fonts-ubuntu \
fonts-wqy-zenhei \
&& rm -rf /var/lib/apt/lists/*
ENV NODE_ENV=development
# Install Node.js
RUN apt-get update && \
mkdir -p /etc/apt/keyrings && \
curl -sL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >> /etc/apt/sources.list.d/nodesource.list && \
apt-get update && \
apt-get install -y nodejs && \
rm -rf /var/lib/apt/lists/*
# Add user so we don't need --no-sandbox.
RUN groupadd --gid 999 node \
&& useradd --uid 999 --gid node --shell /bin/bash --create-home node \
&& adduser node audio \
&& adduser node video
ENV CONNECTION_TIMEOUT=60000
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV PLAYWRIGHT_BROWSERS_PATH=/usr/local/bin/chromium-browsers
# Revision from https://github.com/microsoft/playwright/blob/main/packages/playwright-core/browsers.json#L6
ENV BROWSER_REVISION=1097
ENV PUPPETEER_EXECUTABLE_PATH="$PLAYWRIGHT_BROWSERS_PATH/chromium-$BROWSER_REVISION/chrome-linux/chrome"
RUN npm install [email protected] --location=global
RUN playwright install --with-deps chromium
RUN npm install node-gyp --location=global
ENV DBUS_SESSION_BUS_ADDRESS autolaunch:
RUN service dbus start
# Run everything after as non-privileged user.
USER node
ENV DIRECTORY /home/node/pagedjs-cli
RUN mkdir -p $DIRECTORY
WORKDIR $DIRECTORY
COPY --chown=node:node package.json package-lock.json rollup.config.js src/browser.js $DIRECTORY/
COPY --chown=node:node src/browser.js $DIRECTORY/src/
RUN npm install
RUN GS4JS_HOME="/usr/lib/$(gcc -dumpmachine)" npm install ghostscript4js
COPY --chown=node:node . $DIRECTORY
CMD ["./src/cli.js"]