# 构建阶段
FROM node:16-alpine AS builder

WORKDIR /app
COPY package*.json ./
RUN npm install --registry=https://registry.npmmirror.com

COPY . .
RUN npm run build:h5

# 生产运行阶段
FROM nginx:1.21-alpine

# 删除默认配置
RUN rm -rf /etc/nginx/conf.d/default.conf

# 复制自定义Nginx配置
COPY nginx.conf /etc/nginx/conf.d

# 从构建阶段复制产物
COPY --from=builder /app/dist/build/h5 /usr/share/nginx/html

EXPOSE 8333
CMD ["nginx", "-g", "daemon off;"]
