Skip to content

Refactor deployment #159

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

Merged
merged 23 commits into from
Mar 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
  •  
  •  
  •  
11 changes: 11 additions & 0 deletions .bp-config/options.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"COMPOSER_INSTALL_OPTIONS": [
"--no-dev --optimize-autoloader --no-progress --no-interaction"
],
"COMPOSER_VENDOR_DIR": "vendor",
"WEBDIR": "web",
"PHP_EXTENSIONS": ["bz2", "zlib", "curl", "mcrypt", "gd", "pdo", "pdo_mysql", "mbstring"],
"ADDITIONAL_PREPROCESS_CMDS": [
"$HOME/bootstrap.sh"
]
}
3 changes: 3 additions & 0 deletions .bp-config/php/php.ini.d/memory_limit.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 512M
29 changes: 29 additions & 0 deletions .cfignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Ignore directories generated by Composer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For later: there's a deployment consideration here -- we could include these dirs in the cf deployment (i.e. vendor our dependencies). That'd ensure consistency and slightly speed up restages at the cost of high likelihood of error (e.g. sending up something compiled for OSX).

/drush/contrib/
/vendor/
/web/core/
/web/modules/contrib/
/web/themes/contrib/
/web/profiles/contrib/
/web/libraries/

# Typically, composer generates a .gitignore to ignore the
# `settings.php` files. For cloud.gov and Cloud Foundry, no sensitive
# information is stored in the settings files. Instead, those files
# have code that parses environment variables for DB and S3
#
# Ignore sensitive information [This is a `composer` default]
# /web/sites/*/settings.php
# /web/sites/*/settings.local.php


# Ignore Drupal's file directory
/web/sites/*/files/

# Ignore SimpleTest multi-site environment.
/web/sites/simpletest

# Ignore files generated by PhpStorm
/.idea/

.DS_Store
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,18 @@ core
# Core's dependencies are managed with Composer.
vendor

# Ignore local versions of modules.
modules/*
web/modules/contrib/*
web/themes/contrib/*

# Ignore local database dumps.
db_dumps

# Ignore configuration files that may contain sensitive information.
sites/*/settings*.php
sites/*/*settings*.php*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something to keep an eye on: we may want to include these settings files in the future, but keep all the sensitive info in env vars (via user-provided services). File-based configs don't play too well with the 12-factor app design.

sites/*/services*.yml
sites/default/default.services.*

