@@ -160,10 +160,38 @@ RUN /var/fixes/install_repositories_and_packages.sh
160160# Add the PHP Extension installer
161161ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
162162
163- RUN IPE_ALLOW_UNSTABLE=1 \
164- # Install PHP Extensions \
165- echo "Installing base PHP Extensions: $PHP_BASE_EXTENSIONS" > /dev/stdout && \
166- install-php-extensions $PHP_BASE_EXTENSIONS
163+ RUN EXT_NAMES="$PHP_BASE_EXTENSIONS" && \
164+ for EXT in $EXT_NAMES; do \
165+ echo "--- Processing $EXT ---" ; \
166+ # 1. Attempt to install the stable version \
167+ # We capture the output to a temporary file to scan for the PHP version error \
168+ if ! install-php-extensions "$EXT" 2>/tmp/ipe_error; then \
169+ ERROR_MSG=$(cat /tmp/ipe_error); \
170+ echo "$ERROR_MSG" >&2; \
171+ \
172+ # 2. Check if the failure was due to PHP version incompatibility \
173+ if echo "$ERROR_MSG" | grep -qi "requires PHP" ; then \
174+ echo "[Fallback] Stable $EXT failed PHP version check. Looking for latest (RC/Beta)..." ; \
175+ \
176+ # 3. Fetch the absolute latest version from PECL \
177+ LATEST=$(curl -s "https://pecl.php.net/rest/r/$EXT/allreleases.xml" | \
178+ sed -n 's/.*<v>\( [^<]*\) <\/ v>.*/\1 /p' | head -n 1); \
179+ \
180+ if [ -n "$LATEST" ]; then \
181+ echo "[Fallback] Trying $EXT-$LATEST..." ; \
182+ # 4. Final attempt: If this fails, the script exits and fails the build \
183+ install-php-extensions "$EXT-$LATEST" ; \
184+ else \
185+ echo "[Error] Could not find any releases for $EXT on PECL." ; \
186+ exit 1; \
187+ fi; \
188+ else \
189+ # If it failed for a different reason (compilation error, etc.), throw original error \
190+ echo "[Error] $EXT failed for reasons other than PHP version." ; \
191+ exit 1; \
192+ fi; \
193+ fi; \
194+ done
167195
168196#
169197# --------------------------------------------------------------------------
0 commit comments