fix: add 25min timeout to docker buildx build to prevent infinite hang
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 38s
AI Code Review / AI Code Review (pull_request) Successful in 1m21s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m35s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 1m37s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m41s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 2m3s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 2m52s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m48s
CI/CD Pipeline / Validate - Code Quality (pull_request) Successful in 5m35s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 10m14s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 11m56s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 7m19s
CI/CD Pipeline / CI Gate (pull_request) Successful in 9s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 34s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 1m9s
CI/CD Pipeline / Canary Release to Production (pull_request) Failing after 697h35m43s
CI/CD Pipeline / Deploy Production (pull_request) Failing after 697h35m44s
CI/CD Pipeline / Build Production Worker Image (pull_request) Failing after 697h35m45s
CI/CD Pipeline / Build Production API Image (pull_request) Failing after 697h35m45s
CI/CD Pipeline / PR Build Web Image (pull_request) Failing after 697h47m39s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 697h47m42s
CI/CD Pipeline / ACR Image Cleanup (pull_request) Failing after 697h48m13s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 697h48m15s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 697h48m15s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 697h48m19s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 697h48m21s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 697h48m21s
CI/CD Pipeline / Production Browser E2E (pull_request) Failing after 698h9m24s
CI/CD Pipeline / Build Production Web Image (pull_request) Failing after 698h9m26s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Failing after 698h21m22s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 698h22m2s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 38s
AI Code Review / AI Code Review (pull_request) Successful in 1m21s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m35s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 1m37s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m41s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 2m3s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 2m52s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m48s
CI/CD Pipeline / Validate - Code Quality (pull_request) Successful in 5m35s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 10m14s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 11m56s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 7m19s
CI/CD Pipeline / CI Gate (pull_request) Successful in 9s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 34s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 1m9s
CI/CD Pipeline / Canary Release to Production (pull_request) Failing after 697h35m43s
CI/CD Pipeline / Deploy Production (pull_request) Failing after 697h35m44s
CI/CD Pipeline / Build Production Worker Image (pull_request) Failing after 697h35m45s
CI/CD Pipeline / Build Production API Image (pull_request) Failing after 697h35m45s
CI/CD Pipeline / PR Build Web Image (pull_request) Failing after 697h47m39s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 697h47m42s
CI/CD Pipeline / ACR Image Cleanup (pull_request) Failing after 697h48m13s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 697h48m15s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 697h48m15s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 697h48m19s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 697h48m21s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 697h48m21s
CI/CD Pipeline / Production Browser E2E (pull_request) Failing after 698h9m24s
CI/CD Pipeline / Build Production Web Image (pull_request) Failing after 698h9m26s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Failing after 698h21m22s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 698h22m2s
This commit is contained in:
@@ -3,6 +3,9 @@
|
||||
# 用法: docker_build_push.sh [--no-cache] <Dockerfile> <image_tag> <cache_ref> [build_arg...]
|
||||
set -eu
|
||||
|
||||
# 单次 build 超时时间(秒),防止 docker buildx build 无限挂起
|
||||
BUILD_TIMEOUT=1500
|
||||
|
||||
NO_CACHE_FLAG=""
|
||||
if [ "$1" = "--no-cache" ]; then
|
||||
NO_CACHE_FLAG="--no-cache"
|
||||
@@ -43,7 +46,7 @@ build_with_cache_retry() {
|
||||
local build_output
|
||||
local exit_code
|
||||
set +e
|
||||
build_output=$(docker buildx build \
|
||||
build_output=$(timeout ${BUILD_TIMEOUT} docker buildx build \
|
||||
$NO_CACHE_FLAG \
|
||||
$BUILD_ARGS \
|
||||
--cache-from "type=local,src=${LOCAL_CACHE_DIR}" \
|
||||
@@ -60,6 +63,12 @@ build_with_cache_retry() {
|
||||
echo "$build_output"
|
||||
return 0
|
||||
fi
|
||||
# 超时退出(exit code 124)
|
||||
if [ $exit_code -eq 124 ]; then
|
||||
echo "❌ Docker build TIMEOUT after ${BUILD_TIMEOUT}s - build hung and was killed"
|
||||
echo "$build_output" | tail -20
|
||||
return $exit_code
|
||||
fi
|
||||
# 检测到缓存损坏类错误,清掉本地缓存重试
|
||||
if echo "$build_output" | grep -qE "parent snapshot.*not found|snapshot.*does not exist|cache.*corrupt|failed to compute cache key"; then
|
||||
echo "$build_output"
|
||||
@@ -68,7 +77,7 @@ build_with_cache_retry() {
|
||||
rm -rf "${LOCAL_CACHE_DIR}"
|
||||
mkdir -p "${LOCAL_CACHE_DIR}"
|
||||
# 清理buildx builder的内部snapshot状态
|
||||
docker buildx prune -f -a >/dev/null 2>&1 || true
|
||||
docker buildx prune -f -a > /dev/null 2>&1 || true
|
||||
attempt=$((attempt + 1))
|
||||
else
|
||||
# 非缓存类错误,直接输出并返回
|
||||
@@ -78,7 +87,7 @@ build_with_cache_retry() {
|
||||
done
|
||||
# 重试完还是失败,不用本地缓存最后试一次(只从registry读)
|
||||
echo "⚠️ All cached attempts failed, building without local cache..."
|
||||
docker buildx build \
|
||||
timeout ${BUILD_TIMEOUT} docker buildx build \
|
||||
$NO_CACHE_FLAG \
|
||||
$BUILD_ARGS \
|
||||
--cache-from "type=registry,ref=${CACHE_REF}" \
|
||||
@@ -93,6 +102,7 @@ build_with_cache_retry() {
|
||||
echo "=== Step 1: Build & push image (local cache + registry cache, with auto-repair) ==="
|
||||
echo "Local cache: ${LOCAL_CACHE_DIR}"
|
||||
echo "Registry cache: ${CACHE_REF}"
|
||||
echo "Build timeout: ${BUILD_TIMEOUT}s"
|
||||
echo ""
|
||||
|
||||
build_with_cache_retry
|
||||
|
||||
Reference in New Issue
Block a user