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.

21 lines
475 B
Docker

# 构建阶段
FROM node:20-alpine AS builder
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN npm install -g pnpm
RUN pnpm install
COPY . .
RUN pnpm run build:prod # 生成 dist-prod 目录
# 运行阶段
FROM nginx:alpine
# 关键:复制的是 dist-prod 而不是 dist
COPY --from=builder /app/dist-prod /usr/share/nginx/html
# 复制 Nginx 配置(确保这个文件存在)
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]