Skip to content
Open

Lando #109

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
080fbc9
adding a lando.yml file
mrossi113 Jan 3, 2020
6f05cbe
add node service for frontend assets
jlandfried Jan 9, 2020
8e81776
add composer install to build step
jlandfried Jan 9, 2020
17e91a0
Add documentation around installing modules using lando
jlandfried Jan 10, 2020
de3a595
add lando composer documentation
jlandfried Jan 10, 2020
1d4ed9c
update drush docs for lando
jlandfried Jan 10, 2020
7f2cdf1
Update gulp documentation to reflect lando usage
jlandfried Jan 10, 2020
406a45a
Add lando-specific npm/yarn docs, and tooling override to strongly en…
jlandfried Jan 10, 2020
02b46fa
Update documentation around xdebug with Lando
jlandfried Jan 10, 2020
8e7f2fb
add behat tooling
jlandfried Jan 10, 2020
a8114f7
add todo file required for 3.0 release
jlandfried Jan 10, 2020
ff5b720
add ci config for behat
jlandfried Jan 10, 2020
6a89eb8
update CI profile for behat
jlandfried Jan 10, 2020
2a12140
merge master
jlandfried Jan 23, 2020
4c90fe1
Remove wdio docs
jlandfried Jan 23, 2020
37bafd8
remove wdio docs
jlandfried Jan 23, 2020
0354e2e
Remove varnish docs and default vcl. Not enabling it for lando at the…
jlandfried Jan 23, 2020
b10425b
document lando instead of docker
jlandfried Mar 10, 2020
a6fe26c
add mannequin service
jlandfried Mar 10, 2020
37902c9
mark mannequin service complete
jlandfried Mar 10, 2020
12d9beb
Merge pull request #107 from LastCallMedia/lando_mannequin
jlandfried Mar 10, 2020
81c6949
Add lando-specific settings file, remove docker-compose version
jlandfried Mar 11, 2020
19b1fae
add default readme for config dir
jlandfried Mar 11, 2020
ba972b2
Add ability to pull latest database from pantheon using lando tooling…
jlandfried Mar 11, 2020
de3fb76
fix environment config, add back docker settings for CI
jlandfried Mar 11, 2020
35cee91
indicate that we removed docker directory (moved to .env/) and added …
jlandfried Mar 11, 2020
70ff7ca
we don't already have an acquia import, so we're not recreating it fo…
jlandfried Mar 11, 2020
9413c42
Blackfire WIP. Remaining step is to have a way to ensure that `blackf…
jlandfried Mar 13, 2020
aaadd55
update blackfire docs to describe how to use it with lando
jlandfried Mar 13, 2020
99941bf
merge master
jlandfried May 4, 2020
237db6c
Use external blackfire agent, install only probe/cli on appserver
rbayliss May 26, 2020
f7d595a
Merge pull request #111 from LastCallMedia/lando_blackfire_alt
jlandfried May 27, 2020
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
14 changes: 7 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
#
# * TERMINUS_MACHINE_TOKEN
#
# It also depends on the following environment variables declared in docker/drupal.env:
# It also depends on the following environment variables declared in .env/drupal.env:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think we should use .env as a directory, because it prevents us from ever using a .env file. In #111, we discussed moving this into .lando instead.

#
# * TERMINUS_SITE
# * TERMINUS_SOURCE_ENVIRONMENT
# * TERMINUS_ENV

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there a compelling reason to rename this variable? If not, I'd prefer to leave it as TERMINUS_SOURCE_ENVIRONMENT for backward compatibility reasons.

#
version: 2.1

Expand Down Expand Up @@ -81,10 +81,10 @@ jobs:
- run:
name: Prepare Environment
command: |
echo "source /var/www/code/docker/drupal.env" >> $BASH_ENV && source /var/www/code/docker/drupal.env
echo "source /var/www/code/.env/drupal.env" >> $BASH_ENV && source /var/www/code/.env/drupal.env
mkdir /tmp/junit /tmp/artifacts web/sites/simpletest web/sites/default/files && chown www-data:www-data /tmp/junit web/sites/default/files web/sites/simpletest
terminus auth:login --machine-token="$TERMINUS_MACHINE_TOKEN"
terminus backup:info "$TERMINUS_SITE.$TERMINUS_SOURCE_ENVIRONMENT" --element=db --field=file > /tmp/db-cache-indicator
terminus backup:info "$TERMINUS_SITE.$TERMINUS_ENV" --element=db --field=file > /tmp/db-cache-indicator
# Run linting steps up front. If these fail, they should provide fast feedback.
- run: {name: 'ESLint', command: 'node_modules/.bin/eslint -f junit . > /tmp/junit/eslint.xml'}
- run: {name: 'PHPCS', command: 'vendor/bin/phpcs --report-junit=/tmp/junit/phpcs.xml --report-summary'}
Expand All @@ -98,22 +98,22 @@ jobs:
- run: {name: 'Nightcrawler', command: 'node_modules/.bin/nightcrawler crawl --json /tmp/artifacts/results.json --junit /tmp/junit/crawler.xml'}
# Run PHPUnit as www-data to support BrowserTestBase installing the site.
- run: {name: 'Run PHPUnit', command: 'su -s /bin/bash www-data -c "vendor/bin/phpunit --log-junit=/tmp/junit/phpunit.xml"'}
- run: {name: 'Run Behat', command: 'vendor/bin/behat -f junit -o /tmp/junit'}
- run: {name: 'Run Behat', command: 'vendor/bin/behat --profile=ci -f junit -o /tmp/junit'}
- store_test_results: { path: '/tmp/junit' }
- store_artifacts: {path: '/tmp/artifacts'}

deploy:
executor: php
steps:
- attach_workspace: {at: /var/www}
- run: {name: 'Source environment variables', command: 'echo "source /var/www/code/docker/drupal.env" >> $BASH_ENV'}
- run: {name: 'Source environment variables', command: 'echo "source /var/www/code/.env/drupal.env" >> $BASH_ENV'}
- run: {name: 'Terminus Login', command: 'terminus auth:login --machine-token="$TERMINUS_MACHINE_TOKEN"'}
- run: {name: 'Export git variables', command: 'terminus connection:info --fields=git_host,git_port,git_url --format=json "$TERMINUS_SITE.dev" | bin/json-to-bash >> $BASH_ENV'}
- run: {name: 'Trust host key', command: 'ssh-keyscan -p $GIT_PORT $GIT_HOST >> /etc/ssh/ssh_known_hosts'}
- run: {name: 'Set git committer', command: 'git config --global user.email "$GIT_AUTHOR_EMAIL" && git config --global user.name "$GIT_AUTHOR_NAME"'}
- run: {name: 'Lean Composer install', command: 'composer install --no-dev -o -n'}
- run: {name: 'Push Artifact', command: 'node_modules/.bin/artifactsh -a $GIT_URL -b $CIRCLE_BRANCH'}
- run: {name: 'Ensure multidev', command: 'test $CIRCLE_BRANCH == "master" || bin/create-artifact-environment-pantheon -b $CIRCLE_BRANCH -s $TERMINUS_SOURCE_ENVIRONMENT'}
- run: {name: 'Ensure multidev', command: 'test $CIRCLE_BRANCH == "master" || bin/create-artifact-environment-pantheon -b $CIRCLE_BRANCH -s $TERMINUS_ENV'}
- run: {name: 'Prune multidev environments', command: 'bin/prune-artifact-environments-pantheon -p "p-*"'}
- run: {name: 'Prune branches', command: 'bin/prune-artifact-branches -a $GIT_URL -p "p-*"'}
workflows:
Expand Down
17 changes: 17 additions & 0 deletions .env/default.private.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file contains environment variables for sensitive information that
# should not be committed to the repository.

# This default file is included in the repository as a guideline for things
# that may be useful to pass into the application services.

# Machine token from Pantheon that allows terminus commands to be executed
# from within the appserver service.
TERMINUS_MACHINE_TOKEN=abcdefghijklmnopqrstuvwxyz1234567890

# Blackfire client and server ids. Required for Blackfire profiling. Obtain
# these by creating an account at blackfire.io and visiting
# https://blackfire.io/my/settings/credentials
BLACKFIRE_CLIENT_ID=abcdefghijklmnopqrstuvwxyz1234567890
BLACKFIRE_CLIENT_TOKEN=abcdefghijklmnopqrstuvwxyz1234567890
BLACKFIRE_SERVER_ID=abcdefghijklmnopqrstuvwxyz1234567890
BLACKFIRE_SERVER_TOKEN=abcdefghijklmnopqrstuvwxyz1234567890
2 changes: 1 addition & 1 deletion docker/drupal.env → .env/drupal.env
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ TERMINUS_SITE=scaffold

# Machine name of Pantheon environment to pull db from. This is
# also the environment new multidev instances start from.
TERMINUS_SOURCE_ENVIRONMENT=dev
TERMINUS_ENV=dev
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
web/sites/*/files
web/sites/*/settings.local.php
web/sites/simpletest/*
.env
.env/private.env
docker-compose.override.yml

# Contrib/external code:
Expand Down
79 changes: 79 additions & 0 deletions .lando.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: drupal-scaffold
recipe: drupal8
config:
webroot: web #@docroot
php: 7.2
via: nginx
drush: ^8
xdebug: false
env_file:
- .env/drupal.env
- .env/private.env
proxy:
mannequin:
- mannequin.lndo.site
services:
appserver:
build:
- composer install
build_as_root:
- .lando/init/terminus.sh
- .lando/init/blackfire.sh
overrides:
environment:
BLACKFIRE_CLIENT_ID:
BLACKFIRE_CLIENT_TOKEN:

node:
type: node
build:
- yarn install
globals:
gulp-cli: latest
mannequin:
type: compose
services:
image: devwithlando/php:7.3-apache
command: docker-php-entrypoint /app/vendor/bin/mannequin start -c /app/.mannequin.php *:80
blackfire:
type: compose
keys: false
app_mount: false
services:
image: "blackfire/blackfire"
user: root
command: blackfire-agent
environment:
BLACKFIRE_SERVER_ID: # Set in .env if you want to use Blackfire.
BLACKFIRE_SERVER_TOKEN: # Set in .env if you want to use Blackfire.
LANDO_DROP_USER: blackfire

tooling:
gulp:
service: node
yarn:
service: node
npm:
service: node
cmd: "echo 'NPM is disabled in favor of yarn'"
behat:
service: appserver
cmd: vendor/bin/behat
phpunit:
service: appserver
cmd: vendor/bin/phpunit
phpcs:
service: appserver
cmd: vendor/bin/phpcs
eslint:
service: node
cmd: node_modules/.bin/eslint
terminus:
service: appserver
latest_db_pantheon:
service: appserver
description: Updates the database from the latest Pantheon backup
cmd: bin/refresh-local-pantheon
blackfire:
service: appserver
user: root
10 changes: 10 additions & 0 deletions .lando/init/blackfire.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -e

echo "Installing Blackfire PHP Probe..."
curl -o $(php -r "echo ini_get('extension_dir');")/blackfire.so -L -s https://packages.blackfire.io/binaries/blackfire-php/1.34.0/blackfire-php-linux_amd64-php-$(php -r "echo PHP_MAJOR_VERSION . PHP_MINOR_VERSION;").so
printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8707\n" > $PHP_INI_DIR/conf.d/blackfire.ini

echo "Installing Blackfire CLI..."
curl -o /usr/local/bin/blackfire -L -s https://packages.blackfire.io/binaries/blackfire-agent/1.35.1/blackfire-cli-linux_static_amd64
chmod +x /usr/local/bin/blackfire
5 changes: 5 additions & 0 deletions .lando/init/terminus.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

wget https://github.com/pantheon-systems/terminus/releases/download/2.3.0/terminus.phar -O /usr/local/bin/terminus
chmod +x /usr/local/bin/terminus
[ -z "$TERMINUS_MACHINE_TOKEN" ] && echo "Terminus machine token not set" || terminus auth:login --machine-token=$TERMINUS_MACHINE_TOKEN
3 changes: 2 additions & 1 deletion .mannequin.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
'drupal_root' => __DIR__.'/web',
'twig_options' => [
'auto_reload' => TRUE,
]
],
]);

$config = MannequinConfig::create()
->addExtension($drupalExtension)
->setGlobalCss([
'web/themes/custom/scaffold/dist/css/style.css',
'web/core/themes/stable/css/system/components/hidden.module.css',
])
->setGlobalJs([
'web/core/assets/vendor/jquery/jquery.min.js',
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* Enabled Drupal js behaviors in Mannequin by default.
* Remove dockerized settings in default.settings.php - this file will be used whenever KernelTestBase is executed, causing the site under test to pick up the Dockerized/local settings as it's own.
* Use `CACHE_HOST`, `CACHE_PORT`, `CACHE_PASSWORD` in `settings.docker.php` instead of REDIS_* equivalents. This brings us into line with Pantheon's environment variables.
* Replace environment variables in the default CircleCI build: `PSITE` -> `TERMINUS_SITE`, `PSRCENV` -> `TERMINUS_SOURCE_ENVIRONMENT`, `PMACHINE` -> `TERMINUS_MACHINE_TOKEN`. These variables will remain consistent with what we use in Docker.
* Replace environment variables in the default CircleCI build: `PSITE` -> `TERMINUS_SITE`, `PSRCENV` -> `TERMINUS_ENV`, `PMACHINE` -> `TERMINUS_MACHINE_TOKEN`. These variables will remain consistent with what we use in Docker.
* Use `yarn` in all documentation, CircleCI steps. Yarn is a drop-in replacement for `npm` that is much faster.
* Configure ESLint through `.eslintignore` in repository root rather than custom Gulp configuration.
* Configure PHPCS through `phpcs.xml.dist` in repository root rather than custom Gulp configuration.
Expand Down
40 changes: 21 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ Starting a New Project
```bash
composer create-project lastcall/drupal-scaffold PROJECTNAME
```
- [ ] Bring up the Docker containers and enter the Drupal container.
- [ ] Update the project's `name` in `.lando.yml`
- [ ] Bring up the local development environment.
```bash
docker-compose up -d drupal
docker-compose exec drupal /bin/bash
lando start
```
- [ ] From the repository root (`/var/www` inside the Drupal container), install NPM and composer dependencies:
- [ ] Install project's php and frontend dependencies
```bash
yarn install
composer install
lando yarn install
lando composer install
```
- [ ] Visit the Drupal site in your browser to install Drupal and continue. The default URL will be `http://localhost:8080`.
- [ ] Visit the Drupal site at one of the urls output by lando.

