-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
54 lines (44 loc) · 1.59 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
# ------------------
# Temp image
# ------------------
FROM node:20-bullseye-slim AS tmp
# Workdir
WORKDIR /usr/app/tmp
# Copy and install dependencies separately from the app's code
# to take advantage of Docker's layer caching
# See: https://docs.docker.com/build/cache/#optimizing-how-you-use-the-build-cache
COPY package.json .
COPY package-lock.json .
RUN npm ci --ignore-scripts --omit=dev && \
npm pkg delete commitlint devDependencies jest scripts && \
npm cache clean --force && \
chmod 100 ./node_modules/htmltidy2/bin/linux64/tidy && \
# Remove included Windows and macOS binaries
rm -rf ./node_modules/node-poppler/src/lib/* && \
rm -rf ./node_modules/node-unrtf/src/lib/* && \
rm -rf ./node_modules/htmltidy2/bin/win64 && \
rm -rf ./node_modules/htmltidy2/bin/darwin
# Copy source
COPY . .
# Create temp folder for files to be stored whilst being converted
RUN mkdir -p ./temp/
# ------------------
# Final image
# ------------------
FROM node:20-bullseye-slim AS main
# Workdir
WORKDIR /usr/app
# Change ownership of workdir to allow for temp dir to be deleted on exit
RUN chown node:node /usr/app
# Install OS dependencies
# Curl needed for healthcheck command
RUN apt-get -q update &&\
apt-get -y --no-install-recommends install curl poppler-data poppler-utils unrtf && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Copy files from tmp image and change ownership
COPY --from=tmp --chown=node:node /usr/app/tmp /usr/app
# Node images provide 'node' unprivileged user to run apps and prevent
# privilege escalation attacks
USER node
CMD ["node", "."]