-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathDockerfile.dev
executable file
·53 lines (32 loc) · 996 Bytes
/
Dockerfile.dev
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
FROM node:18 AS development
#指定工作目录
WORKDIR /usr/src/app
#复制package.json和pnpm-lock.yaml 到工作目录 这里单独复制是为了利用缓存
COPY package.json ./
COPY pnpm-lock.yaml ./
COPY prisma ./prisma
RUN npm config set registry https://registry.npmmirror.com/
RUN npm install -g pnpm
RUN pnpm install
RUN pnpx prisma generate
COPY . .
#设置默认环境变量
ARG APP_ENV=development
#暴露环境变量
ENV NODE_ENV=${APP_ENV}
RUN pnpm build
FROM node:18 AS production
ARG APP_ENV=development
ENV NODE_ENV=${APP_ENV}
#指定工作目录
WORKDIR /usr/src/app
RUN npm install -g pnpm
COPY --from=development /usr/src/app/package.json ./
COPY --from=development /usr/src/app/pnpm-lock.yaml ./
COPY --from=development /usr/src/app/dist ./dist
COPY --from=development /usr/src/app/prisma ./prisma
RUN npm config set registry https://registry.npmmirror.com/
RUN pnpm install --production
RUN pnpx prisma generate
EXPOSE 3000
CMD ["node", "dist/main"]