From 60e18ded88bcea83544a1116f1e013254c4ff4ea Mon Sep 17 00:00:00 2001 From: lzy Date: Thu, 23 Jul 2026 23:03:06 +0800 Subject: [PATCH] =?UTF-8?q?fix(docker):=20=E4=BF=AE=E5=A4=8D=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=20Gitea+act=5Frunner=20=E9=85=8D=E7=BD=AE=E4=BD=BF=20?= =?UTF-8?q?CI=20=E5=8F=AF=E8=B7=91=E9=80=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 端口 3000→3001(避开 Astro dev server 占用) - gitea 加 INSTALL_LOCK=true 跳过首装页 + ROOT_URL=http://localhost:3001/ - registration token 两端同步并满足 Gitea ≥32 字符强度要求 - runner 加 GITEA_RUNNER_LABELS 走 docker 模式(node:20-bookworm) - docker.sock 保持单斜杠(Docker Desktop 实测可用,双斜杠为伪需求) 端到端验证通过:Gitea 1.27 + act_runner v0.6.1,标准 node 镜像 job 经 docker.sock spawn 容器执行成功。需配合 Docker registry mirror(国内)拉取业务镜像。 --- docker/gitea.docker-compose.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/docker/gitea.docker-compose.yml b/docker/gitea.docker-compose.yml index 46860fd..6a99b50 100644 --- a/docker/gitea.docker-compose.yml +++ b/docker/gitea.docker-compose.yml @@ -1,17 +1,24 @@ # 本地 Phase 0 验证用 Gitea + act_runner # 用法:cd docker && docker compose -f gitea.docker-compose.yml up -d -# 注意 Windows Docker Desktop:act_runner 挂 docker.sock 可能需改为 -# - //var/run/docker.sock:/var/run/docker.sock (双斜杠) +# 说明: +# - Gitea Web: http://localhost:3001 (宿主 3001,避开 Astro dev 占用的 3000) +# - docker.sock 用单斜杠即可:compose 文件内 YAML 值不经 shell, +# Docker Desktop for Windows 下实测可正常访问宿主 daemon(已验证) +# - GITEA_RUNNER_REGISTRATION_TOKEN 在 gitea 与 runner 两端设相同值: +# gitea 启动时将其作为全局 registration token,runner 用它完成注册 services: gitea: image: gitea/gitea:1 environment: - USER_UID=1000 - USER_GID=1000 + - GITEA__security__INSTALL_LOCK=true # 跳过首装页面,以默认 SQLite 配置启动 + - GITEA__server__ROOT_URL=http://localhost:3001/ # 对外访问地址(宿主端口) + - GITEA_RUNNER_REGISTRATION_TOKEN=phase0-local-actions-runner-token-0123456789abcdef0123456789 # 全局 registration token,与 runner 端一致 volumes: - ./gitea-data:/data ports: - - "3000:3000" # Web + - "3001:3000" # Web(宿主 3001,避开 Astro dev 占用的 3000) - "2222:22" # SSH restart: unless-stopped @@ -19,7 +26,8 @@ services: image: gitea/act_runner:latest environment: - GITEA_INSTANCE_URL=http://gitea:3000 - - GITEA_RUNNER_REGISTRATION_TOKEN=phase0-local-token + - GITEA_RUNNER_REGISTRATION_TOKEN=phase0-local-actions-runner-token-0123456789abcdef0123456789 + - GITEA_RUNNER_LABELS=ubuntu-latest:docker://node:20-bookworm,ubuntu-24.04:docker://node:20-bookworm,ubuntu-22.04:docker://node:20-bookworm volumes: - ./runner-data:/data - /var/run/docker.sock:/var/run/docker.sock