Spaces:
Runtime error
Runtime error
File size: 1,714 Bytes
57727be 8a59281 57727be 8a59281 57727be 8a59281 57727be 8a59281 57727be 54e065a 57727be 8a59281 57727be 20ebd03 eadc41e b78b330 93381bd 54e065a 57727be | 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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | # ========== 第一阶段:构建 ==========
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"] |