-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
56 lines (36 loc) · 1.5 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
# ################################################################
# ### Base image ###
# ################################################################
FROM node:18-alpine as base
WORKDIR /opt
COPY . .
ARG NODE_ENV=production
ENV NODE_ENV ${NODE_ENV}
RUN apk update && \
apk upgrade && \
npm i npm@next-10 -g && \
chown node:node -R /opt
COPY --chown=node:node package*.json ./
USER node
# ################################################################
# ### build image ###
# ################################################################
FROM base as build
ENV NODE_ENV development
COPY --chown=node:node . .
RUN npm install && npm cache clean --force
ENV PATH /opt/node_modules/.bin:$PATH
RUN tsc -p ./tsconfig.json && \
resolve-tspaths --out "dist"
# ################################################################
# ### modules image ###
# ################################################################
FROM base as modules
RUN npm install && npm cache clean --force
# ################################################################
# ### production image ###
# ################################################################
FROM base as production
COPY --from=build --chown=node:node /opt/dist ./dist
COPY --from=modules --chown=node:node /opt/node_modules ./node_modules
CMD node dist/src/index.js