-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathDockerfile
56 lines (39 loc) · 1.15 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
ARG NODE_VER="14.3.0"
# --------------------------------------
# BASE NODE
# --------------------------------------
FROM node:${NODE_VER}-alpine as BASE
ARG PORT=3000
ENV PORT=$PORT
ENV HOME=/app
RUN mkdir -p $HOME
WORKDIR $HOME
COPY package.json package-lock.json ./
# --------------------------------------
# DEPENDENCIES
# --------------------------------------
FROM BASE as DEPENDENCIES
RUN npm install --only=production
# copy production node_modules aside
RUN cp -R node_modules prod_node_modules
# install ALL node_modules, including 'devDependencies'
RUN npm install
# --------------------------------------
# TEST
# --------------------------------------
# run linters, setup and tests
FROM dependencies AS TEST
COPY .eslintrc.json .
COPY /src ./src/
COPY /test ./test/
RUN npm run lint && npm run test
# --------------------------------------
# RELEASE
# --------------------------------------
FROM BASE as RELEASE
# copy production node_modules
COPY --from=dependencies /app/prod_node_modules ./node_modules
COPY /src ./src/
COPY ./nodemon.json ./
EXPOSE $PORT
CMD ["npm", "run", "start"]