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

WIP: Tugboat Config files #228

Draft
wants to merge 1 commit into
base: 8.x-4.x
Choose a base branch
from
Draft
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 114 additions & 0 deletions .tugboat/config.yml
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions .tugboat/tugboat.settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
$databases['default']['default'] = array (
'database' => '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'));