Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 25 additions & 12 deletions .ddev/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,39 @@ name: DrupalPod
type: drupal
docroot: web
php_version: "8.3"
webserver_type: nginx-fpm
webserver_type: apache-fpm
xdebug_enabled: false
additional_hostnames: []
additional_fqdns: []
database:
type: mariadb
version: "10.6"
version: "10.11"
use_dns_when_possible: true
composer_version: "2"
web_environment: []
web_environment:
- APP_ROOT=$DDEV_COMPOSER_ROOT
- WEB_ROOT=$DDEV_COMPOSER_ROOT/$DDEV_DOCROOT
- DB_HOST=db
- DB_PORT=3306
- DB_USER=db
- DB_PASSWORD=db
- DB_NAME=db
- DP_APP_ID=drupalpod
- DB_DRIVER=mysql
corepack_enable: false

# Key features of DDEV's config.yaml:

# name: <projectname> # Name of the project, automatically provides
# http://projectname.ddev.site and https://projectname.ddev.site

# type: <projecttype> # backdrop, craftcms, django4, drupal, drupal6, drupal7, laravel, magento, magento2, php, python, shopware6, silverstripe, typo3, wordpress
# type: <projecttype> # backdrop, cakephp, craftcms, drupal, drupal6, drupal7, drupal8, drupal9, drupal10, drupal11, generic, laravel, magento, magento2, php, shopware6, silverstripe, symfony, typo3, wordpress
# See https://ddev.readthedocs.io/en/stable/users/quickstart/ for more
# information on the different project types
# "drupal" covers recent Drupal 8+

# docroot: <relative_path> # Relative path to the directory containing index.php.

# php_version: "8.2" # PHP version to use, "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3", "8.4"
# php_version: "8.3" # PHP version to use, "5.6" through "8.4"

# You can explicitly specify the webimage but this
# is not recommended, as the images are often closely tied to DDEV's' behavior,
Expand All @@ -39,7 +47,7 @@ corepack_enable: false
# version: <version> # database version, like "10.11" or "8.0"
# MariaDB versions can be 5.5-10.8, 10.11, and 11.4.
# MySQL versions can be 5.5-8.0.
# PostgreSQL versions can be 9-16.
# PostgreSQL versions can be 9-17.

# router_http_port: <port> # Port to be used for http (defaults to global configuration, usually 80)
# router_https_port: <port> # Port for https (defaults to global configuration, usually 443)
Expand All @@ -54,9 +62,11 @@ corepack_enable: false
# "ddev xhprof" to enable Xhprof and "ddev xhprof off" to disable it work better,
# as leaving Xhprof enabled all the time is a big performance hit.

# webserver_type: nginx-fpm, apache-fpm, or nginx-gunicorn
# webserver_type: nginx-fpm, apache-fpm, generic

# timezone: Europe/Berlin
# If timezone is unset, DDEV will attempt to derive it from the host system timezone
# using the $TZ environment variable or the /etc/localtime symlink.
# This is the timezone used in the containers and by PHP;
# it can be set to any valid timezone,
# see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
Expand All @@ -76,9 +86,9 @@ corepack_enable: false
# - preview
# - snapshot
# Alternatively, an explicit Composer version may be specified, for example "2.2.18".
# To reinstall Composer after the image was built, run "ddev debug refresh".
# To reinstall Composer after the image was built, run "ddev debug rebuild".

# nodejs_version: "20"
# nodejs_version: "22"
# change from the default system Node.js version to any other version.
# See https://ddev.readthedocs.io/en/stable/users/configuration/config/#nodejs_version for more information
# and https://www.npmjs.com/package/n#specifying-nodejs-versions for the full documentation,
Expand All @@ -88,6 +98,9 @@ corepack_enable: false
# corepack_enable: false
# Change to 'true' to 'corepack enable' and gain access to latest versions of yarn/pnpm

# corepack_enable: false
# Change to 'true' to 'corepack enable' and gain access to latest versions of yarn/pnpm

# additional_hostnames:
# - somename
# - someothername
Expand Down Expand Up @@ -204,8 +217,8 @@ corepack_enable: false

# You can inject environment variables into the web container with:
# web_environment:
# - SOMEENV=somevalue
# - SOMEOTHERENV=someothervalue
# - SOMEENV=somevalue
# - SOMEOTHERENV=someothervalue

