-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathDockerfile
More file actions
56 lines (43 loc) · 1.63 KB
/
Dockerfile
File metadata and controls
56 lines (43 loc) · 1.63 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
# Stage 1: Build
FROM registry.access.redhat.com/ubi9/nodejs-22:9.7-1776196021@sha256:1fe6a3926ed6249559bb079d523a81e4dad1628205edfd9dea9ab8247f08caec AS builder
USER 0
WORKDIR /pdf-gen
COPY . .
RUN mkdir -p bin
# Install build tools for native npm modules (node-gyp)
RUN dnf install -y python3 make gcc-c++ git && dnf clean all
# Install npm dependencies from lockfile
RUN npm ci
# Download Chrome for PDF generation
RUN node node_modules/puppeteer/install.mjs
# Check for circular dependencies
RUN node circular.js
# Build the application
ENV NODE_ENV=production
RUN npm run build
# Stage 2: Runtime
FROM registry.access.redhat.com/ubi9/nodejs-22-minimal:9.7-1776157051@sha256:5d6d3781346b84e5ebf7c968bd6e897425de5ba9046169b1c898df01c8525350
USER 0
WORKDIR /pdf-gen
# Install Chrome runtime dependencies
RUN microdnf install -y bzip2 fontconfig pango \
libXcomposite libXcursor libXdamage \
libXext libXi libXtst cups-libs \
libXScrnSaver libXrandr alsa-lib \
atk gtk3 libdrm libgbm libxshmfence \
nss && microdnf clean all
# Copy application artifacts from builder
COPY --from=builder /pdf-gen/dist ./dist
COPY --from=builder /pdf-gen/node_modules ./node_modules
COPY --from=builder /pdf-gen/package.json ./package.json
COPY --from=builder /pdf-gen/public ./public
COPY --from=builder /pdf-gen/docs/openapi.json ./docs/openapi.json
# Copy Chrome binary
COPY --from=builder /opt/app-root/src/.cache/puppeteer /opt/app-root/src/.cache/puppeteer
ENV HOME=/opt/app-root/src
ENV XDG_CONFIG_HOME="/tmp/.chromium"
ENV XDG_CACHE_HOME="/tmp/.chromium"
ENV NODE_ENV=production
ENV DEBUG=puppeteer-cluster:*
EXPOSE 8000
CMD ["node", "./dist/server.js"]