You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.2 KiB
Docker

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# 阶段1: 构建阶段
FROM node:24.7.0-slim AS builder
WORKDIR /app
RUN npm config set registry https://registry.npmmirror.com \
&& npm install -g pnpm \
&& pnpm config set registry https://registry.npmmirror.com
# 复制依赖文件
COPY package.json pnpm-lock.yaml ./
# 【合并2】强制安装依赖
RUN pnpm install --force \
&& pnpm add -D @unocss/eslint-plugin
COPY . .
# 【新增1】创建缺失的cancel.svg文件解决文件不存在错误
RUN mkdir -p /app/src/assets/svgs/bpm/ \
&& echo '<svg xmlns="http://www.w3.org/2000/svg" width="0" height="0"></svg>' > /app/src/assets/svgs/bpm/cancel.svg
# 【新增2】执行ESLint自动修复修复vue/no-ref-as-operand错误
RUN pnpm eslint --fix /app/src/components/Table/src/Table.vue \
# 可选修复整个项目的ESLint错误
# && pnpm eslint --fix /app/src/
&& rm -rf /tmp/*
# 执行生产构建
RUN pnpm run build:prod
# 阶段2: 生产运行阶段
FROM node:24.7.0-slim
WORKDIR /app
RUN npm config set registry https://registry.npmmirror.com \
&& npm install -g pnpm \
&& pnpm config set registry https://registry.npmmirror.com
COPY --from=builder /app .
ENV PORT 8088
ENV NODE_ENV production
EXPOSE 8088
CMD ["pnpm", "start"]