Compare commits

..

1 commit
main ... xdebug

Author SHA1 Message Date
Oliver Davies 4138112e4c Add initial xdebug support
Enable using `XDEBUG_MODE=debug docker compose up`.
2024-05-01 23:41:34 +01:00
13 changed files with 1825 additions and 1833 deletions

View file

@ -7,12 +7,6 @@ export COMPOSE_PROFILES=web,php,database
export DOCKER_WEB_VOLUME=.:/app export DOCKER_WEB_VOLUME=.:/app
export DRUSH_OPTIONS_URI="https://${COMPOSE_PROJECT_NAME}.docker.localhost"
export MYSQL_DATABASE=app export MYSQL_DATABASE=app
export MYSQL_PASSWORD=app export MYSQL_PASSWORD=app
export MYSQL_USER=app export MYSQL_USER=app
export DB_NAME="$MYSQL_DATABASE"
export DB_PASSWORD="$MYSQL_PASSWORD"
export DB_USER="$MYSQL_USER"

2
.gitignore vendored
View file

@ -3,7 +3,6 @@
.editorconfig .editorconfig
.env .env
.gitattributes .gitattributes
.phpunit.result.cache
vendor/ vendor/
web/.csslintrc web/.csslintrc
web/.eslintignore web/.eslintignore
@ -40,3 +39,4 @@ web/web.config
.env .env
docker-compose.override.yaml docker-compose.override.yaml

View file

@ -1,6 +1,6 @@
# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs. # Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
FROM php:8.3-fpm-bullseye AS base FROM php:8.2-fpm-bullseye AS base
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
RUN which composer && composer -V RUN which composer && composer -V
@ -32,9 +32,13 @@ RUN apt-get update -yqq \
&& rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man \ && rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man \
&& apt-get clean && apt-get clean
RUN pecl install xdebug
RUN docker-php-ext-configure gd --with-jpeg RUN docker-php-ext-configure gd --with-jpeg
RUN docker-php-ext-install gd opcache pdo_mysql zip RUN docker-php-ext-install gd pdo_mysql zip
RUN docker-php-ext-enable xdebug
COPY --chown=app:app phpunit.xml* ./ COPY --chown=app:app phpunit.xml* ./

View file

@ -10,7 +10,7 @@ database:
version: 10 version: 10
php: php:
version: 8.3-fpm-bullseye version: 8.2-fpm-bullseye
phpcs: phpcs:
paths: paths:
- web/modules/custom - web/modules/custom

View file

@ -16,10 +16,11 @@
], ],
"require": { "require": {
"composer/installers": "^1.9", "composer/installers": "^1.9",
"drupal/core-composer-scaffold": "^11", "drupal/core-composer-scaffold": "^10",
"drupal/core-project-message": "^11", "drupal/core-project-message": "^10",
"drupal/core-recommended": "^11", "drupal/core-recommended": "^10",
"drush/drush": "^13" "drupal/examples": "^4.0",
"drush/drush": "^12.4"
}, },
"conflict": { "conflict": {
"drupal/drupal": "*" "drupal/drupal": "*"
@ -110,7 +111,7 @@
} }
}, },
"require-dev": { "require-dev": {
"drupal/core-dev": "^11", "drupal/core-dev": "^10",
"phpspec/prophecy-phpunit": "^2" "phpspec/prophecy-phpunit": "^2"
} }
} }

3574
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,8 +1,6 @@
services: services:
php-fpm: php:
environment:
XDEBUG_MODE: ${XDEBUG_MODE:-off}
extra_hosts: extra_hosts:
- "host.docker.internal:host-gateway" host.docker.internal: host-gateway
web:
ports:
- "80:80"

View file

@ -3,14 +3,12 @@
x-proxy: &default-proxy x-proxy: &default-proxy
networks: networks:
- default - default
- proxy - web
labels: labels:
- "traefik.enable=true"
- "traefik.docker.network=traefik_proxy" - "traefik.docker.network=traefik_proxy"
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}.rule=Host( - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.rule=Host(
`${COMPOSE_PROJECT_NAME}.docker.localhost`, `${COMPOSE_PROJECT_NAME}.localhost`,
)" )"
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}.tls=true"
x-app: &default-app x-app: &default-app
volumes: volumes:
@ -26,7 +24,7 @@ x-app: &default-app
cpus: "${DOCKER_MYSQL_CPUS:-0}" cpus: "${DOCKER_MYSQL_CPUS:-0}"
memory: "${DOCKER_MYSQL_MEMORY:-0}" memory: "${DOCKER_MYSQL_MEMORY:-0}"
labels: labels:
- "traefik.enable=false" - "traefik.enabled=false"
tty: true tty: true
services: services:
@ -65,7 +63,7 @@ services:
env_file: env_file:
- .env - .env
labels: labels:
- "traefik.enable=false" - "traefik.enabled=false"
environment: environment:
MYSQL_RANDOM_ROOT_PASSWORD: true MYSQL_RANDOM_ROOT_PASSWORD: true
profiles: [database] profiles: [database]
@ -74,6 +72,6 @@ volumes:
db-data: {} db-data: {}
networks: networks:
proxy: web:
external: true external: true
name: traefik_proxy name: traefik_proxy

