From a7741b9de2e989db52429f9856fdd19796919d22 Mon Sep 17 00:00:00 2001 From: yuming Date: Sat, 4 Jul 2026 14:35:18 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20=E8=A3=85=20Docker=20CLI=20=E6=AD=A5?= =?UTF-8?q?=E9=AA=A4=E5=8A=A0=E8=AF=A6=E7=BB=86=E6=8E=92=E6=9F=A5=E6=97=A5?= =?UTF-8?q?=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 之前 apt-get update 用 -qq 静默,看不到到底卡在哪。加日志: - 打印 os-release、sources 文件列表和内容 - 换源后对比确认 sed 生效 - DNS 解析 + HTTP 探测 mirrors.aliyun.com - apt-get update 去 -qq 输出详细 拿到日志再定位下一步(DNS 问题?network 问题?sources 格式问题?) Co-Authored-By: Claude Opus 4.7 (1M context) --- .gitea/workflows/deploy.yml | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 9f6e811..f16aa3c 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -10,18 +10,34 @@ jobs: steps: - name: 安装 Docker CLI run: | - # 大概率 gitea act_runner 已预装 docker,先探测(避免 apt 走国外源超时) if command -v docker >/dev/null 2>&1; then echo "Docker 已预装:$(docker --version)" exit 0 fi - echo "Docker 未预装,换 Ubuntu 源到阿里云再 apt 安装" - # 兼容 legacy sources.list、deb822 .sources、以及 sources.list.d/*.list + echo "=== 1. 系统信息 ===" + cat /etc/os-release | head -5 || true + echo "" + echo "=== 2. 换源前 sources 文件 ===" + ls -la /etc/apt/sources.list /etc/apt/sources.list.d/ 2>&1 || true + grep -h -E 'ubuntu|debian|http' /etc/apt/sources.list /etc/apt/sources.list.d/*.sources /etc/apt/sources.list.d/*.list 2>/dev/null | grep -v '^#' | head -10 || true + echo "" + echo "=== 3. 换源到阿里云 ===" sed -i 's|archive.ubuntu.com|mirrors.aliyun.com|g;s|security.ubuntu.com|mirrors.aliyun.com|g' /etc/apt/sources.list 2>/dev/null || true sed -i 's|archive.ubuntu.com|mirrors.aliyun.com|g;s|security.ubuntu.com|mirrors.aliyun.com|g' /etc/apt/sources.list.d/*.sources 2>/dev/null || true sed -i 's|archive.ubuntu.com|mirrors.aliyun.com|g;s|security.ubuntu.com|mirrors.aliyun.com|g' /etc/apt/sources.list.d/*.list 2>/dev/null || true - timeout 90 apt-get update -qq || { echo "apt-get update 超时/失败"; exit 1; } - timeout 240 apt-get install -y -qq docker.io || { echo "docker.io 安装超时/失败"; exit 1; } + echo "--- 换源后 sources 内容:" + grep -h -E 'aliyun|ubuntu|debian|http' /etc/apt/sources.list /etc/apt/sources.list.d/*.sources /etc/apt/sources.list.d/*.list 2>/dev/null | grep -v '^#' | head -10 || true + echo "" + echo "=== 4. 网络探测 ===" + echo "--- DNS 解析 mirrors.aliyun.com:" + timeout 5 getent hosts mirrors.aliyun.com || echo "DNS 解析失败" + echo "--- HTTP 探测 mirrors.aliyun.com:" + timeout 10 curl -s -o /dev/null -w "http_code=%{http_code} time=%{time_total}s\n" http://mirrors.aliyun.com/ || echo "curl 阿里云失败" + echo "" + echo "=== 5. apt-get update ===" + timeout 90 apt-get update || { echo "apt-get update 失败,看上面日志定位"; exit 1; } + echo "=== 6. 安装 docker.io ===" + timeout 240 apt-get install -y docker.io || { echo "docker.io 安装超时"; exit 1; } docker --version - name: 拉取代码