Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
123 lines (105 loc) · 3.9 KB
/
Copy pathDockerfile
File metadata and controls
123 lines (105 loc) · 3.9 KB
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
# References:
# - https://github.com/gotenberg/gotenberg/blob/main/build/Dockerfile
# - https://github.com/microsoft/playwright/blob/main/utils/docker/Dockerfile.noble
FROM debian:13-slim AS base
ARG DEBIAN_FRONTEND=noninteractive
ARG TZ=Asia/Tokyo
ARG USER_GID=1000
ARG USER_UID=1000
ENV LANG=C.UTF-8
ENV LC_ALL=C.UTF-8
RUN set -x \
&& groupadd --gid $USER_GID vivliostyle \
&& useradd --uid $USER_UID --gid vivliostyle --shell /bin/bash --home /home/vivliostyle --no-create-home vivliostyle \
&& mkdir -p /home/vivliostyle \
&& chown vivliostyle: /home/vivliostyle
RUN set -x \
&& apt-get update -qq \
&& apt-get upgrade -yqq \
&& apt-get install -y -qq --no-install-recommends \
ca-certificates curl gnupg tini \
# Feature-parity with node.js base images
git openssh-client \
# dependencies for press-ready
ghostscript poppler-utils \
# for Puppeteer Firefox installation
xz-utils \
# for @puppeteer/browsers v3+ Chrome zip extraction
unzip \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* `npm config get cache`/_npx
# Tofu fallback (#832)
# https://github.com/adobe-fonts/adobe-notdef/releases/tag/1.001
COPY build/adobe-notdef/AND-Regular.otf /usr/share/fonts/opentype/adobe-notdef/
COPY build/adobe-notdef/LICENSE.md /usr/share/doc/adobe-notdef/
# Install Node.js
RUN set -x \
&& apt-get update -qq \
&& apt-get upgrade -yqq \
&& curl -fsSL https://deb.nodesource.com/setup_24.x | bash - \
&& apt-get install -y nodejs \
&& node -v \
&& npm -v \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN set -x \
&& mkdir -p /opt \
&& mkdir -p /data \
&& chown -R vivliostyle: /data \
&& chown -R vivliostyle: /opt
# Install the pnpm version pinned by `packageManager`
COPY package.json /tmp/package.json
RUN set -x \
&& npm install -g "$(node -p "require('/tmp/package.json').packageManager.split('+')[0]")" \
&& pnpm -v \
&& rm -rf /tmp/* /var/tmp/*
USER vivliostyle
WORKDIR /opt/vivliostyle-cli
# Build stage
FROM base AS builder
COPY --chown=vivliostyle:vivliostyle . /opt/vivliostyle-cli
RUN pnpm install && pnpm build
# Runtime stage
FROM base AS runtime
ARG BROWSER
RUN test $BROWSER
ARG VS_CLI_VERSION
RUN test $VS_CLI_VERSION
COPY --chown=vivliostyle:vivliostyle . /opt/vivliostyle-cli
RUN pnpm install --prod --ignore-scripts \
&& echo $VS_CLI_VERSION > .vs-cli-version
COPY --from=builder --chown=vivliostyle:vivliostyle /opt/vivliostyle-cli/dist/ /opt/vivliostyle-cli/dist/
ENV PATH="/opt/vivliostyle-cli/node_modules/.bin:${PATH}"
# Install Puppeteer browsers (use the @puppeteer/browsers locked by Vivliostyle CLI)
USER root
RUN apt-get update -qq \
&& apt-get upgrade -yqq \
&& mkdir -p /opt/puppeteer \
&& /opt/vivliostyle-cli/node_modules/.bin/browsers install "$BROWSER" \
--path /opt/puppeteer --install-deps \
&& chown -R vivliostyle: /opt/puppeteer \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Let arbitrary UIDs (e.g. `docker run --user`) write build-ids.json and
# download browsers here. build-ids.json sits at the cache root; each
# browser installs under its own dir (chrome/<buildId>/...).
RUN mkdir -p /opt/puppeteer \
&& find /opt/puppeteer -maxdepth 1 -type d -exec chmod 1777 {} +
# Disable font hinting (#866)
RUN rm /etc/fonts/conf.d/10-hinting-slight.conf \
&& ln -s /usr/share/fontconfig/conf.avail/10-hinting-none.conf /etc/fonts/conf.d/10-hinting-none.conf
RUN ln -s /opt/vivliostyle-cli/dist/cli.js /usr/local/bin/vivliostyle \
&& ln -s /opt/vivliostyle-cli/dist/cli.js /usr/local/bin/vs
# Install Noto fonts
COPY build/fonts.conf /tmp/fonts.conf
ARG BUNDLE_NOTO=1
RUN set -x \
&& if [ "$BUNDLE_NOTO" = 1 ]; then \
apt-get update -qq \
&& apt-get install -y -qq fonts-noto \
&& mkdir -p /etc/fonts \
&& cp /tmp/fonts.conf /etc/fonts/local.conf \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*; \
else \
rm -f /tmp/fonts.conf; \
fi
USER vivliostyle
WORKDIR /data
ENTRYPOINT [ "vivliostyle" ]