Files
ogame-vue-ts/Dockerfile
coolxitech 533c36b962 build(docker): 优化 Docker 构建流程
- 调整 pnpm 安装方式以提高构建稳定性
- 修改依赖安装顺序以更好利用缓存
- 更新注释内容以准确反映构建步骤
- 移除冗余指令以简化 Dockerfile 结构
2025-12-13 10:33:11 +08:00

33 lines
724 B
Docker
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ========= 阶段1构建 =========
FROM node:20-alpine AS builder
WORKDIR /app
# 使用国内镜像加速(可选但强烈建议)
RUN npm config set registry https://registry.npmmirror.com
# 直接用 npm 全局安装 pnpm最稳最快
RUN npm install -g pnpm
# 复制依赖文件先缓存
COPY package.json pnpm-lock.yaml ./
# 安装依赖
RUN pnpm install --frozen-lockfile
# 复制源码并构建
COPY . .
RUN pnpm run build
# ========= 阶段2运行时 =========
FROM nginx:alpine
# 复制构建产物
COPY --from=builder /app/dist /usr/share/nginx/html
# 解决 Vue Router history 模式 404 问题
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]