-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
73 lines (53 loc) · 1.43 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
FROM node:alpine as base
# Installs latest Chromium (85) package.
RUN apk add --no-cache \
chromium \
nss \
freetype \
freetype-dev \
harfbuzz \
ca-certificates \
ttf-freefont \
ffmpeg \
font-noto-emoji
# Tell Puppeteer to skip installing Chrome. We'll be using the installed package.
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
# install all node_modules, including dev
FROM base as deps
RUN mkdir /app/
WORKDIR /app/
ADD package.json ./
RUN npm install
# setup production node_modules
FROM base as production-deps
RUN mkdir /app/
WORKDIR /app/
COPY --from=deps /app/node_modules /app/node_modules
ADD package.json /app/
RUN npm prune --production
# build app
FROM base as build
RUN mkdir /app/
WORKDIR /app/
COPY --from=deps /app/node_modules /app/node_modules
# app code changes all the time
ADD . .
RUN npm run postinstall
RUN npm run build
# build smaller image for running
FROM base
ENV NODE_ENV=production
RUN mkdir /app/
WORKDIR /app/
# Add user so we don't need --no-sandbox.
RUN addgroup -S pptruser && adduser -S -g pptruser pptruser \
&& mkdir -p /home/pptruser/Downloads /app \
&& chown -R pptruser:pptruser /home/pptruser \
&& chown -R pptruser:pptruser /app
# Run everything after as non-privileged user.
USER pptruser
COPY --from=production-deps /app/node_modules /app/node_modules
COPY --from=build /app /app
ADD . .
CMD ["npm", "run", "start"]