Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GovCMS 10 Drupal 10 template #905

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
56 changes: 56 additions & 0 deletions project/drupal.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,59 @@ def platformify(self):
self.builddir) + self.composer_defaults(),
]


class Drupal10_govcms10(RemoteProject):
major_version = "3"
remote = 'https://github.com/govCMS/GovCMS.git'

def package_update_actions(self):
actions = super(Drupal10_govcms10, self).package_update_actions()
return [
'cd {0} && composer config -g allow-plugins.composer/installers true --no-plugins'.format(
self.builddir),
'cd {0} && composer config allow-plugins.composer/installers true --no-plugins'.format(
self.builddir),
'cd {0} && composer config allow-plugins.drupal/core-composer-scaffold true --no-plugins'.format(
self.builddir),
'cd {0} && composer config allow-plugins.drupal/core-project-message true --no-plugins'.format(
self.builddir),
'cd {0} && composer config allow-plugins.cweagans/composer-patches true --no-plugins '.format(
self.builddir),
] + actions

@property
def update(self):
projectName = "govcms10"

def drupal10_govcms10_modify_composer(composer):
"""
This change makes the template loadable via Composer (see https://github.com/platformsh-templates/drupal9/pull/33).
"""

composer['name'] = "platformsh/{0}".format(projectName)
composer[
'description'] = "This template builds the Australian government's GovCMS Drupal 10 distribution using the \"Drupal Recommended\" Composer project."

return composer

return super(Drupal10_govcms10, self).update + [
(self.modify_composer, [drupal10_govcms10_modify_composer])
]

@property
def update(self):
return super(Drupal10_govcms10, self).update + [
'cd {0} && rm -rf .circleci'.format(self.builddir),
'cd {0} && rm -rf .tugboat'.format(self.builddir),
'cd {0} && composer remove php {1}'.format(self.builddir,
self.composer_defaults().replace('--prefer-dist', '')),
]

@property
def platformify(self):
return super(Drupal10_govcms10, self).platformify + [
'cd {0} && composer require platformsh/config-reader drush/drush drupal/redis'.format(
self.builddir) + self.composer_defaults(),
# 'cd {0} && composer update -W'.format(self.builddir) + self.composer_defaults(),
# 'cd {0} && rm -rf web/profiles/govcms'.format(self.builddir),
]
30 changes: 30 additions & 0 deletions templates/drupal10-govcms10/.platform.template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: 1

info:
id: platformsh/drupal10-govcms10
name: GovCMS 10
description: |
<p>This template builds the Australian government's GovCMS Drupal 10 distribution using the Drupal Composer project for better flexibility. It is pre-configured to use MariaDB and Redis for caching. The Drupal installer will skip asking for database credentials as they are already provided.</p>
<p>GovCMS is a Drupal distribution built for the Australian government, and includes configuration optimized for managing government websites.</p>
class: starter
tags:
- PHP
- Drupal
- CMS
- Symfony
image: data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='199.37' height='225'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%232ba9e0%7D%3C/style%3E%3C/defs%3E%3Cg %3E%3Cg %3E%3Cpath class='cls-1' d='M93.78 139.31a35.5 35.5 0 1 0 35.5 35.5 35.51 35.51 0 0 0-35.5-35.5zM138 132.51a61.17 61.17 0 0 1-9.26 92.49c29.31-9 53.56-31.06 64.4-57.73 15-36.92 1-64.67-22.43-89.87a45.68 45.68 0 0 1 1.15 10.11 46.88 46.88 0 0 1-33.86 45zM97.82 87.57A27.19 27.19 0 1 0 125 60.43a27.16 27.16 0 0 0-27.18 27.14z'/%3E%3Cpath class='cls-1' d='M47 214.22a61.17 61.17 0 0 1 39.55-100.1 46.82 46.82 0 0 1 44.75-72.89C116 28 100.72 14.62 88.66 0c6.13 64.13-58.4 40.82-82.32 100C-9.62 139.58 4.79 188.56 47 214.22z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E
notes:
- heading: "Features"
content: |
PHP 8.3<br />
MariaDB 10.11<br />
Redis 7.2<br />
Drush included<br />
Automatic TLS certificates<br />
Composer-based build<br />

initialize:
repository: https://github.com/platformsh-templates/drupal10-govcms10.git@master
config: null
files: []
profile: GovCMS 10
49 changes: 49 additions & 0 deletions templates/drupal10-govcms10/files/.ahoy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
ahoyapi: v2

commands:
up:
usage: Build project.
cmd: |
docker compose up -d "$@"

down:
usage: Delete project.
cmd: docker compose down

build:
usage: Build project.
cmd: |
docker compose build "$@"

restart:
usage: Restart Docker containers.
cmd: docker compose restart

stop:
usage: Stop Docker containers.
cmd: docker compose stop "$@"

watch:
usage: Use Compose Watch for live development.
cmd: docker compose watch

cli:
usage: Start a shell.
cmd: docker compose exec govcms bash

composer:
usage: Start a composer command.
cmd: docker compose exec govcms composer "$@"

rector:
usage: Analyze your code with Rector and review suggested changes.
cmd: docker compose exec govcms rector "$@"

phpunit:
usage: Run PHPUnit tests.
cmd: docker compose exec govcms sudo -u root -E sudo -u www-data -E /app/bin/phpunit "$@"

