From 61ffb2ecd83d68b284119c62ebd91e3bda5513ed Mon Sep 17 00:00:00 2001 From: hamed <15238-genius.ha@users.noreply.drupalcode.org> Date: Sun, 28 Jun 2026 14:25:48 +0330 Subject: [PATCH] fix(docker): retry composer install + source fallback for flaky GitHub on Coolify Coolify build host intermittently gets HTTP 400 from codeload.github.com on Composer dist downloads. Bump COMPOSER_HTTP_RETRIES, wrap the install in a 5x retry loop, and on final attempt fall back to --prefer-source (git clone, different endpoint than dist zips). Co-Authored-By: Claude Opus 4.8 --- Dockerfile | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 20a678c6..fe289a57 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,10 +7,24 @@ FROM composer:2 AS vendor WORKDIR /app COPY composer.json composer.lock symfony.lock ./ # --no-scripts: the Symfony kernel isn't fully copied yet; scripts run later in entrypoint. -RUN composer install \ - --no-dev --no-scripts --no-interaction \ - --prefer-dist --optimize-autoloader \ - --ignore-platform-reqs +# +# The Coolify build host intermittently gets HTTP 400 from codeload.github.com +# when Composer pulls dist zips. Mitigations: +# - bump Composer's own HTTP retry count +# - wrap the whole install in a retry loop +# - on the final attempt, fall back to --prefer-source (git clone) which uses +# a different endpoint than codeload dist zips +ENV COMPOSER_HTTP_RETRIES=5 +RUN set -eu; \ + for i in 1 2 3 4 5; do \ + composer install --no-dev --no-scripts --no-interaction \ + --prefer-dist --optimize-autoloader --ignore-platform-reqs && exit 0; \ + echo "composer install failed (attempt $i) — retrying in 5s"; \ + sleep 5; \ + done; \ + echo "dist download kept failing — final attempt via --prefer-source"; \ + composer install --no-dev --no-scripts --no-interaction \ + --prefer-source --optimize-autoloader --ignore-platform-reqs # ============================================================ # Stage 2 — Frontend assets (Webpack Encore / React 19)