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