-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
68 lines (59 loc) · 1.91 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
#######################
# Step 1: Base target #
#######################
FROM node:10-alpine as base
RUN apk update && apk upgrade && \
echo @edge http://nl.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories && \
echo @edge http://nl.alpinelinux.org/alpine/edge/main >> /etc/apk/repositories && \
apk add --no-cache \
chromium@edge=72.0.3626.121-r0 \
nss@edge \
freetype@edge \
harfbuzz@edge \
ttf-freefont@edge
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
ENV PUPPETEER_EXECUTABLE_PATH /usr/bin/chromium-browser
# Base dir /app
WORKDIR /app
# Expose the listening port of your app
EXPOSE 7000
################################
# Step 2: "development" target #
################################
FROM base as development
ARG APP_VERSION
COPY src src/
COPY babel.config.js package.json package-lock.json ./
# Install app dependencies
RUN npm --no-git-tag-version version ${APP_VERSION} ; npm install
#CMD ["npm", "start"]
CMD ["npm","run", "dev"]
##########################
# Step 3: "build" target #
##########################
FROM development as build
ENV NPM_CONFIG_LOGLEVEL warn
# Transpile the code with babel
RUN npm run build
###############################
# Step 4: "production" target #
###############################
FROM build as production
ARG NPM_AUDIT_DRY_RUN
ENV NODE_ENV=production
ARG APP_VERSION
# Copy the transpiled code to use in production (in /app)
COPY --from=build /app/dist ./dist
COPY package.json package-lock.json ./
# Install production dependencies and clean cache
RUN npm --no-git-tag-version version ${APP_VERSION} && \
npm install --production && \
npm config set audit-level moderate && \
npm audit --json --registry=https://registry.npmjs.org || ${NPM_AUDIT_DRY_RUN:-false} && \
npm cache clean --force
# Install pm2
RUN npm install pm2 -g
USER node
# Copy the pm2 config
COPY ecosystem.config.js .
CMD [ "pm2-runtime", "start", "ecosystem.config.js" ]