From e737abf0a077d573b031a7185e5f53214831b740 Mon Sep 17 00:00:00 2001 From: Timi Date: Mon, 28 Sep 2026 11:56:22 +0800 Subject: [PATCH] add gitea_runner_python --- README.md | 16 +++++++++++ gitea_runner_python/Dockerfile | 26 ++++++++++++++++++ gitea_runner_python/README.md | 49 ++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 gitea_runner_python/Dockerfile create mode 100644 gitea_runner_python/README.md diff --git a/README.md b/README.md index f1eb119..645508d 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,21 @@ env: JAVA_HOME: /usr/lib/jvm/java-1.8-openjdk ``` +### gitea_runner_python + +基于 `gitea_runner_base` 的 Python 开发镜像,包含: + +- Python 3、pip 和 virtualenv +- Python 原生扩展常用编译工具(C/C++、Rust、OpenSSL、libffi) +- 基础镜像中的 Node.js、Git、Bash、SSH 和 `sshpass` + +Python 版本由基础镜像对应的 Alpine 仓库提供。job 容器直接使用镜像内的 Python,不需要 `actions/setup-python`。 + +```bash +./rebuild.sh gitea_runner_base latest +./rebuild.sh gitea_runner_python latest +``` + ### gitea_runner_electron 基于 `electronuserland/builder:wine` 的 Electron 三平台打包镜像,包含: @@ -87,6 +102,7 @@ docker build -t gitea_runner_base ./gitea_runner_base # 2. 再构建语言环境镜像 docker build -t gitea_runner_node ./gitea_runner_node docker build -t gitea_runner_java ./gitea_runner_java +docker build -t gitea_runner_python ./gitea_runner_python # 3. Electron 镜像基于官方 Wine 镜像,可独立构建 docker build -t gitea_runner_electron ./gitea_runner_electron diff --git a/gitea_runner_python/Dockerfile b/gitea_runner_python/Dockerfile new file mode 100644 index 0000000..cd848ec --- /dev/null +++ b/gitea_runner_python/Dockerfile @@ -0,0 +1,26 @@ +# Gitea Action Runner Python Image +# 基于 gitea_runner_base 添加 Python 开发环境 + +FROM timi/gitea_runner_base:latest + +LABEL maintainer="www.imyeyu.com" +LABEL description="Gitea Action Runner with Python 3 and native build tools" + +ENV PYTHONUNBUFFERED=1 \ + PIP_DISABLE_PIP_VERSION_CHECK=1 + +# Alpine 的 Python 版本随基础镜像仓库更新;virtualenv 用于隔离项目依赖。 +RUN apk add --no-cache \ + python3 \ + py3-pip \ + py3-virtualenv \ + python3-dev \ + build-base \ + cargo \ + libffi-dev \ + openssl-dev \ + && ln -sf /usr/bin/python3 /usr/local/bin/python \ + && ln -sf /usr/bin/pip3 /usr/local/bin/pip \ + && python --version \ + && python -m pip --version \ + && virtualenv --version diff --git a/gitea_runner_python/README.md b/gitea_runner_python/README.md new file mode 100644 index 0000000..83231a1 --- /dev/null +++ b/gitea_runner_python/README.md @@ -0,0 +1,49 @@ +# Gitea Runner Python + +基于 `timi/gitea_runner_base` 的通用 Python job 镜像,适用于 Gitea Actions。 + +## 包含环境 + +| 类别 | 工具 | +|------|------| +| Python | `python3`、`pip3`、`virtualenv`;提供 `python` 和 `pip` 命令别名 | +| 原生扩展构建 | `python3-dev`、`build-base`、`cargo`、`libffi-dev`、`openssl-dev` | +| Gitea Actions | 继承基础镜像中的 Node.js、Git、Bash、SSH、`sshpass`、Docker CLI 等工具 | + +Python 版本由基础镜像所使用的 Alpine 仓库提供。这个镜像直接预装 Python,因此不要在 Alpine job 容器中再运行 `actions/setup-python`;该 Action 的预编译版本列表不包含 Alpine。使用镜像内的 `python` 即可。 + +## 构建 + +先构建基础镜像,再构建 Python 镜像: + +```bash +./rebuild.sh gitea_runner_base latest +./rebuild.sh gitea_runner_python latest +``` + +如果 Gitea Runner 在另一台机器上运行,需要先把 `timi/gitea_runner_python:latest` 推送到该机器可访问的镜像仓库,或加载到 Runner 使用的 Docker daemon。 + +## Gitea Actions 用法 + +```yaml +jobs: + build: + runs-on: act_runner_java + container: + image: timi/gitea_runner_python:latest + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v4 + + - name: Install dependencies + run: | + virtualenv .venv + .venv/bin/python -m pip install -e ".[dev]" + + - name: Run tests + run: .venv/bin/python -m pytest +``` + +`runs-on` 仍选择可用的 Gitea Runner;`container.image` 选择 job 执行环境。Runner 的 Docker daemon 必须能访问上面指定的镜像。