Files
2026-09-28 11:56:22 +08:00

50 lines
1.6 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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 必须能访问上面指定的镜像。