From 163392d9d4221e9c1c6497e0fa907fba2a75346d Mon Sep 17 00:00:00 2001 From: IlhamTahir Date: Sun, 17 Nov 2024 15:46:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=89=93=E5=8C=85=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index ee64bb9..f55c827 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ # Stage 1: Build Stage -FROM node:20 AS builder +FROM node:22 AS builder -# Set npm registry to Tencent Cloud +# Set npm registry to Tencent Cloud and install pnpm globally RUN npm config set registry https://mirrors.cloud.tencent.com/npm/ \ - && npm install -g pnpm@latest + && npm install -g pnpm@latest # Set the working directory inside the container WORKDIR /usr/src/app @@ -21,15 +21,21 @@ COPY . . RUN pnpm run build # Stage 2: Production Stage -FROM node:20-alpine AS production +FROM node:22 AS production + +# Set npm registry to Tencent Cloud and install pnpm globally +RUN npm install -g pnpm@latest # Set the working directory inside the container WORKDIR /usr/src/app -# Copy the build output and dependencies from the build stage +# Copy the build output and production dependencies from the build stage COPY --from=builder /usr/src/app/dist ./dist -COPY --from=builder /usr/src/app/node_modules ./node_modules -COPY --from=builder /usr/src/app/package.json ./package.json +COPY --from=builder /usr/src/app/package.json /usr/src/app/pnpm-lock.yaml ./ + +# Install only production dependencies +RUN pnpm config set registry https://mirrors.cloud.tencent.com/npm/ \ + && pnpm install --prod # Expose the application port EXPOSE 3000