-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
41 lines (37 loc) · 1018 Bytes
/
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
# ---- Base Node ----
FROM node:lts-alpine AS base
#
# ---- Dependencies ----
FROM base AS dependencies
# copy project file
COPY . .
# install node packages
RUN npm set progress=false && npm config set depth 0
RUN npm install --only=production
# create directory in case of no production modules
RUN mkdir node_modules
# copy production node_modules aside
RUN cp -R node_modules prod_node_modules
# install ALL node_modules, including 'devDependencies'
RUN npm install
# build for production
RUN npm run build
# ---- Test ----
# run linters, setup and tests
FROM dependencies AS test
COPY . .
RUN npm run test
#
# ---- Release ----
FROM base AS release
# install process manager
RUN npm install pm2 -g
# copy production node_modules
COPY --from=dependencies /prod_node_modules ./node_modules
# copy compiled project JavaScript code
COPY --from=dependencies /prod .
# (optional) add environment variables
# ENV VARIABLE_NAME "variable_value"
# (optional) expose port(s)
# EXPOSE 9009
CMD ["pm2-runtime","app.js"]