Skip to content

Commit

Permalink
Merge pull request #100 from palantirnet/multisite-support
Browse files Browse the repository at this point in the history
Multisite support
  • Loading branch information
becw authored Oct 16, 2018
2 parents 4b7eb52 + e5ad828 commit 4a1f93d
Show file tree
Hide file tree
Showing 26 changed files with 1,126 additions and 180 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Configure your build by editing `.the-build/build.default.properties.yml`. You c

* [Configuring the-build](docs/configuration.md)
* [Building an artifact](docs/artifacts.md)
* [Using Drupal multisites](docs/drupal_multisite.md)
* [Custom tasks provided by the-build](docs/tasks.md)

----
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"require": {
"continuousphp/phing-drush-task": "dev-master",
"drupal/coder": "~8.2.12",
"drush/drush": "^8.1.15",
"drush/drush": "^8.1.15@dev",
"pear/http_request2": "^2.3",
"pear/versioncontrol_git": "@dev",
"phing/phing": "^2.14",
Expand Down
157 changes: 103 additions & 54 deletions defaults.properties.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,51 +10,21 @@
#
# @copyright 2018 Palantir.net, Inc.

# Configuration for the-build.
build:
# The destination host, either 'acquia', 'pantheon', 'platformsh', or 'other'. This is
# currently only used when setting up the settings.php file for a Drupal site.
host: other

# Drupal configuration used by tasks/drupal.xml
drupal:
# Relative path to the Drupal web root. This is co-dependent with the composer installer
# configuration in your `composer.json`. Use caution when changing this value.
root: web

# Human-readable name for your site.
site_name: "${projectname}"

# Your site's URI; the default should be the URI of your local development environment.
uri: "https://${projectname}.local"

# Salt for Drupal's password hashing. A unique salt is generated when you install
# `the-build`.
hash_salt: temporary

# Drupal install profile to use for the drupal-install target.
profile: config_installer

# Name of the sites subdirectory where the `settings.php` file should live.
sites_subdir: default

# Path to the Drupal config directory, relative to the Drupal root.
config_sync_directory: "../config/sites/${drupal.sites_subdir}"

# Drupal admin username, if you feel inclined to change it.
admin_user: admin

# Comma-separated list of directories that should be present for Drupal development.
create_dirs: "${drupal.root}/modules/custom,${drupal.root}/themes/custom,${drupal.root}/profiles/custom"

# Database connection for Drupal.
database:
database: drupal
username: root
password: root
host: 127.0.0.1

settings:
# Path to the Drupal public files directory, relative to the Drupal root.
file_public_path: sites/default/files

# Path to the Drupal private files directory, relative to the Drupal root.
file_private_path: "../artifacts/private/${drupal.sites_subdir}"

twig:
# Whether to enable twig debugging.
debug: false
Expand All @@ -65,6 +35,90 @@ drupal:
# Use 'true' or 'yes' to bypass.
bypass: false

sites:
# Configuration values for a Drupal site build. The values in this section
# must be customized for each Drupal multisite installation that you add.
#
# This site configuration is partial; it will be completed in tasks/the-build.xml by
# loading any missing values from drupal.sites._defaults.
#
# To add a Drupal multisite installation, copy these default values into
# your project's .the-build/build.default.properties.yml file and change
# the 'default' key to the name of your new multisite. The key must not
# contain '.' characters, but the 'dir' property may.
default:
# REQUIRED: Name of the sites subdirectory where the `settings.php` file
# should live.
dir: default

# REQUIRED: Your site's URI; the default should be the URI of your local
# development environment.
uri: "https://${projectname}.local"

# Customizing the following values is OPTIONAL. If these values are not
# explicitly configured, they will be set in the-build.xml based on the
# 'dir' value configured above.
#
# NOTE: Properties may use other properties in their values, which are
# expanded when the property file is loaded. We can not use that behavior
# here because these values must reference a variable path: the 'default'
# key in the 'drupal.sites.*' properties.
#
# # Path to the Drupal config directory, relative to the Drupal root.
# config_sync_directory: "../config/sites/default"
#
# # Database connection for Drupal.
# database:
# database: drupal
#
# settings:
# # Path to the Drupal public files directory, relative to the Drupal root.
# file_public_path: sites/default/files
#
# # Path to the Drupal private files directory, relative to the Drupal root.
# file_private_path: "../artifacts/private/default"
#
# # Configuration used by the default 'build' target.
# build:
# # Destination for the templated settings.php file.
# settings_dest: ${drupal.root}/sites/default/settings.build.php
#
# # Destination for the templated `services.yml` file.
# services_dest: ${drupal.root}/sites/default/services.build.yml

# These values are used to fill in defaults for Drupal multisites that might
# not have everything defined. These may be set for specific multisites, or
# you may choose to override the defaults.
_defaults:
# Salt for Drupal's password hashing. A unique salt is generated when you install
# `the-build`.
hash_salt: temporary

# Drupal install profile to use for the drupal-install target.
profile: config_installer

# Drupal admin username, if you feel inclined to change it.
admin_user: admin

# Database connection for Drupal.
database:
# This value is required, but a default is set in the-build.xml.
# database: drupal
username: root
password: root
host: 127.0.0.1

# Configuration used by the default 'build' target.
build:
# Source template for Drupal's `settings.php` file. This may vary per build
# environment.
settings_template: .the-build/drupal.settings.build.php

# Source template for Drupal's `services.yml` file. This may vary per build
# environment.
services_template: .the-build/drupal.services.build.yml


# Configuration for the database loading utility.
load_db:
# Pattern to match gzipped database dump files.
Expand All @@ -85,24 +139,6 @@ drupal:
#file:


# Build configuration used by tasks/drupal.xml
build:
drupal:
# Source template for Drupal's `settings.php` file. This may vary per build
# environment.
settings: .the-build/drupal.settings.build.php

# Destination for the templated settings.php file.
settings_dest: "${drupal.root}/sites/${drupal.sites_subdir}/settings.build.php"

# Source template for Drupal's `services.yml` file. This may vary per build
# environment.
services: .the-build/drupal.services.build.yml

# Destination for the templated `services.yml` file.
services_dest: "${drupal.root}/sites/${drupal.sites_subdir}/services.build.yml"


# Configuration for tasks/artifact.xml
artifact:
# The path of the working directory where the artifact should be built.
Expand Down Expand Up @@ -199,3 +235,16 @@ phpmd:
rulesets: "${build.thebuild.dir}/defaults/config/phpmd.xml"
# File extensions to review.
suffixes: php,inc,module,theme,profile,install,test

# Configuration for running behat tests.
#
# Putting these flags in configuration allows you to vary the behat configuration per
# environment. Sometimes, there are tests that are appropriate to skip on CI. Compare
# these values to the defaults in build.circleci.properties.yml.
#
# Also consider:
# * Tagging tests based on where they should run (e.g. '@skipci')
# * Creating additional "profiles" in behat.yml for environments or multisites (see
# http://docs.behat.org/en/v2.5/guides/7.config.html#profiles)
behat:
args: "--suite=default --strict"
26 changes: 14 additions & 12 deletions defaults/config/drupal-skeleton/build.test.properties.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
# These properties are for running the Drupal Skeleton on circle.
drupal:
site_name: drupal-skeleton
uri: http://drupal-skeleton.local
hash_salt: temporary
root: web
profile: standard
database:
database: circle_test
username: ubuntu
password:
host: 127.0.0.1
settings:
file_public_path: sites/default/files
file_private_path:
sites:
default:
dir: default
uri: http://drupal-skeleton.local
hash_salt: temporary
profile: standard
database:
database: circle_test
username: ubuntu
password:
host: 127.0.0.1
settings:
file_public_path: sites/default/files
file_private_path:
twig:
debug: false
2 changes: 1 addition & 1 deletion defaults/templates/artifact.README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ${drupal.site_name} - Artifact Repository
# ${projectname} - Artifact Repository

This repository contains all of the code and configuration required to run this site. It
is intended for deployment to a host like Acquia or Pantheon.
4 changes: 2 additions & 2 deletions defaults/templates/drupal.settings.build-acquia.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
$settings['trusted_host_patterns'][] = "^{$_ENV['AH_SITE_ENVIRONMENT']}dev.prod.acquia-sites.com";
$settings['trusted_host_patterns'][] = "^{$_ENV['AH_SITE_ENVIRONMENT']}stg.prod.acquia-sites.com";

$settings['file_public_path'] = '${drupal.settings.file_public_path}';
$settings['file_public_path'] = '${drupal.site.settings.file_public_path}';
$settings['file_private_path'] = "/mnt/gfs/{$_ENV['AH_SITE_GROUP']}.{$_ENV['AH_SITE_ENVIRONMENT']}/files-private";
$config['system.file']['path']['temporary'] = $_ENV['TEMP'];

$config_directories = [];
$config_directories[CONFIG_SYNC_DIRECTORY] = '${drupal.config_sync_directory}';
$config_directories[CONFIG_SYNC_DIRECTORY] = '${drupal.site.config_sync_directory}';


//// Add an htaccess prompt on dev and staging environments.
Expand Down
2 changes: 1 addition & 1 deletion defaults/templates/drupal.settings.build-pantheon.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
*/

$config_directories = [];
$config_directories[CONFIG_SYNC_DIRECTORY] = '${drupal.config_sync_directory}';
$config_directories[CONFIG_SYNC_DIRECTORY] = '${drupal.site.config_sync_directory}';
16 changes: 8 additions & 8 deletions defaults/templates/drupal.settings.build.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@

$databases['default']['default'] = array(
'driver' => 'mysql',
'database' => '${drupal.database.database}',
'username' => '${drupal.database.username}',
'password' => '${drupal.database.password}',
'host' => '${drupal.database.host}',
'database' => '${drupal.site.database.database}',
'username' => '${drupal.site.database.username}',
'password' => '${drupal.site.database.password}',
'host' => '${drupal.site.database.host}',
'prefix' => '',
'collation' => 'utf8mb4_general_ci',
);

$config_directories = array();
$config_directories[CONFIG_SYNC_DIRECTORY] = '${drupal.config_sync_directory}';
$config_directories[CONFIG_SYNC_DIRECTORY] = '${drupal.site.config_sync_directory}';

$settings['hash_salt'] = '${drupal.hash_salt}';
$settings['hash_salt'] = '${drupal.site.hash_salt}';
$settings['container_yamls'][] = __DIR__ . '/services.build.yml';

$settings['file_public_path'] = '${drupal.settings.file_public_path}';
$settings['file_private_path'] = '${drupal.settings.file_private_path}';
$settings['file_public_path'] = '${drupal.site.settings.file_public_path}';
$settings['file_private_path'] = '${drupal.site.settings.file_private_path}';

// Disable CSS and JS aggregation.
$config['system.performance']['css']['preprocess'] = FALSE;
Expand Down
1 change: 0 additions & 1 deletion defaults/templates/drushrc.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

# Configure Drush for the current project.
$options['root'] = "{$repo}/${drupal.root}";
$options['uri'] = "${drupal.uri}";
}