# no_project_mount: false
# (Experimental) If true, DDEV will not mount the project into the web container;
Expand Down
5 changes: 5 additions & 0 deletions .devpanel/cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -eu -o pipefail

# Remove composer.json. A fresh one will be generated.
rm -f "${APP_ROOT}"/composer.json
53 changes: 53 additions & 0 deletions .devpanel/composer_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env bash
set -eu -o pipefail
cd $APP_ROOT

# For versions end with x - add `-dev` suffix (ie. 9.3.x-dev)
# For versions without x - add `~` prefix (ie. ~9.2.0)
d="$DP_CORE_VERSION"
case $d in
*.x)
install_version="$d"-dev
;;
*)
install_version=~"$d"
;;
esac

if [ ! -f composer.json ]; then
# Create required composer.json and composer.lock files
time composer create-project -n --no-install drupal/recommended-project:"$install_version" temp-composer-files
cp "$APP_ROOT"/temp-composer-files/* "$APP_ROOT"/.
rm -rf "$APP_ROOT"/temp-composer-files
fi

# Programmatically fix Composer 2.2 allow-plugins to avoid errors
composer config --no-plugins allow-plugins.composer/installers true
composer config --no-plugins allow-plugins.drupal/core-project-message true
composer config --no-plugins allow-plugins.drupal/core-vendor-hardening true
composer config --no-plugins allow-plugins.drupal/core-composer-scaffold true
composer config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
composer config --no-plugins allow-plugins.phpstan/extension-installer true
composer config --no-plugins allow-plugins.mglaman/composer-drupal-lenient true
composer config --no-plugins allow-plugins.php-http/discovery true
composer config --no-plugins allow-plugins.tbachert/spi false

# Add project source code as symlink (to repos/name_of_project)
# double quotes explained - https://stackoverflow.com/a/1250279/5754049
if [ -n "$DP_PROJECT_NAME" ]; then
composer --no-plugins config \
repositories.core1 \
'{"type": "path", "url": "repos/'"$DP_PROJECT_NAME"'", "options": {"symlink": true}}'

composer --no-plugins config minimum-stability dev
fi

# Scaffold settings.php.
composer config -jm extra.drupal-scaffold.file-mapping '{
"[web-root]/sites/default/settings.php": {
"path": "web/core/assets/scaffold/files/default.settings.php",
"overwrite": false
}
}'
composer config scripts.post-drupal-scaffold-cmd \
'cd web/sites/default && test -z "$(grep '\''include \$devpanel_settings;'\'' settings.php)" && patch -Np1 -r /dev/null < $APP_ROOT/.devpanel/drupal-settings.patch || :'
34 changes: 34 additions & 0 deletions .devpanel/contrib_modules_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
set -eu -o pipefail

# Check if additional modules should be installed
export DEVEL_NAME="devel"
export DEVEL_PACKAGE="drupal/devel"

export ADMIN_TOOLBAR_NAME="admin_toolbar_tools"
export ADMIN_TOOLBAR_PACKAGE="drupal/admin_toolbar"

# TODO: once Drupalpod extension supports additional modules - remove these 2 lines
export DP_EXTRA_DEVEL=1
export DP_EXTRA_ADMIN_TOOLBAR=1

# Adding support for composer-drupal-lenient - https://packagist.org/packages/mglaman/composer-drupal-lenient
if [[ "$DP_CORE_VERSION" =~ ^10(\..*)?$ ]]; then
if [ "$DP_PROJECT_TYPE" != "project_core" ]; then
export COMPOSER_DRUPAL_LENIENT=mglaman/composer-drupal-lenient
else
export COMPOSER_DRUPAL_LENIENT=''
fi
fi

# Adding support for composer-drupal-lenient - https://packagist.org/packages/mglaman/composer-drupal-lenient
if [[ "$DP_CORE_VERSION" =~ ^11(\..*)?$ ]]; then
# admin_toolbar and devel are not compatible yet with Drupal 11
export DP_EXTRA_ADMIN_TOOLBAR=
export DP_EXTRA_DEVEL=
if [ "$DP_PROJECT_TYPE" != "project_core" ]; then
export COMPOSER_DRUPAL_LENIENT=mglaman/composer-drupal-lenient
else
export COMPOSER_DRUPAL_LENIENT=''
fi
fi
45 changes: 45 additions & 0 deletions .devpanel/create_quickstart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash
# ---------------------------------------------------------------------
# Copyright (C) 2024 DevPanel
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation version 3 of the
# License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# For GNU Affero General Public License see <https://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------

echo -e "-------------------------------"
echo -e "| DevPanel Quickstart Creator |"
echo -e "-------------------------------\n"


# Preparing
WORK_DIR=$APP_ROOT
TMP_DIR=/tmp/devpanel/quickstart
DUMPS_DIR=$TMP_DIR/dumps
STATIC_FILES_DIR=$WEB_ROOT/sites/default/files

mkdir -p $DUMPS_DIR

# Step 1 - Compress drupal database
cd $WORK_DIR
echo -e "> Export database to $APP_ROOT/.devpanel/dumps"
mkdir -p $APP_ROOT/.devpanel/dumps
drush cr --quiet
drush sql-dump --result-file=../.devpanel/dumps/db.sql --gzip --extra-dump=--no-tablespaces

# Step 2 - Compress static files
cd $WORK_DIR
echo -e "> Compress static files"
tar czf $DUMPS_DIR/files.tgz -C $STATIC_FILES_DIR .

echo -e "> Store files.tgz to $APP_ROOT/.devpanel/dumps"
mkdir -p $APP_ROOT/.devpanel/dumps
mv $DUMPS_DIR/files.tgz $APP_ROOT/.devpanel/dumps/files.tgz
44 changes: 44 additions & 0 deletions .devpanel/custom_package_installer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash
# ---------------------------------------------------------------------
# Copyright (C) 2024 DevPanel
# You can install any service here to support your project
# Please make sure you run apt update before install any packages
# Example:
# - sudo apt-get update
# - sudo apt-get install nano
#
# ----------------------------------------------------------------------
if [ -n "$DEBUG_SCRIPT" ]; then
set -x
fi

# Install APT packages.
if ! command -v npm >/dev/null 2>&1; then
sudo apt-get update
sudo apt-get install -y jq nano npm
fi

# Enable AVIF support in GD extension if not already enabled.
if [ -z "$(php --ri gd | grep AVIF)" ]; then
sudo apt-get install -y libavif-dev
sudo docker-php-ext-configure gd --with-avif --with-freetype --with-jpeg --with-webp
sudo docker-php-ext-install gd
fi

PECL_UPDATED=false
# Install APCU extension. Bypass question about enabling internal debugging.
if ! php --ri apcu > /dev/null 2>&1; then
$PECL_UPDATED || sudo pecl update-channels && PECL_UPDATED=true
sudo pecl install apcu <<< ''
echo 'extension=apcu.so' | sudo tee /usr/local/etc/php/conf.d/apcu.ini
fi
# Install uploadprogress extension.
if ! php --ri uploadprogress > /dev/null 2>&1; then
$PECL_UPDATED || sudo pecl update-channels && PECL_UPDATED=true
sudo pecl install uploadprogress
echo 'extension=uploadprogress.so' | sudo tee /usr/local/etc/php/conf.d/uploadprogress.ini
fi
# Reload Apache if it's running.
if $PECL_UPDATED && sudo /etc/init.d/apache2 status > /dev/null; then
sudo /etc/init.d/apache2 reload
fi
19 changes: 19 additions & 0 deletions .devpanel/drupal-settings.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
diff --git a/settings.php b/settings.php
index e121075454f..9b0d970f3e8 100644
--- a/settings.php
+++ b/settings.php
@@ -854,6 +854,14 @@
# $settings['migrate_file_public_path'] = '';
# $settings['migrate_file_private_path'] = '';

+/**
+ * Load DevPanel override configuration, if available.
+ */
+$devpanel_settings = dirname($app_root) . '/.devpanel/settings.devpanel.php';
+if (getenv('DP_APP_ID') !== FALSE && file_exists($devpanel_settings)) {
+ include $devpanel_settings;
+}
+
/**
* Load local development override configuration, if available.
*
29 changes: 29 additions & 0 deletions .devpanel/drupal_setup_contrib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -eu -o pipefail
cd "${APP_ROOT}"

# Drupal projects with no composer.json, bypass the symlink config, symlink has to be created manually.

if [ "$DP_PROJECT_TYPE" == "project_module" ]; then
PROJECT_TYPE=modules
elif [ "$DP_PROJECT_TYPE" == "project_theme" ]; then
PROJECT_TYPE=themes
fi

cat <<PROJECTASYMLINK >"${APP_ROOT}"/repos/add-project-as-symlink.sh
#!/usr/bin/env bash
# This file was dynamically generated by a script
echo "Replace project with a symlink"
rm -rf web/$PROJECT_TYPE/contrib/$DP_PROJECT_NAME
cd web/$PROJECT_TYPE/contrib && ln -s ../../../repos/$DP_PROJECT_NAME .
PROJECTASYMLINK

chmod +x "${APP_ROOT}"/repos/add-project-as-symlink.sh

if [ -n "$COMPOSER_DRUPAL_LENIENT" ]; then
# Add composer_drupal_lenient for modules on Drupal 10
composer config --no-plugins --merge --json extra.drupal-lenient.allowed-list '["drupal/'"$DP_PROJECT_NAME"'"]'
time composer require "$COMPOSER_DRUPAL_LENIENT"
fi
# Add the project to composer (it will get the version according to the branch under `/repo/name_of_project`)
time composer require drupal/"$DP_PROJECT_NAME" --no-interaction --no-install
41 changes: 41 additions & 0 deletions .devpanel/drupal_setup_core.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
set -eu -o pipefail
cd "${APP_ROOT}"

# Add a special path when working on core contributions
# (Without it, /web/modules/contrib is not found by website)
composer config --no-plugins repositories.drupal-core2 '{"type": "path", "url": "repos/drupal/core"}'
composer config --no-plugins repositories.drupal-core3 '{"type": "path", "url": "repos/drupal/composer/Metapackage/CoreRecommended"}'
composer config --no-plugins repositories.drupal-core4 '{"type": "path", "url": "repos/drupal/composer/Metapackage/DevDependencies"}'
composer config --no-plugins repositories.drupal-core5 '{"type": "path", "url": "repos/drupal/composer/Plugin/ProjectMessage"}'
composer config --no-plugins repositories.drupal-core6 '{"type": "path", "url": "repos/drupal/composer/Plugin/VendorHardening"}'

# Removing the conflict part of composer
echo "$(cat composer.json | jq 'del(.conflict)' --indent 4)" >composer.json

# If a core issue branch was chosen, we want the version of Drupal core that is in that issue branch
# This is very helpful for issues that started with previous Drupal core versions, and the issue version automatically got updated to latest current drupal version
if [ "$DP_PROJECT_TYPE" == "project_core" ] && [ -n "$DP_ISSUE_BRANCH" ]; then
time composer require drupal/core-recommended:* drupal/core-project-message:* drupal/core-composer-scaffold:* --no-update
fi

# Only after composer update, /web/core get symlinked to /repos/drupal/core
# repos/drupal/core -> web/core
time composer update --no-plugins --no-install

# vendor -> repos/drupal/vendor
if [ ! -L "$APP_ROOT"/repos/drupal/vendor ]; then
cd "$APP_ROOT"/repos/drupal &&
ln -s ../../vendor .
fi

# Create folders for running tests
mkdir -p "$APP_ROOT"/web/sites/simpletest
mkdir -p "$APP_ROOT"/web/sites/simpletest/browser_output

# Symlink the simpletest folder into the Drupal core git repo.
# repos/drupal/sites/simpletest -> ../../../web/sites/simpletest
if [ ! -L "$APP_ROOT"/repos/drupal/sites/simpletest ]; then
cd "$APP_ROOT"/repos/drupal/sites &&
ln -s ../../../web/sites/simpletest .
fi
10 changes: 10 additions & 0 deletions .devpanel/fallback_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -eu -o pipefail

# Set a default setup (when project type is not specified)
export DP_INSTALL_PROFILE='demo_umami'
export DP_PROJECT_TYPE='project_core'
export DP_PROJECT_NAME="drupal"
export DP_CORE_VERSION=${DP_CORE_VERSION:='11.2.5'}
export DP_EXTRA_DEVEL=1
export DP_EXTRA_ADMIN_TOOLBAR=1
Loading
Loading