-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
44 lines (30 loc) · 1006 Bytes
/
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
FROM node:20-alpine as builder
ARG CHINA_MIRROR=false
# enable china mirror when ENABLE_CHINA_MIRROR is true
RUN if [[ "$CHINA_MIRROR" = "true" ]] ; then \
echo "Enable China Alpine Mirror" && \
sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories; \
fi
RUN if [[ "$CHINA_MIRROR" = "true" ]] ; then \
echo "Enable China NPM Mirror" && \
npm install -g cnpm --registry=https://registry.npmmirror.com; \
npm config set registry https://registry.npmmirror.com; \
fi
RUN apk add --update python3 make g++ curl
RUN npm install -g eslint
RUN npm install -g @nestjs/cli
WORKDIR /app
COPY package.json .
COPY package-lock.json .
RUN npm install
COPY . .
RUN npm ci --prod
RUN npx nest build
FROM node:20-alpine
WORKDIR /app
COPY --from=builder /app/package.json /app/package.json
COPY --from=builder /app/dist /app/dist
COPY --from=builder /app/node_modules /app/node_modules
USER node
EXPOSE 8080
ENTRYPOINT ["npm", "run", "start:prod"]