forked from TourmalineCore/to-dos-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
30 lines (19 loc) · 803 Bytes
/
Dockerfile
File metadata and controls
30 lines (19 loc) · 803 Bytes
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
FROM node:20.11.1-alpine3.19 as build
# copying of only these 2 files with dependencies allows to cache them when these files aren't changing
# in this case when you change the code but not the dependencies they won't be re-installed again
COPY package.json .
COPY package-lock.json .
RUN npm ci
COPY . .
RUN npm run build
FROM node:20.11.1-alpine3.19
COPY package.json .
COPY package-lock.json .
# second installation of only production dependencies reduces the final docker image size
# with the default packages setup it was ~130MB size reduction from ~300MB to ~172MB
# however, it requires some additional time to re-install part of the deps that were installed in the first build stage
RUN npm ci --omit=dev
COPY --from=build /dist /dist
ENV PORT=80
EXPOSE 80
CMD node dist/src/main.js