From 3e32238a1ee4822ecb3e58a2c4f6371826eb2a28 Mon Sep 17 00:00:00 2001 From: yeuimu <2197651308@qq.com> Date: Thu, 23 Jul 2026 08:18:56 +0000 Subject: [PATCH] ci: work pool + Gitee pull deployment (Dockerfile, prefect.yaml) --- Dockerfile | 15 +++++++++ docker-compose.yml | 9 ++++++ prefect.yaml | 78 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 Dockerfile create mode 100644 prefect.yaml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c5e61fa --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM python:3.12-slim + +RUN apt-get update && apt-get install -y --no-install-recommends git curl ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +RUN curl -LsSf https://astral.sh/uv/install.sh | sh +ENV PATH="/root/.local/bin:$PATH" + +WORKDIR /opt/app +COPY pyproject.toml uv.lock ./ +RUN uv sync --frozen --no-install-project + +ENV PATH="/opt/app/.venv/bin:$PATH" + +CMD ["prefect", "worker", "start", "-p", "inkreach-pool", "--type", "process"] diff --git a/docker-compose.yml b/docker-compose.yml index 2fe0b24..b3c813d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,5 +11,14 @@ services: - prefect-data:/root/.prefect restart: unless-stopped + prefect-worker: + build: . + container_name: prefect-worker + environment: + PREFECT_API_URL: http://prefect-server:4200/api + depends_on: + - prefect-server + restart: unless-stopped + volumes: prefect-data: diff --git a/prefect.yaml b/prefect.yaml new file mode 100644 index 0000000..acf4d7c --- /dev/null +++ b/prefect.yaml @@ -0,0 +1,78 @@ +prefect-version: 3.7.8 +name: inkreach-prefect + +# 每次 flow run 前:从 Gitee clone 最新代码(token 运行时从 Secret 解析,不落盘) +pull: +- prefect.deployments.steps.git_clone: + repository: "https://oauth2:{{ prefect.blocks.secret.gitee-token }}@gitee.com/inkreachZLL/inkreach-prefect.git" + branch: master + +defaults: + work_pool: + name: inkreach-pool + +deployments: +# ---------- RIIN ---------- +- name: riin-order-sync + entrypoint: flows/riin/order_sync.py:riin_order_sync + +- name: riin-incremental-sync + entrypoint: flows/riin/incremental_sync.py:riin_incremental_sync + schedules: + - cron: "0 * * * *" + timezone: "Asia/Shanghai" + +- name: riin-recent-sync + entrypoint: flows/riin/recent_sync.py:riin_recent_sync + schedules: + - cron: "30 * * * *" + timezone: "Asia/Shanghai" + +- name: riin-refresh-pending + entrypoint: flows/riin/refresh_pending.py:riin_refresh_pending + schedules: + - cron: "0 */3 * * *" + timezone: "Asia/Shanghai" + +- name: riin-by-orders-sync + entrypoint: flows/riin/by_orders.py:riin_by_orders_sync + +- name: riin-verify + entrypoint: flows/riin/verify.py:riin_verify + schedules: + - cron: "0 6 * * *" + timezone: "Asia/Shanghai" + +# ---------- SDS ---------- +- name: sds-order-sync + entrypoint: flows/sds/order_sync.py:sds_order_sync + +- name: sds-incremental-sync + entrypoint: flows/sds/incremental_sync.py:sds_incremental_sync + schedules: + - cron: "15 * * * *" + timezone: "Asia/Shanghai" + +- name: sds-recent-sync + entrypoint: flows/sds/recent_sync.py:sds_recent_sync + schedules: + - cron: "45 * * * *" + timezone: "Asia/Shanghai" + +- name: sds-refresh-pending + entrypoint: flows/sds/refresh_pending.py:sds_refresh_pending + schedules: + - cron: "0 */2 * * *" + timezone: "Asia/Shanghai" + +- name: sds-refresh-100-prefix + entrypoint: flows/sds/refresh_100_prefix.py:sds_refresh_100_prefix + schedules: + - cron: "30 */2 * * *" + timezone: "Asia/Shanghai" + +- name: sds-verify + entrypoint: flows/sds/verify.py:sds_verify + schedules: + - cron: "0 7 * * *" + timezone: "Asia/Shanghai"