FROM node:18-alpine AS builder

WORKDIR /app
COPY package*.json ./

# 设置淘宝镜像源并安装
RUN npm config set registry https://registry.npmmirror.com && \
    npm ci --prefer-offline

COPY . .
RUN npm run build:h5

# 使用Nginx作为运行环境
FROM nginx:alpine

# 复制打包结果到Nginx默认目录
COPY --from=builder /app/dist/build/h5 /usr/share/nginx/html

# 配置Nginx
COPY nginx.conf /etc/nginx/conf.d/default.conf

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