ci: 预构建 runner 镜像并预装 Playwright 依赖
This commit is contained in:
1 parent
965dd10219
commit
b43b6f2785
5 files changed
+57
-4
No files matched your search
+21
-1
@@ -18,6 +18,7 @@ RUNNER_NAME=elitebook-local \
|
||||
RUNNER_LABELS=ubuntu-latest,local-x64 \
|
||||
RUNNER_CAPACITY=2 \
|
||||
RUNNER_CONTAINER_OPTIONS='--cpus=4 --memory=8g' \
|
||||
RUNNER_IMAGE=personal-brand-ci:node24 \
|
||||
SKIP_LINGER=1 \
|
||||
./install-runner.sh
|
||||
```
|
||||
@@ -28,11 +29,30 @@ SKIP_LINGER=1 \
|
||||
|
||||
1. 按架构下载 `gitea-runner-<version>-linux-<arch>`,校验 `.sha256` 后解压到 `~/gitea-runner`。
|
||||
2. 用 `--no-interactive` 注册,写出 `.runner`(已存在则跳过,可重复执行)。
|
||||
3. 生成 `config.yaml`:按 `RUNNER_CAPACITY` 设置并发,使用 `docker://node:24-bookworm` 标签,内置 cache server 监听 `172.17.0.1:8193`,并按 `RUNNER_CONTAINER_OPTIONS` 限制任务容器资源。
|
||||
3. 生成 `config.yaml`:按 `RUNNER_CAPACITY` 设置并发,使用 `RUNNER_IMAGE`(默认 `node:24-bookworm`)作为任务容器镜像,内置 cache server 监听 `172.17.0.1:8193`,并按 `RUNNER_CONTAINER_OPTIONS` 限制任务容器资源。
|
||||
4. 为下载的 runner 二进制补上可执行权限,避免归档解压后出现 `Permission denied`。
|
||||
5. 装 systemd user unit `gitea-runner.service`,执行 `loginctl enable-linger` 后 `enable --now`。
|
||||
6. 放行任务容器到 cache 端口的 ufw 规则。
|
||||
|
||||
## 专用 CI 镜像
|
||||
|
||||
`browser-smoke` 需要 Chromium 及其系统库。为避免每个 job 重复执行 `playwright install --with-deps`,本机使用预构建镜像:
|
||||
|
||||
```bash
|
||||
docker build -f deploy/runner/Dockerfile -t personal-brand-ci:node24 .
|
||||
```
|
||||
|
||||
镜像包含 Node 24、pnpm 9.15.0、git/curl/jq/unzip,以及 Playwright 1.58.2 的 Chromium、headless shell、FFmpeg 和系统依赖。构建产物是本机 amd64 镜像(约 3 GB),不推送到 registry。
|
||||
|
||||
`apps/taro/package.json` 升级 Playwright 后,同步修改 `deploy/runner/Dockerfile` 的 `PLAYWRIGHT_VERSION`,重建镜像并重启 runner:
|
||||
|
||||
```bash
|
||||
docker build -f deploy/runner/Dockerfile -t personal-brand-ci:node24 .
|
||||
systemctl --user restart gitea-runner.service
|
||||
```
|
||||
|
||||
镜像只在当前主机存在;换 runner 主机时需要重新构建。若在 ARM 主机构建,镜像会按该主机架构原生构建,不需要额外参数。
|
||||
|
||||
## 为什么 ufw 要放行三个网段
|
||||
|
||||
任务容器访问宿主机的 cache server 走 Docker bridge,`ufw` 默认 `INPUT DROP` 会直接丢包。Gitea Actions 每个 job 会新建独立 bridge(实测 `192.168.x`),默认 `docker0` 又是 `172.17.x`,所以需要 `172.16.0.0/12`、`192.168.0.0/16`、`10.0.0.0/8` 三条规则。只放行其中一条的后果是缓存恢复/保存各空等数分钟并最终超时。
|
||||
|
||||
Reference in new issue
Block a user