ci: 预构建 runner 镜像并预装 Playwright 依赖
This commit is contained in:
1 parent
965dd10219
commit
b43b6f2785
5 files changed
+57
-4
No files matched your search
@@ -0,0 +1,25 @@
|
||||
# 本地 CI 任务容器基础镜像:Node 24 + pnpm + Playwright 运行依赖。
|
||||
# 构建(在仓库根目录执行):
|
||||
# docker build -f deploy/runner/Dockerfile -t personal-brand-ci:node24 .
|
||||
# Playwright 版本需与 apps/taro/package.json 保持一致;升级 Playwright 后重建本镜像。
|
||||
FROM node:24-bookworm
|
||||
|
||||
ARG PNPM_VERSION=9.15.0
|
||||
ARG PLAYWRIGHT_VERSION=1.58.2
|
||||
|
||||
ENV PNPM_HOME=/usr/local/share/pnpm
|
||||
ENV PATH=${PNPM_HOME}:${PATH}
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends jq unzip \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN corepack enable \
|
||||
&& corepack prepare pnpm@${PNPM_VERSION} --activate \
|
||||
&& pnpm --version
|
||||
|
||||
# 预装 Chromium 的系统依赖和浏览器本体,避免每个 job 重复执行 apt 与下载。
|
||||
RUN npx --yes playwright@${PLAYWRIGHT_VERSION} install --with-deps chromium \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /workspace
|
||||
@@ -15,6 +15,7 @@
|
||||
# RUNNER_ROOT 默认 $HOME/gitea-runner
|
||||
# RUNNER_CAPACITY 默认 1,按 runner 主机资源设置并发数
|
||||
# RUNNER_CONTAINER_OPTIONS 默认 "--cpus=1.5 --memory=4g"
|
||||
# RUNNER_IMAGE 任务容器镜像,默认 node:24-bookworm;本地预构建镜像可传 personal-brand-ci:node24
|
||||
# CACHE_PORT 默认 8193
|
||||
# RUNNER_CACHE_HOST 默认 172.17.0.1(Docker 默认 bridge 网关)
|
||||
# SKIP_LINGER 默认 0;设为 1 时不尝试用 sudo 开启 linger
|
||||
@@ -28,6 +29,7 @@ RUNNER_VERSION=${RUNNER_VERSION:-5.2.0}
|
||||
RUNNER_ROOT=${RUNNER_ROOT:-$HOME/gitea-runner}
|
||||
RUNNER_CAPACITY=${RUNNER_CAPACITY:-1}
|
||||
RUNNER_CONTAINER_OPTIONS=${RUNNER_CONTAINER_OPTIONS:-"--cpus=1.5 --memory=4g"}
|
||||
RUNNER_IMAGE=${RUNNER_IMAGE:-node:24-bookworm}
|
||||
CACHE_PORT=${CACHE_PORT:-8193}
|
||||
RUNNER_CACHE_HOST=${RUNNER_CACHE_HOST:-172.17.0.1}
|
||||
CACHE_DIR=${CACHE_DIR:-$RUNNER_ROOT/cache-data}
|
||||
@@ -66,13 +68,17 @@ fi
|
||||
run chmod +x "$RUNNER_ROOT/gitea-runner-${RUNNER_VERSION}-linux-${ARCH}"
|
||||
run ln -sf "gitea-runner-${RUNNER_VERSION}-linux-${ARCH}" "$RUNNER_ROOT/gitea-runner"
|
||||
|
||||
label_specs() {
|
||||
printf '%s\n' "$RUNNER_LABELS" | tr ',' '\n' | sed "s|^\(.*\)$|\1:docker://${RUNNER_IMAGE}|"
|
||||
}
|
||||
|
||||
if [ ! -f "$RUNNER_ROOT/.runner" ]; then
|
||||
run env -C "$RUNNER_ROOT" ./gitea-runner register \
|
||||
--no-interactive \
|
||||
--instance "$GITEA_URL" \
|
||||
--token "$RUNNER_TOKEN" \
|
||||
--name "$RUNNER_NAME" \
|
||||
--labels "$RUNNER_LABELS"
|
||||
--labels "$(label_specs | paste -sd, -)"
|
||||
fi
|
||||
if [ -f "$RUNNER_ROOT/.runner" ]; then
|
||||
run chmod 600 "$RUNNER_ROOT/.runner"
|
||||
@@ -88,7 +94,7 @@ runner:
|
||||
fetch_timeout: 10s
|
||||
fetch_interval: 2s
|
||||
labels:
|
||||
$(printf '%s\n' "$RUNNER_LABELS" | tr ',' '\n' | sed 's|^\(.*\)$| - "\1:docker://node:24-bookworm"|')
|
||||
$(label_specs | sed 's|^| - "|; s|$|"|')
|
||||
cache:
|
||||
enabled: true
|
||||
dir: ${CACHE_DIR}
|
||||
|
||||
Reference in new issue
Block a user