save
This commit is contained in:
parent
6ff6c0e8b0
commit
59815d685f
20
.gitea/workflows/docker-build.yml
Normal file
20
.gitea/workflows/docker-build.yml
Normal file
@ -0,0 +1,20 @@
|
||||
name: Build and Push Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main # 只在 main 分支推送时触发
|
||||
tags:
|
||||
- v* # 推送 v* 标签时也触发(如 v1.0.0)
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Build and Push Docker Image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
30
Dockerfile
30
Dockerfile
@ -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
|
||||
2
cronjob
Normal file
2
cronjob
Normal file
@ -0,0 +1,2 @@
|
||||
# 设置每天 14:45 执行
|
||||
45 14 * * * root /usr/local/bin/python /app/main.py >> /var/log/cron.log 2>&1
|
||||
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
||||
akshare
|
||||
Loading…
Reference in New Issue
Block a user