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.

45 lines
1.1 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 ./
RUN pnpm install --force \
&& pnpm add -D @unocss/eslint-plugin@0.57.7
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
RUN pnpm eslint --fix /app/src/components/Table/src/Table.vue \
&& rm -rf /tmp/*
RUN ESLINT_NO_DEV_ERRORS=true pnpm run build:prod
RUN ls -la /app/
# 阶段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", "vite", "preview", "--port", "8088", "--outDir", "dist-prod"]