ci(docker): 简化Docker工作流配置
Some checks failed
Build docker and publish / build (20.15.1) (push) Failing after 24s

移除冗余的系统时间同步、HTTPS源配置和GPG密钥修复步骤
保留必要的apt更新和软件包安装
简化Docker构建参数
This commit is contained in:
shanshanzhong 2025-10-13 18:28:42 -07:00
parent 5600278618
commit 6cee877922

View File

@ -68,43 +68,7 @@ jobs:
run: | run: |
set -e set -e
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
>/dev/null 2>&1; then
# 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
LOCKS_BUSY=1 LOCKS_BUSY=1
fi fi
fi fi
@ -117,14 +81,7 @@ jobs:
fi fi
echo "仍在等待锁释放..."; sleep 5 echo "仍在等待锁释放..."; sleep 5
done done
apt-get update -y -o Dpkg::Lock::Timeout=600
# 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 install -y -o Dpkg::Lock::Timeout=600 jq curl ca-certificates docker.io apt-get install -y -o Dpkg::Lock::Timeout=600 jq curl ca-certificates docker.io
docker --version docker --version
jq --version jq --version
@ -141,11 +98,8 @@ jobs:
# 构建镜像,同时打上版本和分支两个标签 # 构建镜像,同时打上版本和分支两个标签
docker build -f Dockerfile \ docker build -f Dockerfile \
--platform linux/amd64 \ --platform linux/amd64 \
--build-arg TARGETARCH=amd64 \ --builI}} \
--build-arg VERSION=${{ env.VERSION }} \ -t ${{ env.REPO }}:${{ env.VERSION }} FFIX }} \
--build-arg BUILDTIME=${{ env.BUILDTIME }} \
-t ${{ env.REPO }}:${{ env.VERSION }} \
-t ${{ env.REPO }}:${{ env.DOCKER_TAG_SUFFIX }} \
. .
echo "推送版本标签镜像: ${{ env.REPO }}:${{ env.VERSION }}" echo "推送版本标签镜像: ${{ env.REPO }}:${{ env.VERSION }}"