Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +13 -11
Dockerfile
CHANGED
|
@@ -18,31 +18,33 @@ RUN apt-get update && apt-get install -y \
|
|
| 18 |
python3-pip \
|
| 19 |
&& rm -rf /var/lib/apt/lists/*
|
| 20 |
|
| 21 |
-
# 安装 huggingface-hub
|
| 22 |
RUN pip3 install huggingface-hub --break-system-packages || pip3 install huggingface-hub
|
| 23 |
|
| 24 |
COPY --from=builder /app ./
|
| 25 |
-
RUN mkdir -p /data/
|
| 26 |
RUN cp -r client/dist/* server/dist/public/ 2>/dev/null || cp -r client/dist/* server/public/ 2>/dev/null || true
|
| 27 |
|
| 28 |
EXPOSE 7860
|
| 29 |
ENV PORT=7860
|
| 30 |
ENV NODE_ENV=production
|
| 31 |
-
ENV DATABASE_URL=file:/data/freeapi.db
|
| 32 |
|
| 33 |
-
#
|
| 34 |
-
RUN mkdir -p /app/scripts /var/log/backup
|
| 35 |
-
|
| 36 |
-
# 复制备份脚本
|
| 37 |
COPY scripts/backup_to_dataset.py /app/scripts/backup_to_dataset.py
|
| 38 |
-
|
|
|
|
| 39 |
|
| 40 |
-
# 配置 cron 任务:每天凌晨3点执行备份
|
| 41 |
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 && \
|
| 42 |
chmod 0644 /etc/cron.d/backup-job
|
| 43 |
|
| 44 |
# 复制 supervisord 配置
|
| 45 |
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
| 46 |
|
| 47 |
-
# 启动
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
python3-pip \
|
| 19 |
&& rm -rf /var/lib/apt/lists/*
|
| 20 |
|
| 21 |
+
# 安装 huggingface-hub
|
| 22 |
RUN pip3 install huggingface-hub --break-system-packages || pip3 install huggingface-hub
|
| 23 |
|
| 24 |
COPY --from=builder /app ./
|
| 25 |
+
RUN mkdir -p /data /app/scripts /var/log/backup
|
| 26 |
RUN cp -r client/dist/* server/dist/public/ 2>/dev/null || cp -r client/dist/* server/public/ 2>/dev/null || true
|
| 27 |
|
| 28 |
EXPOSE 7860
|
| 29 |
ENV PORT=7860
|
| 30 |
ENV NODE_ENV=production
|
| 31 |
+
ENV DATABASE_URL="file:/data/freeapi.db" # 指向持久化目录(虽然免费无持久化,但统一用/data)
|
| 32 |
|
| 33 |
+
# 复制备份和恢复脚本
|
|
|
|
|
|
|
|
|
|
| 34 |
COPY scripts/backup_to_dataset.py /app/scripts/backup_to_dataset.py
|
| 35 |
+
COPY scripts/restore_from_dataset.py /app/scripts/restore_from_dataset.py
|
| 36 |
+
RUN chmod +x /app/scripts/*.py
|
| 37 |
|
| 38 |
+
# 配置 cron 任务:每天凌晨3点执行备份
|
| 39 |
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 && \
|
| 40 |
chmod 0644 /etc/cron.d/backup-job
|
| 41 |
|
| 42 |
# 复制 supervisord 配置
|
| 43 |
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
| 44 |
|
| 45 |
+
# 复制启动脚本
|
| 46 |
+
COPY start.sh /start.sh
|
| 47 |
+
RUN chmod +x /start.sh
|
| 48 |
+
|
| 49 |
+
# 使用启动脚本作为入口点
|
| 50 |
+
CMD ["/start.sh"]
|