# Ignore paths that contain user-generated content.
sites/*/files
Expand Down
3 changes: 3 additions & 0 deletions apt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
packages:
- mysql-client
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we're just using the PHP buildpack now -- is this file still needed?

44 changes: 44 additions & 0 deletions bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash
set -euo pipefail

SECRETS=$(echo $VCAP_SERVICES | jq -r '.["user-provided"][] | select(.name == "secrets") | .credentials')

install_drupal() {
ROOT_USER_NAME=$(echo $SECRETS | jq -r '.ROOT_USER_NAME')
ROOT_USER_PASS=$(echo $SECRETS | jq -r '.ROOT_USER_PASS')

: "${ACCOUNT_NAME:?Need and root user name for Drupal}"
: "${ACCOUNT_PASS:?Need and root user pass for Drupal}"

drupal site:install \
--root=$HOME/web \
--no-interaction \
--account-name="$ROOT_USER_NAME" \
--account-pass="$ROOT_USER_PASS" \
--langcode="en"
# Delete some data created in the "standard" install profile
# See https://www.drupal.org/project/drupal/issues/2583113
drupal --root=$HOME/web entity:delete shortcut_set default --no-interaction
# Set site uuid to match our config
UUID=$(grep uuid web/sites/default/config/system.site.yml | cut -d' ' -f2)
drupal --root=$HOME/web config:override system.site uuid $UUID
}

if [ "${CF_INSTANCE_INDEX:-''}" == "0" ]; then
drupal --root=$HOME/web list | grep database > /dev/null || install_drupal
# Sync configs from code
drupal --root=$HOME/web config:import --directory $HOME/web/sites/default/config

# Secrets
CRON_KEY=$(openssl rand -base64 32) # Not used, so we set it to a random val
BRIGHTCOVE_ACCOUNT=$(echo $SECRETS | jq -r '.BRIGHTCOVE_ACCOUNT')
BRIGHTCOVE_CLIENT=$(echo $SECRETS | jq -r '.BRIGHTCOVE_CLIENT')
BRIGHTCOVE_SECRET=$(echo $SECRETS | jq -r '.BRIGHTCOVE_SECRET')
drupal --root=$HOME/web config:override scheduler.settings lightweight_cron_access_key $CRON_KEY > /dev/null
drupal --root=$HOME/web config:override brightcove.brightcove_api_client.nsf_brightcove account_id $BRIGHTCOVE_ACCOUNT > /dev/null
drupal --root=$HOME/web config:override brightcove.brightcove_api_client.nsf_brightcove client_id $BRIGHTCOVE_CLIENT > /dev/null
drupal --root=$HOME/web config:override brightcove.brightcove_api_client.nsf_brightcove secret_key $BRIGHTCOVE_SECRET > /dev/null

# Clear the cache
drupal --root=$HOME/web cache:rebuild --no-interaction
fi
123 changes: 68 additions & 55 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,75 +1,88 @@
{
"name": "drupal/drupal",
"description": "Drupal is an open source content management platform powering millions of websites and applications.",
"name": "18f/nsf",
"description": "The National Science Foundation's beta site",
"type": "project",
"license": "GPL-2.0+",
"authors": [
{
"name": "",
"role": ""
}
],
"repositories": [
{
"type": "composer",
"url": "https://packages.drupal.org/8"
}
],
"require": {
"composer/installers": "^1.0.24",
"wikimedia/composer-merge-plugin": "^1.4",
"drush/drush": "^9.1",
"drupal/features": "^3.5",
"php": "^7.1.0",
"composer/installers": "^1.2",
"cweagans/composer-patches": "^1.6",
"drupal-composer/drupal-scaffold": "^2.2",
"drupal/bootstrap": "^3.11",
"drupal/brightcove": "^1.3",
"drupal/inline_entity_form": "^1.0@beta",
"drupal/time_formatter": "1.x-dev",
"drupal/entity_embed": "^1.0",
"drupal/console": "^1.0.2",
"drupal/core": "~8.4",
"drupal/ctools": "^3.0",
"drupal/devel": "^1.2",
"drupal/diff": "^1.0@RC",
"drupal/embed": "^1.0",
"drupal/entity_browser": "^2.0",
"drupal/ctools": "^3.0",
"drupal/media_entity": "^1.7"
"drupal/entity_embed": "^1.0@beta",
"drupal/features": "^3.5",
"drupal/flysystem_s3": "^1.0@alpha",
"drupal/inline_entity_form": "^1.0@beta",
"drupal/masquerade": "^2.0@beta",
"drupal/media_entity": "^1.7",
"drupal/pathauto": "^1.1",
"drupal/rules": "^3.0@alpha",
"drupal/scheduler": "^1.0",
"drupal/time_formatter": "1.x-dev",
"drupal/tour_ui": "^1.0@alpha",
"drupal/workflow": "^1.0",
"drush/drush": "~8.0|^9.0.0-beta8",
"webflo/drupal-finder": "^1.0.0",
"webmozart/path-util": "^2.3"
},
"replace": {
"drupal/core": "^8.4"
"conflict": {
"drupal/drupal": "*"
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"preferred-install": "dist",
"autoloader-suffix": "Drupal8"
},
"extra": {
"_readme": [
"By default Drupal loads the autoloader from ./vendor/autoload.php.",
"To change the autoloader you can edit ./autoload.php.",
"This file specifies the packages.drupal.org repository.",
"You can read more about this composer repository at:",
"https://www.drupal.org/node/2718229"
],
"merge-plugin": {
"include": [
"core/composer.json",
"modules/brightcove/composer.json"
],
"recurse": false,
"replace": false,
"merge-extra": false
},
"installer-paths": {
"core": ["type:drupal-core"],
"modules/contrib/{$name}": ["type:drupal-module"],
"profiles/contrib/{$name}": ["type:drupal-profile"],
"themes/contrib/{$name}": ["type:drupal-theme"],
"drush/contrib/{$name}": ["type:drupal-drush"],
"modules/custom/{$name}": ["type:drupal-custom-module"],
"themes/custom/{$name}": ["type:drupal-custom-theme"]
}
"sort-packages": true
},
"autoload": {
"psr-4": {
"Drupal\\Core\\Composer\\": "core/lib/Drupal/Core/Composer"
}
"classmap": [
"scripts/composer/ScriptHandler.php"
]
},
"scripts": {
"pre-autoload-dump": "Drupal\\Core\\Composer\\Composer::preAutoloadDump",
"post-autoload-dump": [
"Drupal\\Core\\Composer\\Composer::ensureHtaccess"
"drupal-scaffold": "DrupalComposer\\DrupalScaffold\\Plugin::scaffold",
"pre-install-cmd": [
"DrupalProject\\composer\\ScriptHandler::checkComposerVersion"
],
"pre-update-cmd": [
"DrupalProject\\composer\\ScriptHandler::checkComposerVersion"
],
"post-package-install": "Drupal\\Core\\Composer\\Composer::vendorTestCodeCleanup",
"post-package-update": "Drupal\\Core\\Composer\\Composer::vendorTestCodeCleanup"
"post-install-cmd": [
"DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
],
"post-update-cmd": [
"DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
]
},
"repositories": [
{
"type": "composer",
"url": "https://packages.drupal.org/8"
"extra": {
"installer-paths": {
"web/core": ["type:drupal-core"],
"web/libraries/{$name}": ["type:drupal-library"],
"web/modules/contrib/{$name}": ["type:drupal-module"],
"web/profiles/contrib/{$name}": ["type:drupal-profile"],
"web/themes/contrib/{$name}": ["type:drupal-theme"],
"web/drush/contrib/{$name}": ["type:drupal-drush"],
"web/modules/custom/{$name}": ["type:drupal-custom-module"],
"web/themes/custom/{$name}": ["type:drupal-custom-theme"]
}
]
}
}
Loading