From f54e129b2ab495c42aa6b5074a434829a0976a84 Mon Sep 17 00:00:00 2001 From: Alexander O'Neill Date: Thu, 6 Jun 2024 22:46:51 -0300 Subject: [PATCH] Add host.docker.internal: host-gateway to Drupal image to support XDebug on Linux hosts. --- Makefile | 20 ++++++------------- .../docker-compose/docker-compose.drupal.yml | 2 ++ sample.env | 3 +++ 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 644c3e1d6..48870a1e8 100644 --- a/Makefile +++ b/Makefile @@ -17,16 +17,6 @@ else # GNU/Linux SED_DASH_I=sed -i endif -# Deal with the lack of host.docker.internal on Linux hosts. -ifeq ($(shell uname -s),Darwin) - XDEBUG_HOST_COMMAND=# On a Mac, using host.docker.internal to connect back to host. -else # GNU/Linux - XDEBUG_HOST_COMMAND=docker compose exec drupal bash -lc 'echo -e "\n\# Connect back to host for XDebug\n172.17.0.1 host.docker.internal\n" >> /etc/hosts' -endif - - - - # If custom.makefile exists include it. -include custom.Makefile @@ -50,6 +40,9 @@ export ## Add necessary variables ## ############################################# +PHP_MAJOR_VERSION?=8 +PHP_MINOR_VERSION?=3 + # Services that are not produced by isle-buildkit. EXTERNAL_SERVICES := etcd watchtower traefik @@ -121,7 +114,6 @@ TARGET_MAX_CHAR_NUM=20 IS_DRUPAL_PSSWD_FILE_READABLE := $(shell test -r secrets/live/DRUPAL_DEFAULT_ACCOUNT_PASSWORD -a -w secrets/live/DRUPAL_DEFAULT_ACCOUNT_PASSWORD && echo 1 || echo 0) CMD := $(shell [ $(IS_DRUPAL_PSSWD_FILE_READABLE) -eq 1 ] && echo 'tee' || echo 'sudo -k tee') -PHP_VERSION=83 LATEST_VERSION := $(shell curl -s https://api.github.com/repos/desandro/masonry/releases/latest | grep '\"tag_name\":' | sed -E 's/.*\"([^\"]+)\".*/\1/') PHP_FPM_PID=/var/run/php-fpm7/php-fpm7.pid @@ -705,9 +697,9 @@ xdebug: $(MAKE) set-timeout TIMEOUT_VALUE=3600 sleep 10 - docker compose exec -T drupal with-contenv bash -lc "apk add php${PHP_VERSION}-pecl-xdebug" - docker cp scripts/extra/xdebug.ini $$(docker compose ps -q drupal):/etc/php${PHP_VERSION}/conf.d/xdebug.ini - -docker compose exec -T drupal with-contenv bash -lc "chown root:root /etc/php${PHP_VERSION}/conf.d/xdebug.ini" + docker compose exec -T drupal with-contenv bash -lc "apk add php${PHP_MAJOR_VERSION}${PHP_MINOR_VERSION}-pecl-xdebug" + docker cp scripts/extra/xdebug.ini $$(docker compose ps -q drupal):/etc/php${PHP_MAJOR_VERSION}${PHP_MINOR_VERSION}/conf.d/xdebug.ini + -docker compose exec -T drupal with-contenv bash -lc "chown root:root /etc/php${PHP_MAJOR_VERSION}${PHP_MINOR_VERSION}/conf.d/xdebug.ini" $(XDEBUG_HOST_COMMAND) docker compose restart drupal diff --git a/build/docker-compose/docker-compose.drupal.yml b/build/docker-compose/docker-compose.drupal.yml index 9de21bfa3..22859bd72 100644 --- a/build/docker-compose/docker-compose.drupal.yml +++ b/build/docker-compose/docker-compose.drupal.yml @@ -30,6 +30,8 @@ services: PHP_MAX_INPUT_TIME: ${PHP_MAX_EXECUTION_TIME} PHP_PROCESS_CONTROL_TIMEOUT: ${PHP_MAX_EXECUTION_TIME} PHP_REQUEST_TERMINATE_TIMEOUT: ${PHP_MAX_EXECUTION_TIME} + extra_hosts: + host.docker.internal: host-gateway labels: - traefik.enable=${EXPOSE_DRUPAL:-true} - traefik.http.services.${COMPOSE_PROJECT_NAME-isle-dc}-drupal.loadbalancer.server.port=80 diff --git a/sample.env b/sample.env index aada66dac..d988eb056 100644 --- a/sample.env +++ b/sample.env @@ -96,6 +96,9 @@ REPOSITORY=islandora # their versions specified explicitly in their respective docker-compose files. TAG=main +PHP_MAJOR_VERSION=8 +PHP_MINOR_VERSION=3 + ############################################################################### # Exposed Containers & Ports ###############################################################################