Files
aiot-platform-ui/Dockerfile

43 lines
1.2 KiB
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
# 设置 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;"]