Skip to content

Commit

Permalink
build(config/containers) fall-back to src build for older Xdebug vers…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
lucatume committed Sep 1, 2023
1 parent c21e6b7 commit 95123e8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
18 changes: 16 additions & 2 deletions config/containers/php/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,23 @@ FROM composer:2.2 as composer

FROM php:${PHP_VERSION}-cli-alpine

ARG XDEBUG_SRC='xdebug'

COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/
RUN install-php-extensions xdebug && apk add gettext && rm -rf /var/cache/apk/*
RUN rm /usr/bin/install-php-extensions
# If the XDEBUG_SRC starts with http, download, extract and prepare it.
RUN if echo ${XDEBUG_SRC} | grep -Eq '^http'; then \
curl -k -o /tmp/xdebug.tgz ${XDEBUG_SRC} && \
XDEBUG_VERSION=$(echo ${XDEBUG_SRC} | sed -e 's/.*xdebug-\(.*\)\.tgz/\1/') && \
tar xzf /tmp/xdebug.tgz -C /tmp && \
mv /tmp/package.xml /tmp/xdebug-${XDEBUG_VERSION} && \
rm /tmp/xdebug.tgz && \
XDEBUG_SRC=/tmp/xdebug-${XDEBUG_VERSION}; \
fi \
&& install-php-extensions ${XDEBUG_SRC} \
&& apk add gettext \
&& rm -rf /var/cache/apk/* \
&& rm /usr/bin/install-php-extensions \
&& rm -rf /tmp/xdebug.tgz /tmp/xdebug-${XDEBUG_VERSION}

ARG XDEBUG_REMOTE_HOST='host.docker.internal'
ARG XDEBUG_REMOTE_PORT='9009'
Expand Down
20 changes: 20 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,37 @@ PROJECT_NAME = $(notdir $(PWD))
#.SILENT:
PHP_VERSION ?= 5.6

# Create a function that will return the xdebug source depending on the PHP version.
define xdebug_src
@if [ "$(1)" = 5.6 ]; \
then echo "https://pecl.php.net/get/xdebug-2.5.5.tgz"; \
elif [ "$(1)" = 7.0 ]; \
then echo "https://pecl.php.net/get/xdebug-2.7.2.tgz"; \
else \
echo "xdebug"; \
fi
endef

php_versions :=5.6 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2
build: $(build_php_versions) ## Builds the project PHP images.
mkdir -p var/cache/composer
mkdir -p var/log
# Foreach PHP version build a Docker image.
for version in $(php_versions); do \
if [ "$${version}" = 5.6 ]; \
then export XDEBUG_SRC="https://pecl.php.net/get/xdebug-2.5.5.tgz"; \
elif [ "$${version}" = 7.0 ]; \
then export XDEBUG_SRC="https://pecl.php.net/get/xdebug-2.7.2.tgz"; \
else \
export XDEBUG_SRC="xdebug"; \
fi; \
docker build \
--build-arg PHP_VERSION=$${version} \
--build-arg XDEBUG_REMOTE_HOST=$${XDEBUG_REMOTE_HOST:-host.docker.internal} \
--build-arg XDEBUG_REMOTE_PORT=$${XDEBUG_REMOTE_PORT:-9009} \
--build-arg WORKDIR=${PWD} \
--build-arg XDEBUG_SRC=$${XDEBUG_SRC} \
--progress plain \
config/containers/php \
--tag lucatume/di52-dev:php-v$${version}; \
done
Expand Down

0 comments on commit 95123e8

Please sign in to comment.