From 2cedd6404d5c6276b168d7605341c7932a21086a Mon Sep 17 00:00:00 2001 From: ngks Date: Fri, 19 Dec 2025 17:06:47 +0800 Subject: [PATCH] =?UTF-8?q?update:'=E4=BF=AE=E6=94=B9dockerfile'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2576e61c..3ad3359d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,19 +2,29 @@ FROM node:20-alpine AS builder WORKDIR /app + +# 复制依赖清单 COPY package.json pnpm-lock.yaml ./ -RUN npm install -g pnpm -RUN pnpm install + +# 设置 npm 和 pnpm 使用国内镜像源(关键!) +RUN npm config set registry https://registry.npmmirror.com && \ + npm install -g pnpm && \ + pnpm config set registry https://registry.npmmirror.com + +# 安装依赖(现在会走淘宝镜像) +RUN pnpm install --frozen-lockfile + +# 复制源码并构建 COPY . . RUN pnpm run build:prod # 生成 dist-prod 目录 # 运行阶段 FROM nginx:alpine -# 关键:复制的是 dist-prod 而不是 dist +# 复制前端产物 COPY --from=builder /app/dist-prod /usr/share/nginx/html -# 复制 Nginx 配置(确保这个文件存在) +# 复制 Nginx 配置 COPY nginx.conf /etc/nginx/nginx.conf EXPOSE 80