diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..24700de --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,67 @@ +# https://www.drupal.org/docs/system-requirements/php-requirements +FROM mcr.microsoft.com/devcontainers/php:1-8.3 + +# install the PHP extensions we need +RUN set -eux; \ + \ + if command -v a2enmod; then \ + # https://github.com/drupal/drupal/blob/d91d8d0a6d3ffe5f0b6dde8c2fbe81404843edc5/.htaccess (references both mod_expires and mod_rewrite explicitly) + a2enmod expires rewrite; \ + fi; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + libfreetype6-dev \ + libjpeg-dev \ + libpng-dev \ + libpq-dev \ + libwebp-dev \ + libzip-dev \ + ; \ + \ + docker-php-ext-configure gd \ + --with-freetype \ + --with-jpeg=/usr \ + --with-webp \ + ; \ + \ + pecl install pcov; \ + \ + docker-php-ext-install -j "$(nproc)" \ + gd \ + opcache \ + pdo_mysql \ + pdo_pgsql \ + mysqli \ + zip \ + ; \ + \ + # reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark; \ + ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \ + | awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); printf "*%s\n", so }' \ + | sort -u \ + | xargs -r dpkg-query -S \ + | cut -d: -f1 \ + | sort -u \ + | xargs -rt apt-mark manual; \ + \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/* + +# Install MariaDB client +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get install -y mariadb-client vim\ + && apt-get clean -y && rm -rf /var/lib/apt/lists/* + +# set recommended PHP.ini settings +# see https://secure.php.net/manual/en/opcache.installation.php +RUN { \ + echo 'opcache.memory_consumption=128'; \ + echo 'opcache.interned_strings_buffer=8'; \ + echo 'opcache.max_accelerated_files=4000'; \ + echo 'opcache.revalidate_freq=60'; \ + } > /usr/local/etc/php/conf.d/opcache-recommended.ini diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..f8c195b --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,142 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/php-mariadb +{ + "name": "Drupal", + "dockerComposeFile": "docker-compose.yml", + "service": "app", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + "containerEnv": { + "SIMPLETEST_DB": "mysql://mariadb:mariadb@db/mariadb", + "SIMPLETEST_BASE_URL": "http://app", + "MINK_DRIVER_ARGS_WEBDRIVER": "[\"chrome\", {\"browserName\":\"chrome\",\"goog:chromeOptions\":{\"w3c\":false,\"args\":[\"--disable-gpu\", \"--no-sandbox\", \"--disable-dev-shm-usage\"]}}, \"http://selenium-chrome:4444/wd/hub\"]" + }, + "remoteEnv": { + "PATH": "${containerEnv:PATH}:./vendor/bin" + }, + // Use 'postCreateCommand' to run commands after the container is created + "postCreateCommand": "bash .devcontainer/scripts/postCreateCommand.sh", + "postStartCommand": "bash .devcontainer/scripts/postStartCommand.sh", + // Configure tool-specific properties. + "customizations": { + // Configurations from https://www.drupal.org/docs/develop/development-tools/editors-and-ides/configuring-visual-studio-code + "vscode": { + "extensions": [ + "bmewburn.vscode-intelephense-client", + "xdebug.php-pack", + "ValeryanM.vscode-phpsab", + "recca0120.vscode-phpunit", + "mtxr.sqltools", + "mtxr.sqltools-driver-mysql" + ], + "settings": { + "launch": { + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Listen for Xdebug", + "type": "php", + "request": "launch", + "port": 9000 + }, + { + "name": "Launch currently open script", + "type": "php", + "request": "launch", + "program": "${file}", + "cwd": "${fileDirname}", + "port": 0, + "runtimeArgs": [ + "-dxdebug.start_with_request=yes" + ], + "env": { + "XDEBUG_MODE": "debug,develop", + "XDEBUG_CONFIG": "client_port=${port}" + } + }, + { + "name": "Launch Built-in web server", + "type": "php", + "request": "launch", + "runtimeArgs": [ + "-dxdebug.mode=debug", + "-dxdebug.start_with_request=yes", + "-S", + "localhost:0" + ], + "program": "", + "cwd": "${workspaceRoot}", + "port": 9000, + "serverReadyAction": { + "pattern": "Development Server \\(http://localhost:([0-9]+)\\) started", + "uriFormat": "http://localhost:%s", + "action": "openExternally" + } + } + ] + }, + "breadcrumbs.enabled": true, + "css.validate": true, + "diffEditor.ignoreTrimWhitespace": false, + "editor.tabSize": 2, + "editor.autoIndent": "full", + "editor.insertSpaces": true, + "editor.formatOnPaste": true, + "editor.formatOnSave": false, + "editor.renderWhitespace": "boundary", + "editor.wordWrapColumn": 80, + "editor.wordWrap": "off", + "editor.detectIndentation": true, + "editor.rulers": [ + 80 + ], + "files.associations": { + "*.inc": "php", + "*.module": "php", + "*.install": "php", + "*.theme": "php", + "*.profile": "php", + "*.tpl.php": "php", + "*.test": "php", + "*.php": "php", + "*.info": "ini" + }, + "files.trimTrailingWhitespace": true, + "files.restoreUndoStack": false, + "files.insertFinalNewline": true, + "html.format.enable": true, + "html.format.wrapLineLength": 80, + "telemetry.telemetryLevel": "off", + /* PHP Intelephense (bmewburn.vscode-intelephense-client) */ + "intelephense.environment.includePaths": [ + "core/", + "core/includes", + "../vendor/" + ], + "php.validate.executablePath": "/usr/local/bin/php", + "sqltools.connections": [ + { + "mysqlOptions": { + "authProtocol": "default", + "enableSsl": "Disabled" + }, + "previewLimit": 50, + "server": "db", + "port": 3306, + "driver": "MariaDB", + "name": "db", + "database": "mariadb", + "username": "mariadb" + } + ], + "phpunit.args": [ + "--configuration docroot/core/phpunit.xml.dist" + ], + "phpunit.phpunit": "vendor/bin/phpunit" + } + } + }, + "remoteUser": "vscode" +} diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 0000000..d293849 --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,37 @@ +version: '3.8' + +services: + app: + build: + context: . + dockerfile: Dockerfile + + volumes: + - ../..:/workspaces:cached + + # Overrides default command so things don't shut down after the process ends. + command: sleep infinity + + hostname: app + + db: + image: mariadb:10.11 + restart: unless-stopped + volumes: + - mariadb-data:/var/lib/mysql + environment: + MYSQL_ROOT_PASSWORD: mariadb + MYSQL_DATABASE: mariadb + MYSQL_USER: mariadb + MYSQL_PASSWORD: mariadb + # Add "forwardPorts": ["3306"] to **devcontainer.json** to forward MariaDB locally. + # (Adding the "ports" property to this file will not forward from a Codespace.) + + selenium: + image: selenium/standalone-chrome + shm_size: 2g + environment: + VNC_NO_PASSWORD: 1 + +volumes: + mariadb-data: diff --git a/.devcontainer/scripts/postCreateCommand.sh b/.devcontainer/scripts/postCreateCommand.sh new file mode 100644 index 0000000..4f13678 --- /dev/null +++ b/.devcontainer/scripts/postCreateCommand.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Install dependencies +composer install + +# Setup docroot +DOCROOT=$(composer config extra.drupal-scaffold.locations.web-root) +sudo chmod a+x "$(pwd)" +sudo rm -rf /var/www/html +sudo ln -s "$(pwd)/${DOCROOT}" /var/www/html diff --git a/.devcontainer/scripts/postStartCommand.sh b/.devcontainer/scripts/postStartCommand.sh new file mode 100644 index 0000000..4b08f63 --- /dev/null +++ b/.devcontainer/scripts/postStartCommand.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +# Start Apache +apache2ctl start diff --git a/composer.json b/composer.json index ad2ab53..9c013f5 100644 --- a/composer.json +++ b/composer.json @@ -153,10 +153,10 @@ "merge-extra-deep": true }, "local-develop-packages": { - "thunder/thunder-distribution": "7.2.x", + "thunder/thunder-distribution": "7.4.x", "drupal/paragraphs_features": "2.x", "drupal/paragraphs_paste": "2.x", - "drupal/select2": "8.x-1.x", + "drupal/select2": "2.x", "drupal/ivw_integration": "8.x-2.x", "drupal/update_helper": "4.0.x", "thunder/thunder_testing_demo": "4.x" @@ -174,7 +174,8 @@ "dealerdirect/phpcodesniffer-composer-installer": true, "phpstan/extension-installer": true, "php-http/discovery": true, - "mglaman/composer-drupal-lenient": true + "mglaman/composer-drupal-lenient": true, + "tbachert/spi": true } } }