Skip to content

Commit

Permalink
Add host.docker.internal: host-gateway to Drupal image to support XDe…
Browse files Browse the repository at this point in the history
…bug on Linux hosts.
  • Loading branch information
alxp committed Jun 24, 2024
1 parent ab8a685 commit f54e129
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
20 changes: 6 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions build/docker-compose/docker-compose.drupal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -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
###############################################################################
Expand Down

0 comments on commit f54e129

Please sign in to comment.