feat: 构建cicd | docke部署 | nginx 配置文件
This commit is contained in:
42
Dockerfile
Normal file
42
Dockerfile
Normal file
@@ -0,0 +1,42 @@
|
||||
|
||||
# 1. 构建阶段
|
||||
FROM node:20-alpine AS builder
|
||||
|
||||
# 设置 npm 镜像源为淘宝源
|
||||
RUN npm config set registry https://registry.npmmirror.com
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# 启用 pnpm (使用 corepack)
|
||||
RUN corepack enable && corepack prepare pnpm@9.12.3 --activate
|
||||
|
||||
# 单独复制依赖描述文件,利用 Docker 缓存层
|
||||
COPY package.json pnpm-lock.yaml turbo.json ./
|
||||
# 注意:你需要复制 workspace 下所有的 package.json,这里简单起见复制整个 packages 目录结构可能比较繁琐
|
||||
# 更推荐的做法是直接 COPY 所有源码,因为 pnpm lock 已经锁定了版本
|
||||
COPY . .
|
||||
|
||||
# 安装依赖 (利用 cache 挂载可以进一步加速,但在 Gitea Runner 中可能需要额外配置,这里暂时不用)
|
||||
RUN pnpm install --frozen-lockfile
|
||||
|
||||
# 构建指定项目 (根据 package.json 里的 scripts)
|
||||
# 这里我们构建 antd 版本
|
||||
RUN pnpm build:antd
|
||||
|
||||
# 2. 运行阶段
|
||||
FROM nginx:alpine
|
||||
|
||||
# 移除默认配置
|
||||
RUN rm /etc/nginx/conf.d/default.conf
|
||||
|
||||
# 复制自定义 Nginx 配置
|
||||
COPY apps/web-antd/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
# 复制构建产物
|
||||
# 注意:Vben 5 的产物目录通常在 apps/web-antd/dist
|
||||
COPY --from=builder /app/apps/web-antd/dist /usr/share/nginx/html
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
|
||||
Reference in New Issue
Block a user