-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
72 lines (36 loc) · 1.09 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
FROM node:18.16.0-slim as base
ARG NODE_ENV=production
ENV NODE_ENV $NODE_ENV
ARG PORT=3000
ENV PORT $PORT
EXPOSE $PORT
# 의존성 이미지가 시작될 때까지 기다리기 위한 유틸리티(즉, MongoDB가 준비가 되면 NestJS 애플리케이션이 시작한다.)
COPY --from=ghcr.io/ufoscout/docker-compose-wait:latest /wait /wait
RUN npm i npm@9.5.1 -g
USER node
WORKDIR /opt/node_app
COPY --chown=node:node package*.json ./
RUN npm ci && npm cache clean --force
ENV PATH /opt/node_app/node_modules/.bin:$PATH
FROM base as dev
ENV NODE_ENV=development
USER node
WORKDIR /opt/node_app
RUN npm install
WORKDIR /opt/node_app/app
CMD ["npm", "run", "start:dev"]
FROM base as source
USER node
WORKDIR /opt/node_app/app
COPY --chown=node:node . .
FROM source as test
ENV NODE_ENV=development
USER node
COPY --from=dev /opt/node_app/node_modules /opt/node_app/node_modules
CMD ["npm", "run", "test"]
FROM source as prod
USER node
HEALTHCHECK --interval=30s CMD node /opt/node_app/app/dist/healthcheck.js
WORKDIR /opt/node_app/app
RUN npm run build
CMD ["node", "dist/src/main"]