kalamuna / drupal-project

Kalamuna composer template for Drupal projects with CircleCI and Pantheon integration. (NOTE: THIS SHOULD NOT BE USED FOR NEW DRUPAL 9 SITES)
GNU General Public License v2.0
6 stars 1 forks source link

Kalamuna composer template for Drupal projects with CircleCI and Pantheon integration

This template is based on the drupal-composer/drupal-project template, with additional tools and settings specific to the Kalamuna workflow.

The goal of this repository is to provide a clean installation with just the tools and files that we need for 95% of our Drupal projects. Alternate configurations, with lesser-used packages or frameworks, should be included as sperate packages or moved to branches which can be used when needed for particular projects.

Usage

Create a new Github repo

Press the Use this template button in Github to create a new repository for your project based on this template, or clone this repository manually and remove any unneeded git history.

Create Pantheon environment

  1. Created a new pantheon site at https://dashboard.pantheon.io/sites/create, selecting the appropriate Organization. Note: It may make more sense from a process perspective to have the client create the pantheon site and then add Kalamuna as a supporting organization.
  2. When prompted to select an upstream, choose the regular Pantheon Drupal 8 upstream option (not an organization upstream), so the hidden framework variable on Pantheon is properly set to Drupal.
  3. Run terminus site:upstream:set my-site-name empty from your command line to remove the unneeded upstream after the site has been initialized.
  4. Add the Kalamuna Commit Bot kalacommitbot@kalamuna.com under the Team tab for the project (or an alternate account you'd like to use for pushing to Pantheon).
  5. Copy the location of the Pantheon git repo from the Git SSH clone URL field under the Connection info dropdown in the Pantheon site dashboard, which is the format ssh://codeserver.dev.XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX@codeserver.dev.XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.drush.in:2222/~/repository.git. Discard the git clone and site-name parts from before and after the URL in the provided command.

Initialize CircleCI integration

Note: The circleci/php:7.3-node-browsers image is currently incompatible with Drupal 8, due to the upgrade to Composer 2. For the time being, the docker image is set to a specific tag from before composer was upgraded.

  1. Log into CircleCI and add your github repo as an active project.
  2. Find the place to add ssh keys to the circle project, which is at Project Settings > SSH Keys > Additional SSH Keys in the new circleci interface, and at Project Settings > SSH Permissions in the old interface.
  3. And add a new private key with drush.in as the hostname and the private key text for kalacommitbot@kalamuna.com, or whichever user you added to the pantheon project for pushing commits. The private key should start with -----BEGIN RSA PRIVATE KEY----- and end with -----END RSA PRIVATE KEY-----. (Kalamuna devs should look in 1password for this info.)
  4. Under the environment variables tab in the project settings, create a new variable with PANTHEON_REPO as the key, and the ssh://codeserver.dev.XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX@codeserver.dev.XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.drush.in:2222/~/repository.git repo url as the value. (If you encounter an error, double check that you removed git clone and the trailing repository name that is added in the pantheon connection info.)
  5. If the npm build process should run in a subfolder, add a NPM_PATH environmental variable in the format web/themes/custom/themename/. (Note that until circle allows environmental variables in keys, the packages used in a subfolder will not be cached. More info)

Install the codebase and deploy

  1. Clone the github repository locally and run composer install to install Drupal. (You may need to increase your memory limit or execute php -d memory_limit=3G /path/to/composer install.)
  2. Commit the composer.lock file, and files that have been initialized for customization, like robots.txt and settings.php.
  3. Run npm it to install the node modules, and commit the package.lock file to the repository.
  4. Push the changes to github, and check that the CircleCI workflow executes properly and the code is pushed to pantheon.

Configure Drupal

  1. Install Drupal in the Pantheon dev environment. (Note: If you want to run the Drupal installation process locally, you may need to re-enable some layers of caching in the /web/sites/default/settings.local.php file.)
  2. Enable the included contrib modules, including admin_toolbar_tools, metatag, pantheon_advanced_page_cache, and pathauto.
  3. Copy the database to your local environment, and run drush cex to export the configuration to the config/sync directory, and commit to git.

Set up local development environment

  1. If using lando, edit the .lando.yml file to set the appropriate PROJECTNAME, PANTHEON_SITE_ID, and PANTHEON_SITE_MACHINE_NAME. Database credentials are set automagically by the pantheon lando recipie.

    or

  2. Create an .env file from .env.example, and set the appropriate database credentials and drush site url.

What does the original drupal-composer/drupal-project template do?

When installing the given composer.json some tasks are taken care of:

What Kalamuna-specific features have been added?

What features have been removed or changed from the original drupal-composer/drupal-project repository?

Potential improvements