taro-miniprogram / Dockerfile
Trae Assistant
Clean project init
159b89e
raw
history blame contribute delete
776 Bytes
# 第一阶段:构建
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;"]