Spaces:
Runtime error
Runtime error
File size: 776 Bytes
159b89e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | # 第一阶段:构建
FROM node:18-alpine AS builder
WORKDIR /app
# 安装 pnpm
RUN npm install -g pnpm
COPY package.json pnpm-lock.yaml ./
# 安装依赖
RUN pnpm install --frozen-lockfile
COPY . .
# 构建 H5
RUN pnpm run build:h5
# 第二阶段:运行
FROM nginx:alpine
# 复制构建产物到 Nginx 目录
COPY --from=builder /app/dist /usr/share/nginx/html
# 暴露端口 (Hugging Face Spaces 需要 7860)
EXPOSE 7860
# 替换 Nginx 默认端口 80 为 7860,并修改 root 目录
RUN sed -i 's/listen 80;/listen 7860;/' /etc/nginx/conf.d/default.conf && \
sed -i 's/root \/usr\/share\/nginx\/html;/root \/usr\/share\/nginx\/html; try_files $uri $uri\/ \/index.html;/' /etc/nginx/conf.d/default.conf
CMD ["nginx", "-g", "daemon off;"]
|