/**
Expand Down
12 changes: 8 additions & 4 deletions defaults/templates/the-build/build.acquia.properties.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# @file
# Configuration properties specific to the Acquia deployment.
build:
drupal:
settings: .the-build/drupal.settings.build-acquia.php
services_dest: artifacts/dev/null
drupal:
twig:
debug: false
sites:
default:
build:
settings_template: .the-build/drupal.settings.build-acquia.php
services_dest: artifacts/dev/null
12 changes: 7 additions & 5 deletions defaults/templates/the-build/build.circleci.properties.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# @file
# Configuration properties specific to the CircleCI environment.
drupal:
database:
database: circle_test
username: root
password: ""
host: 127.0.0.1
twig:
debug: false
sites:
default:
database:
database: circle_test
username: root
password: ""
host: 127.0.0.1

behat:
args: "--profile=circle --suite=default --strict --format=junit --out=/tmp/artifacts --tags=~@skipci"
40 changes: 32 additions & 8 deletions defaults/templates/the-build/build.default.properties.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,44 @@
# Drupal site, and by some of the targets in the default build.xml file.
# @see .the-build/drupal.services.yml
# @see .the-build/drupal.settings.php
build:
host: ${build.host}

drupal:
root: "${drupal.root}"
hash_salt: "${drupal.hash_salt}"
profile: "${drupal.profile}"

database:
database: "${drupal.database.database}"
username: "${drupal.database.username}"
password: "${drupal.database.password}"
host: "${drupal.database.host}"

twig:
debug: true

sites:
default:
# REQUIRED: Name of the sites subdirectory where the `settings.php` file
# should live.
dir: default

# REQUIRED: Your site's URI; the default should be the URI of your local
# development environment.
uri: "${drupal.sites.default.uri}"

# OPTIONAL: Drupal hash salt defaults to "temporary".
hash_salt: "${drupal.sites.default.hash_salt}"

# OPTIONAL: The Drupal database name defaults to the site's "dir" value.
database:
database: "drupal"

# Add more multisites here.
# second:
# dir: second
# uri: "http://second.local"

# Defaults for all sites; these can be overridden for individual sites.
_defaults:
database:
username: "${drupal.sites._defaults.database.username}"
password: "${drupal.sites._defaults.database.password}"
host: "${drupal.sites._defaults.database.host}"

# Putting these flags in configuration allows you to vary the behat configuration per
# environment. Sometimes, there are tests that are appropriate to skip on CI. Compare
# these values to the defaults in build.circleci.properties.yml.
Expand Down
Loading

0 comments on commit 4a1f93d

Please sign in to comment.