See the [scaffold documentation](docs/scaffold.md) for next steps.

Expand All @@ -33,31 +33,33 @@ Everything below this line applies to scaffold projects that are already set up.

Setting Up for Local Development
--------------------------------

This project is built using Drupal Scaffold. Before you begin, you must have Docker and Docker Compose installed on your local machine. For installation instructions, see the [Drupal Scaffold - Docker documentation](https://github.com/LastCallMedia/Drupal-Scaffold/blob/master/docs/tools/docker.md).
This project is built using Drupal Scaffold. Before you begin, you must have Lando installed on your local machine. For installation instructions, see the [Drupal Scaffold - Lando documentation](https://github.com/LastCallMedia/Drupal-Scaffold/blob/master/docs/tools/lando.md).

1. [Clone](https://help.github.com/articles/cloning-a-repository/) this repository.
2. If you haven't created and [set your Pantheon machine token](https://github.com/LastCallMedia/Drupal-Scaffold/blob/master/docs/recipes/setting-machine-token.md), do that now.
3. [Start](https://github.com/LastCallMedia/Drupal-Scaffold/blob/master/docs/tools/docker.md#Running) the Docker environment and shell in:
```bash
docker-compose up -d drupal
docker-compose exec drupal bash
lando start
```
3. Install [Composer](https://github.com/LastCallMedia/Drupal-Scaffold/blob/master/docs/tools/composer.md#Running) dependencies:
```bash
composer install
lando composer install
```
4. Install [NPM](https://github.com/LastCallMedia/Drupal-Scaffold/blob/master/docs/tools/npm.md#Running) dependencies:
```bash
yarn install
lando yarn install
```
5. Import a database
```bash
# Download a copy of the database backups from the hosting environment and save it to the projectroot
lando db-import [file]
```
6. Compile and watch frontend assets
```bash
lando gulp watch
```
5. Run `composer site:import` to pull down and import a copy of the site's database. If Pantheon gives you an error here, make sure you followed Step 2 above correctly and that you're running Docker in a new terminal window

6. Run `drupal site:mode dev` to switch to dev configuration.

7. Run `gulp build` (or `gulp watch`) and `drush cr` (from within the Drupal root at `/var/www/web`) to compile the theme.

8. View your new local site in the browser at [http://localhost:8080/](http://localhost:8080/).
8. View your new local site in the browser at a url provided by lando when running `lando start`

See the [Drupal Scaffold documentation](https://github.com/LastCallMedia/Drupal-Scaffold/blob/master/docs/) for more information on how to use the tools and how to use this project. To find more information on the Docker stack, visit the [Docker documenation](https://github.com/LastCallMedia/Drupal-Scaffold/blob/master/docs/tools/docker.md).

Expand Down
25 changes: 25 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
TODO
====

- [ ] BLACKFIRE: Enable Blackfire in Lando (see [this issue](https://github.com/lando/lando/issues/511) and [this gist](https://gist.github.com/tylerssn/8923149702d4a796c5e103412c2370c3))
- Update Blackfire docs in docs/tools/blackfire.md
- [x] WDIO:
- Disable, remove WDIO configuration
- Documentation at docs/tools/wdio.md
- [x] MANNEQUIN:
- Add mannequin service to Lando config
- Update Mannequin docs at docs/tools/mannequin.md
- [x] VARNISH:
- Determine if we still want a varnish service
- [ ] If yes:
- add varnish service to .lando.yml
- [x] If no:
- Remove docker/default.vcl, docs in docs/tools/varnish.md
- [ ] DOCKER-COMPOSE: Since we're switching from docker-compose to lando it would be confusing to leave the docker-compose functionality in here, documented or not. We should remove config and references to the old docker-compose local infrastructure
- [ ] Remove `docker-compose.yml`
- [x] Remove `docker` directory
- [x] LOCAL DEVELOPMENT TOOLS:
- Determine if we need the `site-import` tooling in `appserver`
- If yes:
- [x] Add terminus commands and scripts for importing a database
- ~~[ ] Add acquia API commands for importing databases~~
9 changes: 6 additions & 3 deletions behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ default:
extensions:
Behat\MinkExtension:
goutte: ~
# The base URL of the site. If you are using the gulp tasks,
# this URL is set in the gulpconfig, so leave this commented out.
# base_url: http://127.0.0.1:8888
# The base URL of the site.
base_url: "http://appserver_nginx" # internal nginx url. For testing with Lando, this should not have to be changed.
# Browser open command used for "Then show the last response"
show_cmd: open %s
Drupal\DrupalExtension:
Expand All @@ -50,3 +49,7 @@ default:
error_message_selector: '.messages.messages--error'
success_message_selector: '.messages.messages--status'
warning_message_selector: '.messages.messages--warning'
ci:
extensions:
Behat\MinkExtension:
base_url: "http://localhost:80"
2 changes: 1 addition & 1 deletion bin/create-artifact-environment-pantheon
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ error_out() {

pattern=".*"
site="$TERMINUS_SITE"
source="${TERMINUS_SOURCE_ENVIRONMENT:-live}"
source="${TERMINUS_ENV:-live}"
dryrun=0
while getopts "hb:i:s:n" opt; do
case "$opt" in
Expand Down
6 changes: 3 additions & 3 deletions bin/refresh-local-pantheon
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Refresh your local environment from Pantheon.
Options:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this file needed anymore? We can just use lando pull now, right?

-h: Show help
-i: Set the Pantheon site that will be used (defaults to TERMINUS_SITE).
-s: Set the Pantheon environment that will be used (defaults to TERMINUS_SOURCE_ENVIRONMENT/live)
-s: Set the Pantheon environment that will be used (defaults to TERMINUS_ENV/live)
-c: Set the cache directory to work from.
-n: Dry run (does not create environment).

Expand All @@ -29,7 +29,7 @@ error_out() {
}

site="$TERMINUS_SITE"
source="${TERMINUS_SOURCE_ENVIRONMENT:-live}"
source="${TERMINUS_ENV:-live}"
cache="/tmp/site-import-cache"
dryrun=0
while getopts "hi:s:c:n" opt; do
Expand All @@ -43,7 +43,7 @@ while getopts "hi:s:c:n" opt; do
done

test -n "$site" || error_out "Site must be set using the -i flag or the TERMINUS_SITE environment variable" 1
test -n "$source" || error_out "Source environment must be set using the -s flag or the TERMINUS_SOURCE_ENVIRONMENT environment variable" 1
test -n "$source" || error_out "Source environment must be set using the -s flag or the TERMINUS_ENV environment variable" 1


mkdir -p "$cache"
Expand Down
1 change: 1 addition & 0 deletions config/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This directory contains configuration to be imported into your Drupal site. To make this configuration active, visit admin/config/development/configuration/sync. For information about deploying configuration between servers, see https://www.drupal.org/documentation/administer/config
8 changes: 4 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ services:
links:
- mysql
- redis
env_file: [docker/drupal.env]
env_file: [.env/drupal.env]
environment:
APACHE_DOCROOT: /var/www/web
MYSQL_HOST: mysql
Expand All @@ -42,9 +42,9 @@ services:
MYSQL_DATABASE: drupal
CACHE_HOST: redis
DOCKER_ENV: local
# SITE_NAME: # Set in docker/drupal.env
# TERMINUS_SITE: # Set in docker/drupal.env
# TERMINUS_SOURCE_ENVIRONMENT: # Set in docker/drupal.env
# SITE_NAME: # Set in .env/drupal.env
# TERMINUS_SITE: # Set in .env/drupal.env
# TERMINUS_ENV: # Set in .env/drupal.env
TERMINUS_MACHINE_TOKEN: # Optionally set in .env.
XDEBUG_CONFIG: # Optionally set in .env.
XDEBUG_ENABLE: # Optionally sert in .env.
Expand Down
Loading