From 60b33a9431c5c9189032331ce8d2b299373838a3 Mon Sep 17 00:00:00 2001 From: "sipc.ink" <92251518+SIPC@users.noreply.github.com> Date: Sun, 10 Mar 2024 11:47:26 +0800 Subject: [PATCH] Update Dockerfile --- Dockerfile | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index e6e3dc0..64facd0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,24 @@ -FROM node:18-alpine +# 构建阶段 +FROM node:18-alpine AS builder WORKDIR /app +COPY package*.json ./ +RUN npm ci + COPY . . -RUN npm install --production && npm run build +RUN npm run build + +# 生产阶段 +FROM node:18-alpine + +WORKDIR /app + +COPY --from=builder /app/build /app/build +COPY --from=builder /app/node_modules /app/node_modules + +ENV NODE_ENV=production EXPOSE 3000 -CMD [ "npm", "run", "start" ] +CMD ["npm", "start"] \ No newline at end of file