diff --git a/.github/workflows/docker.build.yaml b/.github/workflows/docker.build.yaml index 5388004..4600bcf 100644 --- a/.github/workflows/docker.build.yaml +++ b/.github/workflows/docker.build.yaml @@ -163,6 +163,22 @@ jobs: working-directory: ${{ runner.temp }}/digests run: | set -euo pipefail + + # Docker Hub answers bursts of requests with 429 Too Many Requests, + # so every call to it is retried with a growing delay. + retry() { + local attempt=1 delay=30 + until "$@"; do + if [ "${attempt}" -ge 5 ]; then + return 1 + fi + echo "::warning::Attempt ${attempt} failed, retrying in ${delay} seconds" + sleep "${delay}" + attempt=$((attempt + 1)) + delay=$((delay * 2)) + done + } + versions="$(find . -mindepth 1 -maxdepth 1 -type d -name 'digest-*' | sed -n 's|^\./digest-\([0-9.]*\)-[a-z0-9]*$|\1|p' | sort -u)" [ -n "${versions}" ] || { echo "::error::No digests found"; exit 1; } for version in ${versions}; do @@ -180,11 +196,14 @@ jobs: sources+=("${image}@sha256:${digest}") done echo "::group::${image}:${version}" - docker buildx imagetools create \ + retry docker buildx imagetools create \ --tag "${image}:${version%.*}" \ --tag "${image}:${version}" \ "${sources[@]}" - docker buildx imagetools inspect "${image}:${version}" + # Only Harbor is inspected, to spare Docker Hub the requests. + case "${image}" in + harbor.flownative.io/*) retry docker buildx imagetools inspect "${image}:${version}" ;; + esac echo "::endgroup::" done done diff --git a/Dockerfile b/Dockerfile index 24750ec..b346055 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ ARG PHP_BASE_IMAGE # The stage runs on the build platform and cross-compiles, so no emulation is # involved. -FROM --platform=$BUILDPLATFORM golang:1-alpine AS php-fpm-exporter-builder +FROM --platform=$BUILDPLATFORM harbor.flownative.io/docker.io/library/golang:1-alpine AS php-fpm-exporter-builder ARG PHP_FPM_EXPORTER_VERSION=0ef3d973d5046059993d90dc32c86f36eab0929f ARG TARGETOS @@ -41,7 +41,7 @@ USER root COPY root-files / -COPY --from=blackfire/blackfire:2 /usr/local/bin/blackfire /opt/flownative/php/bin/ +COPY --from=harbor.flownative.io/docker.io/blackfire/blackfire:2 /usr/local/bin/blackfire /opt/flownative/php/bin/ COPY --from=php-fpm-exporter-builder /out/php-fpm_exporter /opt/flownative/php/bin/php-fpm-exporter