# 使用官方 Node.js 运行时作为基础镜像 FROM node:18-alpine # 安装 nginx 和 curl RUN apk add --no-cache nginx curl # 设置工作目录 WORKDIR /app # 复制 package.json 和相关配置文件 COPY package*.json ./ COPY vite.config.js ./ COPY index.html ./ COPY postcss.config.js ./ COPY tailwind.config.js ./ # 复制源代码目录 COPY src/ ./src/ # 安装前端依赖 RUN npm install # 构建前端应用 RUN npm run build # 创建非 root 用户 RUN addgroup -g 1001 -S nodejs && \ adduser -S nextjs -u 1001 # 设置用户权限 USER nextjs # 暴露 Hugging Face Spaces 要求的端口 EXPOSE 7860 # 设置启动命令 CMD ["sh", "start.sh"]