Spaces:
Runtime error
Runtime error
Download Dockerfile from lydgs/FreeLLMAPI: direct link, hf CLI and curl.
- Browser
- Download file 1.71 kB
-
https://huggingface.co/spaces/lydgs/FreeLLMAPI/resolve/052d080977555cc5e1281e8950690ca1162e105e/Dockerfile
- Command line
-
hf download hf://spaces/lydgs/FreeLLMAPI@052d080977555cc5e1281e8950690ca1162e105e/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/lydgs/FreeLLMAPI/resolve/052d080977555cc5e1281e8950690ca1162e105e/Dockerfile
1.71 kB
| # ========== 第一阶段:构建 ========== | |
| FROM node:20-slim AS builder | |
| WORKDIR /app | |
| RUN apt-get update && apt-get install -y git python3 make g++ && rm -rf /var/lib/apt/lists/* | |
| RUN git clone https://github.com/tashfeenahmed/freellmapi.git . | |
| RUN npm config set registry https://registry.npmmirror.com && npm install | |
| RUN npm run build | |
| # ========== 第二阶段:运行 ========== | |
| FROM node:20-slim AS runner | |
| WORKDIR /app | |
| # 安装运行时依赖:cron, supervisor, python3, pip | |
| RUN apt-get update && apt-get install -y \ | |
| cron \ | |
| supervisor \ | |
| python3 \ | |
| python3-pip \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # 安装 huggingface-hub(用于上传到数据集) | |
| RUN pip3 install huggingface-hub --break-system-packages || pip3 install huggingface-hub | |
| COPY --from=builder /app ./ | |
| RUN mkdir -p /data/freellm | |
| RUN cp -r client/dist/* server/dist/public/ 2>/dev/null || cp -r client/dist/* server/public/ 2>/dev/null || true | |
| EXPOSE 7860 | |
| ENV PORT=7860 | |
| ENV NODE_ENV=production | |
| ENV DATABASE_URL="file:/data/database.sqlite" | |
| # 创建备份脚本目录 | |
| RUN mkdir -p /app/scripts /var/log/backup | |
| # 复制备份脚本 | |
| COPY scripts/backup_to_dataset.py /app/scripts/backup_to_dataset.py | |
| RUN chmod +x /app/scripts/backup_to_dataset.py | |
| # 配置 cron 任务:每天凌晨3点执行备份(UTC时间) | |
| RUN echo "0 3 * * * root /usr/bin/python3 /app/scripts/backup_to_dataset.py >> /var/log/backup/cron.log 2>&1" > /etc/cron.d/backup-job && \ | |
| chmod 0644 /etc/cron.d/backup-job | |
| # 复制 supervisord 配置 | |
| COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf | |
| # 启动 supervisord(同时管理 node 应用和 cron) | |
| CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] |