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
This commit is contained in:
2025-11-04 15:04:57 +01:00
parent f97863af40
commit 0b342c68bb

View File

@@ -795,6 +795,8 @@ jobs:
CACHE_FROM_ARGS="${CACHE_FROM_ARGS} --cache-from ${CACHE_SRC}" CACHE_FROM_ARGS="${CACHE_FROM_ARGS} --cache-from ${CACHE_SRC}"
done done
# Build image with cache but don't push yet
echo "🏗️ Building image..."
docker buildx build \ docker buildx build \
--platform linux/amd64 \ --platform linux/amd64 \
--file ./Dockerfile.production \ --file ./Dockerfile.production \
@@ -804,14 +806,29 @@ jobs:
--tag "${REGISTRY_TO_USE}/${IMAGE_NAME}:git-${SHORT_SHA}" \ --tag "${REGISTRY_TO_USE}/${IMAGE_NAME}:git-${SHORT_SHA}" \
${CACHE_FROM_ARGS} \ ${CACHE_FROM_ARGS} \
--cache-to type=registry,ref="${CACHE_TARGET}/${IMAGE_NAME}:buildcache",mode=max \ --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 BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
--build-arg GIT_COMMIT=${COMMIT_SHA} \ --build-arg GIT_COMMIT=${COMMIT_SHA} \
--build-arg GIT_BRANCH=${REF_NAME} \ --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 - name: Set image info
id: image_info id: image_info