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 DRUSH_OPTIONS_URI="https://${COMPOSE_PROJECT_NAME}.docker.localhost"
export MYSQL_DATABASE=app
export MYSQL_PASSWORD=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
.env
.gitattributes
.phpunit.result.cache
vendor/
web/.csslintrc
web/.eslintignore
@ -40,3 +39,4 @@ web/web.config
.env
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.
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
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 \
&& apt-get clean
RUN pecl install xdebug
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* ./

View file

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

View file

@ -16,10 +16,11 @@
],
"require": {
"composer/installers": "^1.9",
"drupal/core-composer-scaffold": "^11",
"drupal/core-project-message": "^11",
"drupal/core-recommended": "^11",
"drush/drush": "^13"
"drupal/core-composer-scaffold": "^10",
"drupal/core-project-message": "^10",
"drupal/core-recommended": "^10",
"drupal/examples": "^4.0",
"drush/drush": "^12.4"
},
"conflict": {
"drupal/drupal": "*"
@ -110,7 +111,7 @@
}
},
"require-dev": {
"drupal/core-dev": "^11",
"drupal/core-dev": "^10",
"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:
php-fpm:
php:
environment:
XDEBUG_MODE: ${XDEBUG_MODE:-off}
extra_hosts:
- "host.docker.internal:host-gateway"
web:
ports:
- "80:80"
host.docker.internal: host-gateway

View file

@ -3,14 +3,12 @@
x-proxy: &default-proxy
networks:
- default
- proxy
- web
labels:
- "traefik.enable=true"
- "traefik.docker.network=traefik_proxy"
- "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
volumes:
@ -26,7 +24,7 @@ x-app: &default-app
cpus: "${DOCKER_MYSQL_CPUS:-0}"
memory: "${DOCKER_MYSQL_MEMORY:-0}"
labels:
- "traefik.enable=false"
- "traefik.enabled=false"
tty: true
services:
@ -65,7 +63,7 @@ services:
env_file:
- .env
labels:
- "traefik.enable=false"
- "traefik.enabled=false"
environment:
MYSQL_RANDOM_ROOT_PASSWORD: true
profiles: [database]
@ -74,6 +72,6 @@ volumes:
db-data: {}
networks:
proxy:
web:
external: true
name: traefik_proxy

View file

@ -17,7 +17,7 @@
<env name="MINK_DRIVER_ARGS_WEBDRIVER" value=''/>
<env name="MINK_DRIVER_CLASS" value=''/>
<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="memory_limit" value="-1"/>

24
run
View file

@ -18,9 +18,9 @@ function ci:test {
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
@ -39,34 +39,22 @@ function cmd {
docker compose exec php "${@}"
}
# Run coding standards checks.
function coding-standards {
cmd phpcs "${@}"
}
# Execute any Composer command.
function 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 {
_exec php drush "${@}"
}
# Disable Git hooks.
function git-hooks:off {
git config --unset core.hooksPath
}
# Enable Git hooks.
function git-hooks:on {
git config core.hooksPath .githooks
}
@ -85,19 +73,16 @@ function install {
drush site:install -y "${@}"
}
# Lint the Dockerfile.
function lint:dockerfile {
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 {
coding-standards
static-analysis
}
# Start the project.
function start {
cp -v --no-clobber .env.example .env || true
@ -141,8 +126,7 @@ function _run {
}
# Include any local tasks.
# https://stackoverflow.com/a/6659698
[[ -e "${BASH_SOURCE%/*}/run.local" ]] && source "${BASH_SOURCE%/*}/run.local"
[[ -e run.local ]] && source run.local
TIMEFORMAT=$'\nTask completed in %3lR'
time "${@:-help}"

View file

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

View file

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

View file

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