@@ -115,23 +115,42 @@ runs:
115115 LOAD_OR_PUSH="--load"
116116 fi
117117
118+ export DOCKER_CLIENT_TIMEOUT=300
119+ export COMPOSE_HTTP_TIMEOUT=300
120+
118121 # Get image name from compose config since rocketchat image is different from service name (rocket.chat)
119122 IMAGE=$(docker compose "${compose_files[@]}" config --format json 2>/dev/null | jq -r --arg s "${{ inputs.service }}" '.services[$s].image')
120123
121- docker buildx bake \
122- "${compose_files[@]}" \
123- ${LOAD_OR_PUSH} \
124- --allow=fs.read=/tmp/build \
125- --set "*.tags+=${IMAGE}-gha-run-${{ github.run_id }}" \
126- --set "*.labels.org.opencontainers.image.description=Build run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
127- --set "*.labels.org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}" \
128- --set *.platform=linux/${{ inputs.arch }} \
129- --set *.cache-from=type=gha \
130- --set *.cache-to=type=gha,mode=max \
131- --provenance=false \
132- --sbom=false \
133- --metadata-file "/tmp/meta.json" \
124+ buildx_bake_cmd=(
125+ docker buildx bake
126+ "${compose_files[@]}"
127+ ${LOAD_OR_PUSH}
128+ --allow=fs.read=/tmp/build
129+ --set "*.tags+=${IMAGE}-gha-run-${{ github.run_id }}"
130+ --set "*.labels.org.opencontainers.image.description=Build run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
131+ --set "*.labels.org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}"
132+ --set *.platform=linux/${{ inputs.arch }}
133+ --set *.cache-from=type=gha
134+ --set *.cache-to=type=gha,mode=max
135+ --provenance=false
136+ --sbom=false
137+ --metadata-file "/tmp/meta.json"
134138 "${{ inputs.service }}"
139+ )
140+
141+ attempts=1
142+ max_attempts=3
143+ until "${buildx_bake_cmd[@]}"; do
144+ if [[ "${{ inputs.publish-image }}" != 'true' || $attempts -ge $max_attempts ]]; then
145+ echo "docker buildx bake failed after ${attempts} attempt(s)."
146+ exit 1
147+ fi
148+
149+ attempts=$((attempts + 1))
150+ sleep_seconds=$((15 * attempts))
151+ echo "docker buildx bake failed (likely transient push error). Retrying in ${sleep_seconds}s... (attempt ${attempts}/${max_attempts})"
152+ sleep ${sleep_seconds}
153+ done
135154
136155 echo "Contents of /tmp/meta.json:"
137156 cat /tmp/meta.json
0 commit comments