From dec7440eec469b47dbc69d37b04ebb8c60870989 Mon Sep 17 00:00:00 2001 From: navneet0693 Date: Fri, 19 Nov 2021 19:19:13 +0530 Subject: [PATCH] Upgrade to use Drupal 9.1 1. Added a new folder which will serve the purpose of doing D9 readiness development leaving the regular docker machines as it is. 2. Added composer.json similar to goalgorilla/drupal_social#362 3. Extends image from Drupal 9.1 4. Changed the way composer install command runs. --- d9/Dockerfile | 101 ++++++++++++++++++++++++++++ d9/composer.json | 138 ++++++++++++++++++++++++++++++++++++++ d9/mailcatcher-msmtp.conf | 5 ++ d9/php.ini | 16 +++++ 4 files changed, 260 insertions(+) create mode 100644 d9/Dockerfile create mode 100644 d9/composer.json create mode 100644 d9/mailcatcher-msmtp.conf create mode 100644 d9/php.ini diff --git a/d9/Dockerfile b/d9/Dockerfile new file mode 100644 index 0000000..e78ef94 --- /dev/null +++ b/d9/Dockerfile @@ -0,0 +1,101 @@ +FROM drupal:9.1 +MAINTAINER devel@goalgorilla.com + +# Specify the work directory. +WORKDIR /var/www/ + +# Install packages. +RUN apt-get update && apt-get install -y \ + zlib1g-dev \ + mariadb-client \ + git \ + msmtp \ + libzip-dev \ + nano \ + vim && \ + apt-get clean + +ADD mailcatcher-msmtp.conf /etc/msmtprc + +RUN echo 'sendmail_path = "/usr/bin/msmtp -t"' > /usr/local/etc/php/conf.d/mail.ini + +ADD php.ini /usr/local/etc/php/php.ini + +# Install extensions +RUN docker-php-ext-install zip bcmath exif + +# Install Composer. +RUN curl -sS https://getcomposer.org/installer | php +RUN mv composer.phar /usr/local/bin/composer + +# Install Open Social via composer. +RUN rm -f /var/www/composer.lock +RUN rm -rf /root/.composer + +ADD composer.json /var/www/composer.json +WORKDIR /var/www/ +ENV COMPOSER_ALLOW_SUPERUSER=1 +RUN COMPOSER_MEMORY_LIMIT=-1 composer install + +WORKDIR /var/www/html/ +RUN chown -R www-data:www-data * + +# Unfortunately, adding the composer vendor dir to the PATH doesn't seem to work. So: +RUN ln -s /var/www/vendor/bin/drush /usr/local/bin/drush + +RUN php -r 'opcache_reset();' + +# Fix shell. +RUN echo "export TERM=xterm" >> ~/.bashrc + +# Install composer dependencies. +RUN composer install --prefer-dist --no-interaction + +# Unfortunately, adding the composer vendor dir to the PATH doesn't seem to work. So: +RUN ln -s /root/.composer/vendor/bin/behat /usr/local/bin/behat +RUN ln -s /root/.composer/vendor/bin/phpunit /usr/local/bin/phpunit +RUN ln -s /var/www/vendor/bin/drupal /usr/local/bin/drupal + +### CI SPECIFIC - END ### + +### DEV SPECIFIC - START ### + +ADD php.ini /usr/local/etc/php/php.ini + +# GMP library. +RUN apt-get install -y libgmp-dev +RUN ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/local/include/ +RUN docker-php-ext-configure gmp +RUN docker-php-ext-install gmp + +# Xdebug. +RUN pecl install xdebug-3.1.1 && \ + docker-php-ext-enable xdebug && \ + sed -i '1 a xdebug.client_port=9003' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \ + sed -i '1 a xdebug.mode=debug' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \ + sed -i '1 a xdebug.start_with_request=yes' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \ + sed -i '1 a xdebug.discover_client_host=true' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \ + sed -i '1 a xdebug.idekey=PHPSTORMi' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini + +# Blackfire +RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \ + && curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$version \ + && mkdir -p /tmp/blackfire \ + && tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \ + && mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so \ + && printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8707\n" > $PHP_INI_DIR/conf.d/blackfire.ini \ + && rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz + +RUN php -r "opcache_reset();" + +# Contains the Mac hack to get the permissions to work for development. +# Set user 1000 and group staff to www-data, enables write permission. +# https://github.com/boot2docker/boot2docker/issues/581#issuecomment-114804894 +RUN usermod -u 1000 www-data +RUN usermod -G staff www-data + +### DEV SPECIFIC - END ### + +# Redis. +RUN pecl install redis \ + && docker-php-ext-enable redis diff --git a/d9/composer.json b/d9/composer.json new file mode 100644 index 0000000..5ded5f6 --- /dev/null +++ b/d9/composer.json @@ -0,0 +1,138 @@ +{ + "name": "goalgorilla/social_docker", + "description": "Social docker template for composer based Open Social projects.", + "type": "project", + "license": "GPL-2.0-or-later", + "minimum-stability": "dev", + "prefer-stable": true, + "config": { + "optimize-autoloader": true, + "update-with-dependencies": true, + "sort-packages": true + }, + "require": { + "drush/drush": "10.*@stable", + "goalgorilla/open_social": "dev-feature/3162491-group-update-d9", + "goalgorilla/open_social_scripts": "^2.0", + "drupal/redis": "^1.5", + "blackfire/php-sdk": "^v1.27.1" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "~0.7.1", + "drupal/coder": "8.3.13", + "drupal/composer_deploy": "^1.6", + "drupal/core-dev": "~9.1.0", + "drupal/devel": "^4.1", + "drupal/drupal-extension": "^4.1", + "drupal/upgrade_status": "^3.11", + "jcalderonzumba/gastonjs": "~1.2.0", + "jcalderonzumba/mink-phantomjs-driver": "~0.3.3", + "mglaman/phpstan-drupal": "^1.0", + "mikey179/vfsstream": "^1.6", + "palantirnet/drupal-rector": "3248684.x-dev", + "phpmd/phpmd": "^2.10", + "phpspec/prophecy-phpunit": "^2.0", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan-deprecation-rules": "^1.0", + "slevomat/coding-standard": "^7.0", + "squizlabs/html_codesniffer": "*", + "symplify/easy-coding-standard": "^9.4" + }, + "autoload": { + "psr-4": { + "Drupal\\socialblue\\": "html/profiles/contrib/social/themes/socialblue/src", + "Drupal\\socialbase\\": "html/profiles/contrib/social/themes/socialbase/src", + "Drupal\\bootstrap\\": "html/themes/contrib/bootstrap/src" + } + }, + "repositories": { + "0": { + "type": "composer", + "url": "https://packages.drupal.org/8", + "exclude": ["goalgorilla/open_social", "drupal/social"] + }, + "1": { + "type": "composer", + "url": "https://asset-packagist.org" + }, + "2": { + "type": "package", + "package": { + "name": "squizlabs/html_codesniffer", + "version": "2.5.1", + "source": { + "url": "https://github.com/squizlabs/HTML_CodeSniffer.git", + "type": "git", + "reference": "master" + } + } + }, + "3": { + "type": "git", + "url": "https://github.com/goalgorilla/open_social.git", + "only": ["goalgorilla/open_social", "drupal/social"] + }, + "4": { + "type": "vcs", + "url": "https://github.com/bluehorndigital/drupal-rector.git", + "only": ["palantirnet/drupal-rector"] + } + }, + "scripts": { + "refresh": [ + "rm -rf composer.lock vendor html/core html/modules/contrib html/profiles/contrib html/themes/contrib", + "@composer update -W --ansi" + ] + }, + "extra": { + "installer-types": [ + "bower-asset", + "npm-asset" + ], + "installer-paths": { + "html/core": [ + "drupal/core" + ], + "html/modules/contrib/{$name}": [ + "type:drupal-module" + ], + "html/profiles/contrib/social": [ + "goalgorilla/open_social" + ], + "html/profiles/contrib/{$name}": [ + "type:drupal-profile" + ], + "html/themes/contrib/{$name}": [ + "type:drupal-theme" + ], + "html/libraries/{$name}": [ + "type:drupal-library", + "type:bower-asset", + "type:npm-asset" + ], + "scripts/{$name}": [ + "goalgorilla/open_social_scripts" + ], + "drush/contrib/{$name}": [ + "type:drupal-drush" + ] + }, + "enable-patching": true, + "patchLevel": { + "drupal/core": "-p2" + }, + "drupal-scaffold": { + "locations": { + "web-root": "html/" + } + }, + "patches": { + "drupal/like_dislike": { + "Add support for webprofiler": "patches/like-dislike-fix-webprofiler.patch" + }, + "squizlabs/html_codesniffer": { + "Translatings does not work": "patches/DS-5443-accessibility.patch" + } + } + } +} diff --git a/d9/mailcatcher-msmtp.conf b/d9/mailcatcher-msmtp.conf new file mode 100644 index 0000000..0ec1159 --- /dev/null +++ b/d9/mailcatcher-msmtp.conf @@ -0,0 +1,5 @@ +account mailcatcher +host mailcatcher +port 1025 +auto_from on +account default: mailcatcher diff --git a/d9/php.ini b/d9/php.ini new file mode 100644 index 0000000..2436f28 --- /dev/null +++ b/d9/php.ini @@ -0,0 +1,16 @@ +[PHP] +; Prod settings -- see ../prod/php.ini +date.timezone = UTC +zend.assertions = 0 +upload_max_filesize = 24M +post_max_size = 32M +file_uploads = On + +; CI settings - see ../ci/php.ini +; TODO Change memory_limit to prod value. +memory_limit = 1024M +max_execution_time = 0 + +; Dev settings +xdebug.max_nesting_level = 500 +opcache.enable = 0