-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.prod
50 lines (29 loc) · 872 Bytes
/
Dockerfile.prod
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
### DEVELOPMENT
FROM node:20.5.1-slim as development
USER node
RUN mkdir /home/node/app
WORKDIR /home/node/app
COPY --chown=node:node package*.json ./
RUN npm ci
COPY --chown=node:node . .
CMD [ "tail", "-f", "/dev/null" ]
### BUILDER
FROM node:20.5.1-slim as builder
USER node
RUN mkdir /home/node/app
WORKDIR /home/node/app
COPY --chown=node:node --from=development /home/node/app ./
RUN npm run build
ENV NODE_ENV production
RUN npm ci --only=production
### PRODUCTION
FROM node:20.5.1-slim as production
USER node
RUN mkdir /home/node/app
WORKDIR /home/node/app
COPY --chown=node:node --from=builder /home/node/app/dist ./dist
COPY --chown=node:node --from=builder /home/node/app/node_modules ./node_modules
COPY --chown=node:node --from=builder /home/node/app/package.json ./
EXPOSE 3000
ENV NODE_ENV production
CMD [ "npm", "run", "start:prod" ]