View file

@ -17,7 +17,7 @@
<env name="MINK_DRIVER_ARGS_WEBDRIVER" value=''/> <env name="MINK_DRIVER_ARGS_WEBDRIVER" value=''/>
<env name="MINK_DRIVER_CLASS" value=''/> <env name="MINK_DRIVER_CLASS" value=''/>
<env name="SIMPLETEST_BASE_URL" value="http://web"/> <env name="SIMPLETEST_BASE_URL" value="http://web"/>
<env name="SIMPLETEST_DB" value="mysql://app:app@database/app#test"/> <env name="SIMPLETEST_DB" value="sqlite://localhost//dev/shm/test.sqlite"/>
<ini name="error_reporting" value="32767"/> <ini name="error_reporting" value="32767"/>
<ini name="memory_limit" value="-1"/> <ini name="memory_limit" value="-1"/>

24
run
View file

@ -18,9 +18,9 @@ function ci:test {
docker compose version docker compose version
docker network create traefik_proxy || true docker network create traefik_proxy
cp --no-clobber .env.example .env || true cp --no-clobber .env.example .env
docker compose build --progress plain docker compose build --progress plain
@ -39,34 +39,22 @@ function cmd {
docker compose exec php "${@}" docker compose exec php "${@}"
} }
# Run coding standards checks.
function coding-standards { function coding-standards {
cmd phpcs "${@}" cmd phpcs "${@}"
} }
# Execute any Composer command.
function composer { function composer {
_exec php composer "${@}" _exec php composer "${@}"
} }
# Connect to the database.
function db {
[[ -f ".env" ]] && source .env
docker compose exec database mysql -u"$DB_USER" -p"$DB_PASSWORD" "$DB_NAME"
}
# Execute any Drush command.
function drush { function drush {
_exec php drush "${@}" _exec php drush "${@}"
} }
# Disable Git hooks.
function git-hooks:off { function git-hooks:off {
git config --unset core.hooksPath git config --unset core.hooksPath
} }
# Enable Git hooks.
function git-hooks:on { function git-hooks:on {
git config core.hooksPath .githooks git config core.hooksPath .githooks
} }
@ -85,19 +73,16 @@ function install {
drush site:install -y "${@}" drush site:install -y "${@}"
} }
# Lint the Dockerfile.
function lint:dockerfile { function lint:dockerfile {
docker container run --rm -i \ docker container run --rm -i \
hadolint/hadolint hadolint --ignore DL3008 --ignore DL3022 --ignore DL3059 -t style "${@}" - < Dockerfile hadolint/hadolint hadolint --ignore DL3008 --ignore DL3059 -t style "${@}" - < Dockerfile
} }
# Run code quality checks.
function quality { function quality {
coding-standards coding-standards
static-analysis static-analysis
} }
# Start the project.
function start { function start {
cp -v --no-clobber .env.example .env || true cp -v --no-clobber .env.example .env || true
@ -141,8 +126,7 @@ function _run {
} }
# Include any local tasks. # Include any local tasks.
# https://stackoverflow.com/a/6659698 [[ -e run.local ]] && source run.local
[[ -e "${BASH_SOURCE%/*}/run.local" ]] && source "${BASH_SOURCE%/*}/run.local"
TIMEFORMAT=$'\nTask completed in %3lR' TIMEFORMAT=$'\nTask completed in %3lR'
time "${@:-help}" time "${@:-help}"

View file

@ -1,6 +1,3 @@
xdebug.mode=develop,debug
xdebug.client_host=host.docker.internal xdebug.client_host=host.docker.internal
xdebug.discover_client_host=0 xdebug.discover_client_host=0
xdebug.output_dir=/tmp/xdebug
xdebug.log=/tmp/xdebug/xdebug-docker-drupal-example.log
xdebug.start_with_request=yes xdebug.start_with_request=yes

View file

@ -1,5 +1,5 @@
name: Example module name: Example module
description: TODO description: TODO
type: module type: module
core_version_requirement: ^9 || ^10 || ^11 core_version_requirement: ^9||^10
package: Example package: Example

View file

@ -12,7 +12,7 @@ final class ExamplePageController {
use StringTranslationTrait; use StringTranslationTrait;
public function __construct( public function __construct(
private LoggerChannelFactoryInterface $logger, private LoggerChannelFactoryInterface $logger
) {} ) {}
/** /**