This commit is contained in:
cheney
2025-07-21 22:37:18 +08:00
parent 6ff6c0e8b0
commit 59815d685f
4 changed files with 50 additions and 3 deletions
+27 -3
View File
@@ -1,4 +1,28 @@
FROM ubuntu:latest
LABEL authors="Cheney"
# 使用 Python 3.13 的基础镜像(注意:3.13可能尚未正式发布,这里使用可能的最新开发版本)
FROM python:3.13-rc-slim
ENTRYPOINT ["top", "-b"]
# 安装必要的软件包
RUN apt-get update && \
apt-get install -y --no-install-recommends cron && \
rm -rf /var/lib/apt/lists/*
# 设置工作目录
WORKDIR /app
# 复制Python脚本和其他必要文件
COPY *.py /app/
COPY cronjob /etc/cron.d/cronjob
# 设置cron作业文件权限
RUN chmod 0644 /etc/cron.d/cronjob && \
crontab /etc/cron.d/cronjob
# 安装Python依赖(如果有)
COPY ./requirements.txt /app/requirements.txt
RUN pip install -r requirements.txt
# 创建日志文件(用于cron输出)
RUN touch /var/log/cron.log
# 保持容器运行的命令
CMD tail -f /var/log/cron.log