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.

42 lines
934 B
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 . .
# 执行生产构建和你本地的build:prod命令一致
RUN pnpm run build:prod
# 阶段2: 生产运行阶段
FROM node:24.7.0-slim
WORKDIR /app
# 【合并3】设置npm镜像源 + 全局安装pnpm + 设置pnpm镜像源
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"]