From 6cee877922269857681c8f14d6c36b1b3fbe88e4 Mon Sep 17 00:00:00 2001 From: shanshanzhong Date: Mon, 13 Oct 2025 18:28:42 -0700 Subject: [PATCH] =?UTF-8?q?ci(docker):=20=E7=AE=80=E5=8C=96Docker=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E6=B5=81=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除冗余的系统时间同步、HTTPS源配置和GPG密钥修复步骤 保留必要的apt更新和软件包安装 简化Docker构建参数 --- .gitea/workflows/docker.yml | 54 +++---------------------------------- 1 file changed, 4 insertions(+), 50 deletions(-) diff --git a/.gitea/workflows/docker.yml b/.gitea/workflows/docker.yml index 9d7b674..ba6a040 100644 --- a/.gitea/workflows/docker.yml +++ b/.gitea/workflows/docker.yml @@ -68,43 +68,7 @@ jobs: run: | set -e export DEBIAN_FRONTEND=noninteractive - - # 1. 同步系统时间 (修复GPG签名时间问题) - echo "同步系统时间..." - if command -v ntpdate >/dev/null 2>&1; then - ntpdate -s time.nist.gov || true - elif command -v timedatectl >/dev/null 2>&1; then - timedatectl set-ntp true || true - fi - date - - # 2. 配置HTTPS源 (避免HTTP连接的GPG问题) - echo "配置HTTPS软件源..." - if [ -f /etc/apt/sources.list ]; then - echo "修改现有的 sources.list..." - sed -i 's|http://deb.debian.org|https://deb.debian.org|g' /etc/apt/sources.list - sed -i 's|http://security.debian.org|https://deb.debian.org|g' /etc/apt/sources.list - else - echo "创建新的 sources.list..." - echo "deb https://deb.debian.org/debian bookworm main" > /etc/apt/sources.list - echo "deb https://deb.debian.org/debian bookworm-updates main" >> /etc/apt/sources.list - echo "deb https://deb.debian.org/debian-security bookworm-security main" >> /etc/apt/sources.list - fi - echo "当前软件源配置:" - cat /etc/apt/sources.list - - echo "等待 apt/dpkg 锁释放 (unattended-upgrades)..." - # 等待最多 300 秒让 unattended-upgrades/apt/dpkg 锁释放 - end=$((SECONDS+300)) - while true; do - LOCKS_BUSY=0 - # 如果 unattended-upgrades 正在运行,标记为忙碌 - if pgrep -x unattended-upgrades >/dev/null 2>&1; then LOCKS_BUSY=1; fi - # 如果 fuser 存在,检查常见的锁文件 - if command -v fuser >/dev/null 2>&1; then - if fuser /var/lib/dpkg/lock >/dev/null 2>&1 \ - || fuser /var/lib/dpkg/lock-frontend >/dev/null 2>&1 \ - || fuser /var/lib/apt/lists/lock >/dev/null 2>&1; then + >/dev/null 2>&1; then LOCKS_BUSY=1 fi fi @@ -117,14 +81,7 @@ jobs: fi echo "仍在等待锁释放..."; sleep 5 done - - # 3. 清理并重新安装GPG密钥 - echo "修复GPG密钥..." - rm -rf /var/lib/apt/lists/* - apt-get clean - apt-get update -y -o Dpkg::Lock::Timeout=600 -o Acquire::Retries=3 - - # 4. 安装软件包 + apt-get update -y -o Dpkg::Lock::Timeout=600 apt-get install -y -o Dpkg::Lock::Timeout=600 jq curl ca-certificates docker.io docker --version jq --version @@ -141,11 +98,8 @@ jobs: # 构建镜像,同时打上版本和分支两个标签 docker build -f Dockerfile \ --platform linux/amd64 \ - --build-arg TARGETARCH=amd64 \ - --build-arg VERSION=${{ env.VERSION }} \ - --build-arg BUILDTIME=${{ env.BUILDTIME }} \ - -t ${{ env.REPO }}:${{ env.VERSION }} \ - -t ${{ env.REPO }}:${{ env.DOCKER_TAG_SUFFIX }} \ + --builI}} \ + -t ${{ env.REPO }}:${{ env.VERSION }} FFIX }} \ . echo "推送版本标签镜像: ${{ env.REPO }}:${{ env.VERSION }}"