From 1328086e8dcfaeb190e3ba3138a550cfd308ee05 Mon Sep 17 00:00:00 2001 From: Jakob Perry Date: Tue, 20 Oct 2020 09:33:07 -0700 Subject: [PATCH] Initial Tugboat config files. --- .tugboat/config.yml | 114 ++++++++++++++++++++++++++++++++++ .tugboat/tugboat.settings.php | 13 ++++ 2 files changed, 127 insertions(+) create mode 100644 .tugboat/config.yml create mode 100644 .tugboat/tugboat.settings.php diff --git a/.tugboat/config.yml b/.tugboat/config.yml new file mode 100644 index 000000000..c314f40a2 --- /dev/null +++ b/.tugboat/config.yml @@ -0,0 +1,114 @@ +services: + # What to call the service hosting the site. + php: + # Use PHP 7.x with Apache; this syntax pulls in the latest version of PHP 7 + image: tugboatqa/php:7.4-apache + + # Set this as the default service. This does a few things + # 1. Clones the git repository into the service container + # 2. Exposes port 80 to the Tugboat HTTP proxy + # 3. Routes requests to the preview URL to this service + default: true + + # Wait until the mysql service is done building + depends: mysql + + # A set of commands to run while building this service + commands: + # Commands that set up the basic preview infrastructure + init: + - printenv + - apt-get update + # Install bz2 and zip extensions + - apt-get install -y libbz2-dev libzip-dev + # Install opcache and mod-rewrite. + - docker-php-ext-install opcache bz2 zip bcmath + - a2enmod headers rewrite + + # Up the memory limit to 512m + - echo "memory_limit = 512M" >> /usr/local/etc/php/conf.d/my-php.ini + + # Install node10/npm to build source + - curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - + - apt-get install -y nodejs + + # Install drush-launcher, if desired. + - wget -O /usr/local/bin/drush https://github.com/drush-ops/drush-launcher/releases/download/0.6.0/drush.phar + - chmod +x /usr/local/bin/drush + + # Link the document root to the expected path. This example links /web + # to the docroot. + - ln -snf "${TUGBOAT_ROOT}/docroot" "${DOCROOT}" + + # A common practice in many Drupal projects is to store the config and + # private files outside of the Drupal root. If that's the case for your + # project, you can either specify the absolute paths to those + # directories in your settings.local.php, or you can symlink them in + # here. Here is an example of the latter option: + - ln -snf "${TUGBOAT_ROOT}/config" "${DOCROOT}/../config" + - ln -snf "${TUGBOAT_ROOT}/files-private" "${DOCROOT}/../files-private" + + # Commands that import files, databases, or other assets. When an + # existing preview is refreshed, the build workflow starts here, + # skipping the init step, because the results of that step will + # already be present. + update: + # Use the tugboat-specific Drupal settings. + - cp "${TUGBOAT_ROOT}/.tugboat/tugboat.settings.php" "${DOCROOT}/sites/default/settings/local.settings.php" + + # Install/update packages managed by composer, including drush. + - COMPOSER_MEMORY_LIMIT=-1 composer install --optimize-autoloader + + # Copy Drupal's public files directory from an external server. The + # public SSH key found in the Tugboat Repository configuration must be + # copied to the external server in order to use rsync over SSH. + #- rsync -arvz -e 'ssh -p 41864' --progress --delete SOURCE "DESTINATION" + + # Alternatively, another common practice is to use the + # stage_file_proxy Drupal module. This module lets Drupal serve + # files from another publicly-accessible Drupal site instead of + # syncing the entire files directory into the Tugboat Preview. + # This results in smaller previews and reduces the build time. + #- COMPOSER_MEMORY_LIMIT=-1 composer require --dev drupal/stage_file_proxy + #- PHP_OPTIONS='-d memory_limit="1024M"' drush pm:enable --yes stage_file_proxy + #- drush config:set --yes stage_file_proxy.settings origin "http://www.lanfest.com" + + # Set file permissions such that Drupal will not complain + - chgrp -R www-data "${DOCROOT}/sites/default/files" + - find "${DOCROOT}/sites/default/files" -type d -exec chmod 2775 {} \; + - find "${DOCROOT}/sites/default/files" -type f -exec chmod 0664 {} \; + + # Commands that build the site. This is where you would add things + # like feature reverts or any other drush commands required to + # set up or configure the site. When a preview is built from a + # base preview, the build workflow starts here, skipping the init + # and update steps, because the results of those are inherited + # from the base preview. + build: + - COMPOSER_MEMORY_LIMIT=-1 composer install --optimize-autoloader + # Add Drush drupal installer here. + - PHP_OPTIONS='-d memory_limit="1024M"' drush cache:rebuild + # Config import might not be needed for the new install. + - PHP_OPTIONS='-d memory_limit="1024M"' drush config:import -y + - PHP_OPTIONS='-d memory_limit="1024M"' drush updatedb -y + - PHP_OPTIONS='-d memory_limit="1024M"' drush cache:rebuild + + # What to call the service hosting MySQL. This name also acts as the + # hostname to access the service by from the php service. + mysql: + # Use the latest available 5.x version of MySQL + image: tugboatqa/mysql:5.7 + + # A set of commands to run while building this service + commands: + # Commands that import files, databases, or other assets. When an + # existing preview is refreshed, the build workflow starts here, + # skipping the init step, because the results of that step will + # already be present. + update: + # Copy a database dump from an external server. The public + # SSH key found in the Tugboat Repository configuration must be + # copied to the external server in order to use scp. + - scp SOURCEFROMAHOSTING /tmp/sitebackup.sql + - cat /tmp/sitebackup.sql | mysql tugboat + - rm /tmp/sitebackup.sql diff --git a/.tugboat/tugboat.settings.php b/.tugboat/tugboat.settings.php new file mode 100644 index 000000000..9abe63309 --- /dev/null +++ b/.tugboat/tugboat.settings.php @@ -0,0 +1,13 @@ + 'tugboat', + 'username' => 'tugboat', + 'password' => 'tugboat', + 'prefix' => '', + 'host' => 'mysql', + 'port' => '3306', + 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', + 'driver' => 'mysql', +); +// Use the TUGBOAT_REPO_ID to generate a hash salt for Tugboat sites. +$settings['hash_salt'] = hash('sha256', getenv('TUGBOAT_REPO_ID'));