From 0b342c68bbfe6e1e4add1b7f2f44116153d688d2 Mon Sep 17 00:00:00 2001 From: Michael Schiemer Date: Tue, 4 Nov 2025 15:04:57 +0100 Subject: [PATCH] fix(ci): change docker build to load then push tags sequentially Docker registry was getting overwhelmed with concurrent pushes of multiple tags and cache layers, resulting in 499 status code (Client Closed Request). Changes: - Build with --load instead of --push to save image locally first - Push each tag sequentially (latest, timestamp, git-sha) instead of all at once - Reduce cache targets from 2 to 1 (keep only buildcache) - Add progress logging for each push operation This approach: 1. Reduces concurrent write pressure on registry 2. Allows better error handling per tag 3. Provides clearer progress feedback 4. Prevents registry timeouts from concurrent uploads Related to: Status 499 error during docker push --- .gitea/workflows/build-image.yml | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/build-image.yml b/.gitea/workflows/build-image.yml index 2f1dccc3..2b0f32cf 100644 --- a/.gitea/workflows/build-image.yml +++ b/.gitea/workflows/build-image.yml @@ -795,6 +795,8 @@ jobs: CACHE_FROM_ARGS="${CACHE_FROM_ARGS} --cache-from ${CACHE_SRC}" done + # Build image with cache but don't push yet + echo "🏗️ Building image..." docker buildx build \ --platform linux/amd64 \ --file ./Dockerfile.production \ @@ -804,14 +806,29 @@ jobs: --tag "${REGISTRY_TO_USE}/${IMAGE_NAME}:git-${SHORT_SHA}" \ ${CACHE_FROM_ARGS} \ --cache-to type=registry,ref="${CACHE_TARGET}/${IMAGE_NAME}:buildcache",mode=max \ - --cache-to type=registry,ref="${REGISTRY_TO_USE}/${IMAGE_NAME}:${REF_NAME}-cache",mode=max \ --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \ --build-arg GIT_COMMIT=${COMMIT_SHA} \ --build-arg GIT_BRANCH=${REF_NAME} \ - --push \ + --load \ . - - echo "✅ Image built and pushed successfully!" + + echo "✅ Image built successfully!" + + # Push tags one by one to avoid overwhelming the registry + echo "📤 Pushing tags to registry..." + docker tag "${REGISTRY_TO_USE}/${IMAGE_NAME}:latest" "${REGISTRY_TO_USE}/${IMAGE_NAME}:${TAG}" + docker tag "${REGISTRY_TO_USE}/${IMAGE_NAME}:latest" "${REGISTRY_TO_USE}/${IMAGE_NAME}:git-${SHORT_SHA}" + + echo " Pushing latest..." + docker push "${REGISTRY_TO_USE}/${IMAGE_NAME}:latest" + + echo " Pushing ${TAG}..." + docker push "${REGISTRY_TO_USE}/${IMAGE_NAME}:${TAG}" + + echo " Pushing git-${SHORT_SHA}..." + docker push "${REGISTRY_TO_USE}/${IMAGE_NAME}:git-${SHORT_SHA}" + + echo "✅ All tags pushed successfully!" - name: Set image info id: image_info