mirror of
https://github.com/setube/ogame-vue-ts.git
synced 2026-05-12 07:55:11 +08:00
build(docker): 优化 Docker 构建流程
- 调整 pnpm 安装方式以提高构建稳定性 - 修改依赖安装顺序以更好利用缓存 - 更新注释内容以准确反映构建步骤 - 移除冗余指令以简化 Dockerfile 结构
This commit is contained in:
22
Dockerfile
22
Dockerfile
@@ -1,22 +1,22 @@
|
||||
# ========= 阶段1:构建 =========
|
||||
FROM node:20-alpine AS builder
|
||||
|
||||
# 使用国内镜像加速(可选)
|
||||
RUN npm config set registry https://registry.npmmirror.com
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# 先复制依赖文件,利用缓存
|
||||
COPY package.json pnpm-lock.yaml* ./
|
||||
# 使用国内镜像加速(可选但强烈建议)
|
||||
RUN npm config set registry https://registry.npmmirror.com
|
||||
|
||||
# 安装 pnpm 并安装依赖
|
||||
RUN corepack enable && corepack prepare pnpm@latest --activate \
|
||||
&& pnpm install --frozen-lockfile
|
||||
# 直接用 npm 全局安装 pnpm(最稳,最快)
|
||||
RUN npm install -g pnpm
|
||||
|
||||
# 复制源码
|
||||
# 复制依赖文件先缓存
|
||||
COPY package.json pnpm-lock.yaml ./
|
||||
|
||||
# 安装依赖
|
||||
RUN pnpm install --frozen-lockfile
|
||||
|
||||
# 复制源码并构建
|
||||
COPY . .
|
||||
|
||||
# 生产构建
|
||||
RUN pnpm run build
|
||||
|
||||
# ========= 阶段2:运行时 =========
|
||||
|
||||
Reference in New Issue
Block a user