From 501320f6cadc89c2bdd507b1157beb88991088d9 Mon Sep 17 00:00:00 2001 From: winwin2011 Date: Sun, 22 May 2022 19:57:11 +0800 Subject: [PATCH] chore: docker split builder and runner --- Dockerfile | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 155cd19..5177c04 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,19 @@ -FROM node:16-alpine +FROM node:16-alpine as builder WORKDIR /app - COPY . . - RUN npm install -g pnpm - RUN pnpm install --frozen-lockfile - RUN npm run build -EXPOSE 3000 +FROM node:16-alpine as runner +WORKDIR /app +ENV NODE_ENV production +COPY . . +RUN npm install -g pnpm +RUN pnpm install --frozen-lockfile -P +COPY --from=builder /app/dist ./dist + +EXPOSE 3000 CMD ["npm", "start"] \ No newline at end of file