drupal-check:
usage: Static analysis tool to check for correctness and deprecation errors.
cmd: docker compose exec govcms drupal-check "$@"
81 changes: 81 additions & 0 deletions templates/drupal10-govcms10/files/.blackfire.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
tests:
'The homepage should be fast':
path:
- '/'
assertions:
- 'main.wall_time <= 250ms'
'Some Composer dependencies have known security issues and should be upgraded':
path:
- '/.*'
assertions:
- { expression: 'not has_vulnerable_dependencies()' }
'"assert.active" is a dev_only feature and should be disabled in production':
path:
- '/.*'
assertions:
- { expression: 'runtime.configuration.assert_active === false' }
'"display_errors" should be disabled':
path:
- '/.*'
assertions:
- { expression: 'not is_configuration_enabled("display_errors")' }
'"display_startup_errors" should not be enabled':
path:
- '/.*'
assertions:
- { expression: 'not is_configuration_enabled("display_startup_errors")' }
'"max_execution_time" should be less than 30 seconds for Web requests':
path:
- '/.*'
assertions:
- { expression: 'runtime.configuration.max_execution_time <= 30' }
'"session.use_strict_mode" should be enabled':
path:
- '/.*'
assertions:
- { expression: 'runtime.configuration.session_use_strict_mode === true' }
'"zend.detect_unicode" should be disabled as BOMs are not portable':
path:
- '/.*'
assertions:
- { expression: 'runtime.configuration.zend_detect_unicode === false' }
'The realpath cache ttl should be more than one hour in production':
path:
- '/.*'
assertions:
- { expression: 'runtime.configuration.realpath_cache_ttl >= 3600' }
'The session garbage collector should be disabled in production':
path:
- '/.*'
assertions:
- { expression: 'runtime.configuration.session_gc_probability === 0' }

scenarios: |
#!blackfire-player

name "Drupal Scenarios"

group homepages
visit url("/")
name "Homepage (English)"
expect status_code() == 200
visit url("/es")
name "Homepage (Español)"
expect status_code() == 200

group articles
visit url("/en/articles")
name "Articles"
expect status_code() == 200

group admin_anonymous
visit url("/en/admin/content")
expect status_code() == 403
visit url("/en/admin/structure")
expect status_code() == 403

scenario
name "Anonymous Visit"
include homepages
include articles
include admin_anonymous
63 changes: 63 additions & 0 deletions templates/drupal10-govcms10/files/.docker/Dockerfile.govcms
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Stage 1: Build the application
FROM drupal:10-php8.1 as builder

# Set timezone to Australia/Sydney by default
RUN ln -sf /usr/share/zoneinfo/Australia/Sydney /etc/localtime

# Install required packages and PHP extensions
RUN \
--mount=type=cache,target=/var/cache/apt \
apt-get update && \
apt-get install -y --no-install-recommends libicu-dev sqlite3 mariadb-client git unzip rsync sudo && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
docker-php-ext-configure intl && \
docker-php-ext-install intl

# Configure PHP settings
RUN echo "memory_limit = 512M" >> /usr/local/etc/php/conf.d/docker-php-ram-limit.ini && \
echo "upload_max_filesize = 100M" >> /usr/local/etc/php/conf.d/docker-php-upload-limit.ini && \
echo "post_max_size = 100M" >> /usr/local/etc/php/conf.d/docker-php-upload-limit.ini

# Set Composer environment variables
ENV COMPOSER_ALLOW_SUPERUSER=1
ENV COMPOSER_MEMORY_LIMIT=-1
ENV SIMPLETEST_BASE_URL="http://govcms"
ENV SIMPLETEST_DB='mysql://drupal:drupal@mariadb/drupal'

# Set working directory
WORKDIR /app

# Copy only the necessary files for dependency installation
COPY composer.json ./

# Install Composer dependencies
RUN \
--mount=type=cache,mode=0777,target=/root/.composer/cache \
composer require palantirnet/drupal-rector mglaman/drupal-check --dev --no-update && \
composer update --no-scripts --no-autoloader && \
cp vendor/palantirnet/drupal-rector/rector.php .

# Create a symbolic link
RUN rm -rf /opt/drupal && \
ln -sf /app/web /var/www/html

# Stage 2: Final application image
FROM builder as site

# Set the working directory
WORKDIR /app

# Copy the rest of the application files
COPY . /app/

# Configure Composer
RUN \
--mount=type=cache,mode=0777,target=/root/.composer/cache \
composer install

# Adjust ownership
RUN chown -R www-data:www-data web/sites web/modules web/themes

# Set the PATH environment variable
ENV PATH=${PATH}:/app/bin
29 changes: 29 additions & 0 deletions templates/drupal10-govcms10/files/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.ahoy.yml
.circleci
.docker
.dockerignore
.DS_Store
.editorconfig
.env
.git
.gitattributes
.github
.gitignore
.idea
.tugboat
DEVELOPMENT.md
CHANGELOG.txt
CONTRIBUTING.md
LICENSE.txt
README.md
SECURITY.md
VERSIONS.md
app
bin
build
composer.lock
docker-compose.yml
sites
tests
vendor
web
11 changes: 11 additions & 0 deletions templates/drupal10-govcms10/files/.environment
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Statements in this file will be executed (sourced) by the shell in SSH
# sessions, in deploy hooks, in cron jobs, and in the application's runtime
# environment. This file must be placed in the root of the application, not
# necessarily the git repository's root. In case of multiple applications,
# each application can have its own .environment file.

# Allow executable app dependencies from Composer to be run from the path.
if [ -n "$PLATFORM_APP_DIR" -a -f "$PLATFORM_APP_DIR"/composer.json ] ; then
bin=$(composer config bin-dir --working-dir="$PLATFORM_APP_DIR" --no-interaction 2>/dev/null)
export PATH="${PLATFORM_APP_DIR}/${bin:-vendor/bin}:${PATH}"
fi
Loading