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 <noreply@anthropic.com>
This commit is contained in:
hamed
2026-06-28 14:25:48 +03:30
co-authored by Claude Opus 4.8
parent f1dd540ca2
commit 61ffb2ecd8
+18 -4
View File
@@ -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)