From 080fbc926bcc90427e8e7e3403b1373900dccc74 Mon Sep 17 00:00:00 2001 From: Melissa Rossi Date: Fri, 3 Jan 2020 09:39:08 -0500 Subject: [PATCH 01/28] adding a lando.yml file --- .lando.yml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .lando.yml diff --git a/.lando.yml b/.lando.yml new file mode 100644 index 0000000..10bf9fa --- /dev/null +++ b/.lando.yml @@ -0,0 +1,8 @@ +name: drupal-scaffold +recipe: drupal8 +config: + webroot: web + php: 7.2 + via: nginx + drush: ^8 + From 6f05cbed54cfbefba82b19bd7238abb40f20091d Mon Sep 17 00:00:00 2001 From: Jeff Landfried Date: Thu, 9 Jan 2020 12:09:23 -0500 Subject: [PATCH 02/28] add node service for frontend assets --- .lando.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.lando.yml b/.lando.yml index 10bf9fa..8980062 100644 --- a/.lando.yml +++ b/.lando.yml @@ -1,8 +1,19 @@ name: drupal-scaffold recipe: drupal8 config: - webroot: web + webroot: web #@docroot php: 7.2 via: nginx drush: ^8 - +services: + node: + type: node + build: + - yarn install + globals: + gulp-cli: latest +tooling: + gulp: + service: node + yarn: + service: node From 8e817764d765ddd114f92093f1fa398d71ec74ff Mon Sep 17 00:00:00 2001 From: Jeff Landfried Date: Thu, 9 Jan 2020 12:25:45 -0500 Subject: [PATCH 03/28] add composer install to build step --- .lando.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.lando.yml b/.lando.yml index 8980062..fae2406 100644 --- a/.lando.yml +++ b/.lando.yml @@ -6,6 +6,9 @@ config: via: nginx drush: ^8 services: + appserver: + build: + - composer install node: type: node build: From 17e91a0109a7eb247ea0ed01d14c46c8d741aa16 Mon Sep 17 00:00:00 2001 From: Jeff Landfried Date: Fri, 10 Jan 2020 10:05:59 -0500 Subject: [PATCH 04/28] Add documentation around installing modules using lando --- docs/recipes/adding-modules.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/docs/recipes/adding-modules.md b/docs/recipes/adding-modules.md index cc2c8cc..f0ce7de 100644 --- a/docs/recipes/adding-modules.md +++ b/docs/recipes/adding-modules.md @@ -2,23 +2,22 @@ Adding Modules/Themes --------------------- Use composer to bring in modules and themes. For example, if you want to add the [metatag](https://www.drupal.org/project/metatag) module, you would use the following workflow: +All commands can be run from your host machine. + 1. Add the module using composer: ```bash - # from inside drupal container: - composer require drupal/metatag + lando composer require drupal/metatag ``` 2. Enable the module: ```bash - # from inside drupal container: - drush en metatag + lando drush en metatag ``` 3. Export the configuration that includes the metatag module: ```bash - drush config-export -y + lando drush config-export -y ``` 4. Review and commit configuration changes: ```bash - # from your host machine: git status config/ # review changes, make sure there is nothing unexpected # finalize the changes by committing them. git add config/ From de3a595a2f2451133af29d9b447ade810a558f12 Mon Sep 17 00:00:00 2001 From: Jeff Landfried Date: Fri, 10 Jan 2020 10:06:30 -0500 Subject: [PATCH 05/28] add lando composer documentation --- docs/tools/composer.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/tools/composer.md b/docs/tools/composer.md index b34ed56..8581b70 100644 --- a/docs/tools/composer.md +++ b/docs/tools/composer.md @@ -1,7 +1,9 @@ Composer ======== -We recommend using [Composer](https://getcomposer.org) to manage all third party PHP code dependencies, include contributed Drupal modules and themes. Composer comes pre-installed in the `drupal` container. +We recommend using [Composer](https://getcomposer.org) to manage all third party PHP code dependencies, include contributed Drupal modules and themes. Composer comes pre-installed with Lando. + +All commands below can be un as `lando composer ...` from the host machine as well. Installing a new Module/Theme/Library ------------------------------------- From 1d4ed9c6804a790d2dc37e1f54f2a50eb1ba77c2 Mon Sep 17 00:00:00 2001 From: Jeff Landfried Date: Fri, 10 Jan 2020 10:06:45 -0500 Subject: [PATCH 06/28] update drush docs for lando --- docs/tools/drush.md | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/docs/tools/drush.md b/docs/tools/drush.md index 3ace1e6..e1514c2 100644 --- a/docs/tools/drush.md +++ b/docs/tools/drush.md @@ -9,12 +9,7 @@ Drush configuration and extra commands can be added in the `drush/` directory in Running ------- -Inside of the `drupal` container, Drush is already installed. You can run it just by typing `drush`. Examples: -* `drush uli` - Generate a one time login link. -* `drush en page_cache` - Enable the page cache module. - -Uninstalling ------------- -1. Run `composer remove --dev drush/drush`. -2. Run `git rm drush/` -3. Commit changes. +Drush comes preinstalled in the `appserver` service of the Lando development environment. +You can run it from the host machine by typing `lando drush`. Examples: +* `lando drush uli` - Generate a one time login link. +* `lando drush en page_cache` - Enable the page cache module. From 7f2cdf13f69770e83075831f559728db3e7a0f09 Mon Sep 17 00:00:00 2001 From: Jeff Landfried Date: Fri, 10 Jan 2020 10:11:25 -0500 Subject: [PATCH 07/28] Update gulp documentation to reflect lando usage --- docs/tools/gulp.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/tools/gulp.md b/docs/tools/gulp.md index dccac8c..2577b10 100644 --- a/docs/tools/gulp.md +++ b/docs/tools/gulp.md @@ -3,18 +3,21 @@ Gulp This project uses [Gulp](https://gulpjs.com/) to build front-end assets. See [Gulp Drupal Tasks](https://github.com/LastCallMedia/gulp-drupal-tasks) for more information. +Gulp is installed globally on the `node` service in the Lando local development environment. + Configuration ------------- Gulp configuration lives in `gulpconfig.js` in the repository root. You may also update `gulpfile.js` if you wish to add additional tasks. Running ------- -* `composer build` to run all Gulp build tasks. -* `node_modules/.bin/gulp` for access to more fine-grained tasks. +* `lando gulp build` to run a one time asset compilation +* `lando gulp watch` to continually watch configured files and compile them on the fly Uninstalling ------------ -1. Run `yarn remove gulp gulp-help lastcall-gulp-drupal-tasks` to remove the dependencies. -2. Edit `composer.json` to remove the `build` and `build:watch` scripts. +1. Remove `gulp-cli` from `globals` section of `node` service declaration in `.lando.yml` +2. Remove `gulp` entry from `tooling` section of `.lando.yml` +1. Run `lando yarn remove gulp gulp-help lastcall-gulp-drupal-tasks` to remove the dependencies. 3. Delete `gulpconfig.js` and `gulpfile.js` 4. Commit changes. From 406a45a3e37f60e1fb88618dd85302965f7dc870 Mon Sep 17 00:00:00 2001 From: Jeff Landfried Date: Fri, 10 Jan 2020 10:24:01 -0500 Subject: [PATCH 08/28] Add lando-specific npm/yarn docs, and tooling override to strongly encourage use of yarn instead of npm --- .lando.yml | 3 +++ README.md | 41 +++++++++++++++++++++-------------------- docs/tools/npm.md | 17 ++++++++++++----- 3 files changed, 36 insertions(+), 25 deletions(-) diff --git a/.lando.yml b/.lando.yml index fae2406..4c92276 100644 --- a/.lando.yml +++ b/.lando.yml @@ -20,3 +20,6 @@ tooling: service: node yarn: service: node + npm: + service: node + cmd: "echo 'NPM is disabled in favor of yarn'" diff --git a/README.md b/README.md index 699f3e9..a3bf5ba 100644 --- a/README.md +++ b/README.md @@ -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. @@ -31,8 +31,6 @@ Everything below this line applies to scaffold projects that are already set up. --------------------------------------------- -Setting Up for Local Development --------------------------------- 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). @@ -41,23 +39,26 @@ This project is built using Drupal Scaffold. Before you begin, you must have Doc 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. 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. +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 + ``` -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). +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. diff --git a/docs/tools/npm.md b/docs/tools/npm.md index 78ecdba..1ded328 100644 --- a/docs/tools/npm.md +++ b/docs/tools/npm.md @@ -1,7 +1,7 @@ NPM/Yarn -------- -Node Package Manager(npm) is a package management tool for NodeJS packages. Yarn is a newer, faster tool that does the same thing. NPM and Yarn are both installed in the `drupal` container. +Node Package Manager(npm) is a package management tool for NodeJS packages. Yarn is a newer, faster tool that does the same thing. NPM and Yarn are both installed in the `node` service of the Lando local development environment. Configuration ------------- @@ -11,7 +11,14 @@ Running ------- Use `yarn` rather than `npm` - these two commands are equivalent, but `yarn` is faster, and the CircleCI build relies on a `yarn.lock` file that gets generated when you use `yarn`. -* Install all dependencies: `yarn install` -* Update dependencies to the latest versions: `yarn upgrade` -* List outdated dependencies: `yarn outdated` -* Add a new dependency: `yarn add mypackage`. This will add the package to `package.json` and install it right away. +* Install all dependencies: `lando yarn install` +* Update dependencies to the latest versions: `lando yarn upgrade` +* List outdated dependencies: `lando yarn outdated` +* Add a new dependency: `lando yarn add mypackage`. This will add the package to `package.json` and install it right away. + +Enabling NPM +------------ +By default, `npm` is disabled in the local Lando development. This is done because it can create confusion if some people use `npm` while others use `yarn`. Yarn will complain if it sees a `package-lock.json` file as well. + +To enable the use of `npm`, remove npm tooling override in the `tooling` section of `.lando.yml` in the project root. +You are also able to use `npm` by `ssh`ing into the `node` service (`lando ssh -s node`) From 02b46fa6ed8419b06b341a9d4b031757446ac341 Mon Sep 17 00:00:00 2001 From: Jeff Landfried Date: Fri, 10 Jan 2020 12:55:43 -0500 Subject: [PATCH 09/28] Update documentation around xdebug with Lando --- .lando.yml | 1 + docs/tools/xdebug.md | 22 +++++++++------------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/.lando.yml b/.lando.yml index 4c92276..6448ec5 100644 --- a/.lando.yml +++ b/.lando.yml @@ -5,6 +5,7 @@ config: php: 7.2 via: nginx drush: ^8 + xdebug: false services: appserver: build: diff --git a/docs/tools/xdebug.md b/docs/tools/xdebug.md index 17aacfe..22ffe3e 100644 --- a/docs/tools/xdebug.md +++ b/docs/tools/xdebug.md @@ -1,26 +1,22 @@ -XDebug +Xdebug ====== -[XDebug](https://xdebug.org) is a remote debugging tool that allows you to pause execution of your code and view variables in real time. XDebug is available for debugging in the `drupal` container. +[Xdebug](https://xdebug.org) is a remote debugging tool that allows you to pause execution of your code and view variables in real time. Xdebug is available for debugging in the `appserver` service within the Lando local development environment. + +While Xdebug is a great tool for debugging, it does add additional performance overhead. Because of this, Xdebug is _disabled_ by default in local environments. It's easy to enable though. Configuration ------------- -Create or update the `.env` file at the repository root to enter your XDebug configuration as an environment variable: - -```bash -XDEBUG_CONFIG=remote_host=docker.for.mac.localhost -``` -The example above assumes you are on a Mac, and configures XDebug to connect back to your Mac on port 9000 (the default) when a debugging session is started. See [this page](https://xdebug.org/docs/remote) for more information on the XDEBUG_CONFIG environment variable. +Change the value from `xdebug: false` to `xdebug: true` in `.lando.yml` and run `lando rebuild` to enable Xdebug. Usage ----- -1. Using PHPStorm, add a new "PHP Remote Debug" configuration. -2. Set breakpoints in your code. -3. Visit the site in your browser, adding the XDEBUG_SESSION_START query parameter to the end of the URL. Example: http://localhost:8080?XDEBUG_SESSION_START -4. Step through code in your IDE. +See the Lando documentation to configure Xdebug in your IDE. +* [PHPStorm](https://docs.lando.dev/guides/lando-phpstorm.html) (bonus [youtube video](https://www.youtube.com/watch?v=sHNJxx0L9r0)) +* [VSCode](https://docs.lando.dev/guides/lando-with-vscode.html) Uninstalling ------------ -Xdebug is bundled with the [PHP Docker](https://github.com/LastCallMedia/PHP-Docker) container used for this project and can't be uninstalled. +Change the value from `xdebug: true` to `xdebug: false` in `.lando.yml` and run `lando rebuild` to disable Xdebug. From 8e7f2fbc19c0a65402e2e934d28fcc1f91ad7a11 Mon Sep 17 00:00:00 2001 From: Jeff Landfried Date: Fri, 10 Jan 2020 15:04:43 -0500 Subject: [PATCH 10/28] add behat tooling --- .lando.yml | 12 ++++++++++++ behat.yml | 5 ++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.lando.yml b/.lando.yml index 6448ec5..0c6351a 100644 --- a/.lando.yml +++ b/.lando.yml @@ -24,3 +24,15 @@ tooling: 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 diff --git a/behat.yml b/behat.yml index 409163a..4f820bb 100644 --- a/behat.yml +++ b/behat.yml @@ -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: From a8114f7d3c397467e2a7f6f8913362e491f779a6 Mon Sep 17 00:00:00 2001 From: Jeff Landfried Date: Fri, 10 Jan 2020 15:05:13 -0500 Subject: [PATCH 11/28] add todo file required for 3.0 release --- TODO.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 TODO.md diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..379332b --- /dev/null +++ b/TODO.md @@ -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 +- [ ] WDIO: + - Disable, remove WDIO configuration + - Documentation at docs/tools/wdio.md +- [ ] MANNEQUIN: + - Add mannequin service to Lando config + - Update Mannequin docs at docs/tools/mannequin.md +- [ ] VARNISH: + - Determine if we still want a varnish service + - If yes: + - add varnish service to .lando.yml + - 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` + - Remove `docker` directory +- [ ] LOCAL DEVELOPMENT TOOLS: + - Determine if we need the `site-import` tooling in `appserver` + - If yes: + - Add terminus commands and scripts for importing a database + - Add acquia API commands for importing databases From ff5b720990e087cc78097aea5ddfa1e60e1520ac Mon Sep 17 00:00:00 2001 From: Jeff Landfried Date: Fri, 10 Jan 2020 15:21:25 -0500 Subject: [PATCH 12/28] add ci config for behat --- .circleci/config.yml | 2 +- behat.yml | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5734a1f..69a2b95 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -97,7 +97,7 @@ jobs: - run: {name: 'Wait for Apache', command: 'dockerize -wait tcp://localhost:80 -timeout 5s'} # 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'} diff --git a/behat.yml b/behat.yml index 4f820bb..d5f3400 100644 --- a/behat.yml +++ b/behat.yml @@ -49,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://127.0.0.1:8888" From 6a89eb8fbe08752c9ca367db4800abcb820e1997 Mon Sep 17 00:00:00 2001 From: Jeff Landfried Date: Fri, 10 Jan 2020 15:39:07 -0500 Subject: [PATCH 13/28] update CI profile for behat --- behat.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/behat.yml b/behat.yml index d5f3400..c52354e 100644 --- a/behat.yml +++ b/behat.yml @@ -52,4 +52,4 @@ default: ci: extensions: Behat\MinkExtension: - base_url: "http://127.0.0.1:8888" + base_url: "http://localhost:80" From 4c90fe1fd26dd56e77b5bb6509d7bbb077a49064 Mon Sep 17 00:00:00 2001 From: Jeff Landfried Date: Thu, 23 Jan 2020 15:38:11 -0500 Subject: [PATCH 14/28] Remove wdio docs --- docs/tools/wdio.md | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 docs/tools/wdio.md diff --git a/docs/tools/wdio.md b/docs/tools/wdio.md deleted file mode 100644 index 89f6690..0000000 --- a/docs/tools/wdio.md +++ /dev/null @@ -1,30 +0,0 @@ -Webdriver IO -============ - -Webdriver IO is an end-to-end testing tool that uses Selenium. It can perform functional tests as well as Visual Regression tests. - -Tests using Webdriver IO will be slower than any other type of test, so use them sparingly. - -Configuration -------------- -Configuration lives in `wdio.conf.js`. Test files live in the `wd/tests` directory. - - -### Mocha Tests -Standard [Mocha](https://mochajs.org/) test cases can be run by writing the test cases in the `specs` directory. - -### Visual Regression Testing -Visual regression tests can be run by writing test cases in the `wd/specs` directory. VRT runs using [wdio-visual-regression-service](https://www.npmjs.com/package/wdio-visual-regression-service). In the provided sample configuration, screenshots are captured to the `wd/screenshots/taken` directory, and compared with reference samples in the `wd/screenshots/reference` directory. If a difference is found, a comparison image will be generated to highlight the difference, and placed into the `wd/screenshots/diff` directory. - -Running -------- -* `node_modules/.bin/wdio` Run all tests. -* `node_modules/.bin/wdio --spec wd/tests/vrt.js` Run one test. - -Uninstalling ------------- -1. Run `yarn remove lastcall-scaffold-webdriver` to remove the Node modules required for the webdriver. -2. Edit `composer.json` to remove the `@test:wdio` key from the `test` script. -3. Remove the "Run WDIO" step from `.circleci/config.yml`. -4. Optionally, remove the `wd/` directory entirely. -5. Commit changes. From 37bafd88b6e7ce8636fe5ee6f870011a5f3514ea Mon Sep 17 00:00:00 2001 From: Jeff Landfried Date: Thu, 23 Jan 2020 15:38:38 -0500 Subject: [PATCH 15/28] remove wdio docs --- TODO.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TODO.md b/TODO.md index 379332b..8dab64e 100644 --- a/TODO.md +++ b/TODO.md @@ -3,7 +3,7 @@ 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 -- [ ] WDIO: +- [x] WDIO: - Disable, remove WDIO configuration - Documentation at docs/tools/wdio.md - [ ] MANNEQUIN: From 0354e2e76630206e8e1231d648e7fc32f30648d8 Mon Sep 17 00:00:00 2001 From: Jeff Landfried Date: Thu, 23 Jan 2020 15:40:01 -0500 Subject: [PATCH 16/28] Remove varnish docs and default vcl. Not enabling it for lando at the moment. --- TODO.md | 6 +- docker/default.vcl | 128 ------------------------------------------ docs/tools/varnish.md | 16 ------ 3 files changed, 3 insertions(+), 147 deletions(-) delete mode 100644 docker/default.vcl delete mode 100644 docs/tools/varnish.md diff --git a/TODO.md b/TODO.md index 8dab64e..1481abe 100644 --- a/TODO.md +++ b/TODO.md @@ -9,11 +9,11 @@ TODO - [ ] MANNEQUIN: - Add mannequin service to Lando config - Update Mannequin docs at docs/tools/mannequin.md -- [ ] VARNISH: +- [x] VARNISH: - Determine if we still want a varnish service - - If yes: + - [ ] If yes: - add varnish service to .lando.yml - - If no: + - [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` diff --git a/docker/default.vcl b/docker/default.vcl deleted file mode 100644 index b15b723..0000000 --- a/docker/default.vcl +++ /dev/null @@ -1,128 +0,0 @@ -vcl 4.0; - -# This is a VCL configuration file for Varnish. - -backend default { - .host = "drupal"; - .port = "80"; -} - -# Access control list for PURGE/BAN requests. -acl purge { - "172.0.0.0/8"; -} - -sub vcl_recv { - # Only allow PURGE requests from IP addresses in the 'purge' ACL. - if (req.method == "PURGE") { - if (!client.ip ~ purge) { - return (synth(405, "Not allowed.")); - } - return (purge); - } - - # Only allow BAN requests from IP addresses in the 'purge' ACL. - if (req.method == "BAN") { - # Same ACL check as above: - if (!client.ip ~ purge) { - return (synth(403, "Not allowed.")); - } - - # Logic for the ban, using the Cache-Tags header. For more info - # see https://github.com/geerlingguy/drupal-vm/issues/397. - if (req.http.Cache-Tags) { - ban("obj.http.Cache-Tags ~ " + req.http.Cache-Tags); - } - else if (req.http.X-Url) { - ban("obj.http.X-Url ~ " + req.http.X-Url); - } - else { - return (synth(403, "Cache-Tags or X-Url header missing.")); - } - - # Throw a synthetic page so the request won't go to the backend. - return (synth(200, "Ban added.")); - } - - # Large static files are delivered directly to the end-user without - # waiting for Varnish to fully read the file first. - # Varnish 4 fully supports Streaming, so set do_stream in vcl_backend_response() - if (req.url ~ "^[^?]*\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\?.*)?$") { - unset req.http.Cookie; - return (hash); - } - - # Remove all cookies for static files - # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left. - # Sure, there's disk I/O, but chances are your OS will already have these files in their buffers (thus memory). - # Before you blindly enable this, have a read here: https://ma.ttias.be/stop-caching-static-files/ - if (req.url ~ "^[^?]*\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\?.*)?$") { - unset req.http.Cookie; - return (hash); - } - - # Only allow SESS, NO_CACHE, and MoodleSession cookies directly through. All others are stripped. - if (req.http.Cookie) { - set req.http.Cookie = ";" + req.http.Cookie; - set req.http.Cookie = regsuball(req.http.Cookie, "; +", ";"); - set req.http.Cookie = regsuball(req.http.Cookie, ";(SESS[a-z0-9]+|NO_CACHE|MoodleSession)=", "; \1="); - set req.http.Cookie = regsuball(req.http.Cookie, ";[^ ][^;]*", ""); - set req.http.Cookie = regsuball(req.http.Cookie, "^[; ]+|[; ]+$", ""); - - if (req.http.Cookie == "") { - # If there are no remaining cookies, remove the cookie header. If there - # aren't any cookie headers, Varnish's default behavior will be to cache - # the page. - unset req.http.Cookie; - } - else { - # If there is any cookies left (a session or NO_CACHE cookie), do not - # cache the page. Pass it on to Apache directly. - return (pass); - } - } -} - -# Code determining what to do when serving items from the Apache servers. -sub vcl_backend_response { - # Don't allow static files to set cookies. - if (bereq.url ~ "^[^?]*\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\?.*)?$") { - unset beresp.http.set-cookie; - } - - # Large static files are delivered directly to the end-user without - # waiting for Varnish to fully read the file first. - # Varnish 4 fully supports Streaming, so use streaming here to avoid locking. - if (bereq.url ~ "^[^?]*\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip|csv)(\?.*)?$") { - unset beresp.http.set-cookie; - set beresp.do_stream = true; # Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if the backend doesn't send a Content-Length header, so only enable it for big objects - set beresp.do_gzip = false; # Don't try to compress it for storage - } - - # Set ban-lurker friendly custom headers - set beresp.http.X-Url = bereq.url; - set beresp.http.X-Host = bereq.http.host; - - # Allow items to be stale if needed. - set beresp.grace = 1h; -} - -sub vcl_deliver { - # These headers are for internal use (or debugging) only - unset resp.http.X-Url; - unset resp.http.X-Host; - unset resp.http.X-Upstream; - unset resp.http.Cache-Tags; - unset resp.http.X-Drupal-Cache; - unset resp.http.X-Drupal-Dynamic-Cache; - - if (obj.hits > 0) { - set resp.http.X-Edge-Cache = "HIT"; - } else { - set resp.http.X-Edge-Cache = "MISS"; - } -} - -sub vcl_purge { - return (synth(200, "Purged")); -} diff --git a/docs/tools/varnish.md b/docs/tools/varnish.md deleted file mode 100644 index 91a9765..0000000 --- a/docs/tools/varnish.md +++ /dev/null @@ -1,16 +0,0 @@ -Varnish -------- - -[Varnish](https://varnish-cache.org/) is an HTTTP reverse proxy cache that stores cached pages "at the edge". Many hosts (Pantheon, Acquia) use it as part of their platform. Varnish sits in front of Apache and PHP, so when you visit the site, the first server you hit is the Varnish server, which passes requests back to Apache if it is not able to serve a page from the cache. - -Configuration -------------- -Varnish configuration (VCL) is stored in [default.vcl](/docker/default.vcl). - -Running -------- -To use Varnish: - -1. Uncomment the `varnish` container in [`docker-compose.yml`](/docker-compose.yml). -2. Run `docker-compose up -d varnish` to bring the Varnish container up. -3. Visit the site on port 8085 instead of 8080. From b10425b50c07d854b66d3a6e400a3b4aeeecd931 Mon Sep 17 00:00:00 2001 From: Jeff Landfried Date: Tue, 10 Mar 2020 15:34:29 -0400 Subject: [PATCH 17/28] document lando instead of docker --- README.md | 2 +- docker/mysql-extra.cnf | 2 -- docs/tools/docker.md | 51 ------------------------------------------ docs/tools/lando.md | 42 ++++++++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 54 deletions(-) delete mode 100644 docker/mysql-extra.cnf delete mode 100644 docs/tools/docker.md create mode 100644 docs/tools/lando.md diff --git a/README.md b/README.md index a3bf5ba..e0a29e9 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ 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. diff --git a/docker/mysql-extra.cnf b/docker/mysql-extra.cnf deleted file mode 100644 index 2801299..0000000 --- a/docker/mysql-extra.cnf +++ /dev/null @@ -1,2 +0,0 @@ -[mysqld] -max_allowed_packet=16M diff --git a/docs/tools/docker.md b/docs/tools/docker.md deleted file mode 100644 index 9d6883d..0000000 --- a/docs/tools/docker.md +++ /dev/null @@ -1,51 +0,0 @@ -Docker -====== - -[Docker](https://docs.docker.com/) is an open platform for developers and sysadmins to build, ship, and run distributed applications. In this project, it is software that lives on your local machine that allows you to run preconfigured development environments without extensive configuration. Specifically, this project uses [Docker Compose](https://docs.docker.com/compose/) to define and run the local development environment. - -Note: The Docker configuration that comes with this project is not suitable for production hosting. It is intended for use in local or development environments only. - -Installing ----------- -You must have `docker` and `docker-compose` installed on your local machine before using the Docker environments. - -[Mac](https://docs.docker.com/docker-for-mac/install/) | [Windows](https://docs.docker.com/docker-for-windows/install/) - -Configuration -------------- -All Docker configuration for this project lives in the [`docker-compose.yml`](/docker-compose.yml) file in the repository root. You may customize this file if you would like, or you may use the following files to customize your environment further: - -* [`docker/drupal.env`](/docker/drupal.env) - This file contains environment variables that are injected into the `drupal` container. It should be committed to the repository, so do not put anything sensitive in here. -* `.env` - This file can contain environment variables that get referenced in `docker-compose.yml`. See [`.env.example`](/.env.example) for documentation on variables may be used. - -For port configuration, changing the "exposed" port does not change the port inside of the container. Eg: If you change the `MANNEQUIN_PORT` variable to 8007, you should still run Mannequin inside of the container on 8081, but you will access it from your browser at `localhost:8007`. - -Running -------- -Use the `docker-compose` command on your host to interact with Docker. - -* Start all containers: `docker-compose up -d` -* List running containers: `docker-compose ps` -* Stop all containers: `docker-compose stop` -* Download updates to all containers: `docker-compose pull` -* Output the logs of the `drupal` container: `docker-compose logs drupal` -* Remove all containers to reset your environment: `docker-compose down` - -Note that MySQL data will not be removed, even when you remove the `mysql` container. To fully delete this data, use `docker-compose down -v`. - -Accessing the Containers ------------------------- -When the containers are running, they are accessible on the following ports: - -* **8080**: Direct connection to Drupal running on Apache. -* **33306**: Direct connection to MySQL. Useful for connecting to the database from the host machine. A direct mysql connection can be made from the outside via: `mysql -h 127.0.0.1 --port 33306 -u drupal -pdrupal drupal` - -Optional containers (must be enabled before you can use them): -* **8085**: Varnish, connected to Drupal. If you want to use Varnish, uncomment it in `docker-compose.yml` -* **8983**: Solr direct connection. Useful for debugging via Apache Solr web interface. - -Important: Should you choose to run this setup in production, you should always remove the debug ports (noted in `docker-compose.yml`) for security. - -Troubleshooting ---------------- -* If you see an error message bringing up the containers that has something like "port is already allocated", it means that another application is already using one of the ports. You can set alternate ports in `.env` (see [Confguration](#Configuration)). diff --git a/docs/tools/lando.md b/docs/tools/lando.md new file mode 100644 index 0000000..7142358 --- /dev/null +++ b/docs/tools/lando.md @@ -0,0 +1,42 @@ +Docker +====== + +[Lando](https://docs.lando.dev/) is an local development platform for developers. It is software that lives on your local machine that allows you to run preconfigured development environments without extensive configuration. + +Installing +---------- +You must have `lando` installed on your local machine before using the Lando environments. + +Installers for Windows, Mac, and various Linux distributions can be found on the [releases page](https://github.com/lando/lando/releases). Generally the newest release available is preferred. + +Configuration +------------- +All Docker configuration for this project lives in the [`.lando.yml`](/.lando.yml) file in the repository root. You may customize this file to suit the needs of the project. + +Running +------- +Use the `lando` command on your host to interact with Lando. + +* Start all containers: `docker-compose start` +* View lando service info: `lando info` +* Stop all containers: `lando stop` +* Rebuild all services: `lando rebuild` +* Output the logs of the `lando` services: `lando logs`, `lando logs -s appserver` +* Remove all containers to reset your environment: `lando destroy` + +Accessing the Containers +------------------------ +When the containers are running, they are accessible on the following ports: + +* **8080**: Direct connection to Drupal running on Apache. +* **33306**: Direct connection to MySQL. Useful for connecting to the database from the host machine. A direct mysql connection can be made from the outside via: `mysql -h 127.0.0.1 --port 33306 -u drupal -pdrupal drupal` + +Optional containers (must be enabled before you can use them): +* **8085**: Varnish, connected to Drupal. If you want to use Varnish, uncomment it in `docker-compose.yml` +* **8983**: Solr direct connection. Useful for debugging via Apache Solr web interface. + +Important: Should you choose to run this setup in production, you should always remove the debug ports (noted in `docker-compose.yml`) for security. + +Troubleshooting +--------------- +* If you see an error message bringing up the containers that has something like "port is already allocated", it means that another application is already using one of the ports. You can set alternate ports in `.env` (see [Confguration](#Configuration)). From a6fe26cc2f6e249a59f793ccf952138b425a1d13 Mon Sep 17 00:00:00 2001 From: Jeff Landfried Date: Tue, 10 Mar 2020 15:35:08 -0400 Subject: [PATCH 18/28] add mannequin service --- .lando.yml | 8 ++++++++ .mannequin.php | 3 ++- docs/tools/mannequin.md | 27 +++++++++++++++++++++++++-- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/.lando.yml b/.lando.yml index 0c6351a..e5a7272 100644 --- a/.lando.yml +++ b/.lando.yml @@ -6,6 +6,9 @@ config: via: nginx drush: ^8 xdebug: false +proxy: + mannequin: + - mannequin.lndo.site services: appserver: build: @@ -16,6 +19,11 @@ services: - 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 tooling: gulp: service: node diff --git a/.mannequin.php b/.mannequin.php index 685f0ae..5c09e3b 100644 --- a/.mannequin.php +++ b/.mannequin.php @@ -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', diff --git a/docs/tools/mannequin.md b/docs/tools/mannequin.md index a11c040..e4b3c2d 100644 --- a/docs/tools/mannequin.md +++ b/docs/tools/mannequin.md @@ -6,8 +6,31 @@ Configuration ------------- Mannequin is configured in `.mannequin.php`. Mannequin metadata is added to theme templates as YAML comment blocks. +Accessing +--------- +Mannequin is configured as a mannequin service, and can be accessed at https://mannequin.lndo.site + +This is using mannequin in "server" mode, so it watches for changes and will automatically update as templates css changes + Uninstalling ------------ 1. Run `composer remove --dev lastcall/mannequin-drupal`. -2. Run `git rm .mannequin.php`. -3. Commit changes. +1. Run `git rm .mannequin.php`. +1. Remove the following sections from `.lando.yml` + * + ``` + proxy: + mannequin: + - mannequin.lndo.site + ``` + * + ``` + services: + mannequin: + type: compose + services: + image: devwithlando/php:7.3-apache + command: docker-php-entrypoint /app/vendor/bin/mannequin start -c /app/.mannequin.php *:80 + ``` + +1. Commit changes. From 37902c9b912f2dc29961d622661718157a685887 Mon Sep 17 00:00:00 2001 From: Jeff Landfried Date: Tue, 10 Mar 2020 15:37:56 -0400 Subject: [PATCH 19/28] mark mannequin service complete --- TODO.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/TODO.md b/TODO.md index 1481abe..f66cf6b 100644 --- a/TODO.md +++ b/TODO.md @@ -6,18 +6,18 @@ TODO - [x] WDIO: - Disable, remove WDIO configuration - Documentation at docs/tools/wdio.md -- [ ] MANNEQUIN: - - Add mannequin service to Lando config +- [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 + - 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 +- [ ] 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` - - Remove `docker` directory + - Remove `docker` directory - [ ] LOCAL DEVELOPMENT TOOLS: - Determine if we need the `site-import` tooling in `appserver` - If yes: From 81c6949079d437abe5893e3d965ad8dd2e8ed5a4 Mon Sep 17 00:00:00 2001 From: Jeff Landfried Date: Wed, 11 Mar 2020 13:50:08 -0400 Subject: [PATCH 20/28] Add lando-specific settings file, remove docker-compose version --- web/sites/default/settings.docker.php | 42 --------------------------- web/sites/default/settings.lando.php | 12 ++++++++ web/sites/default/settings.php | 4 +-- 3 files changed, 14 insertions(+), 44 deletions(-) delete mode 100644 web/sites/default/settings.docker.php create mode 100644 web/sites/default/settings.lando.php diff --git a/web/sites/default/settings.docker.php b/web/sites/default/settings.docker.php deleted file mode 100644 index 673e7d8..0000000 --- a/web/sites/default/settings.docker.php +++ /dev/null @@ -1,42 +0,0 @@ - 'mysql', - 'collation' => 'utf8mb4_general_ci', - 'host' => getenv('MYSQL_HOST') ?: 'mysql', - 'database' => getenv('MYSQL_DATABASE'), - 'username' => getenv('MYSQL_USER'), - 'password' => getenv('MYSQL_PASSWORD'), -]; - -// Important: set a consistent cache prefix. Otherwise, -// prefix will be different between drush and web runs. -$prefix = sprintf("%s:%s", getenv('SITE_NAME'), getenv('DOCKER_ENV')); -$settings['cache_prefix'] = $prefix; -$settings['hash_salt'] = getenv('DRUPAL_HASH_SALT') ?: 'insecurehashsalt'; -$config['search_api_solr.settings']['site_hash'] = $prefix; - -// Allow any docker container to serve as a reverse -// proxy for this one. -$settings['reverse_proxy'] = TRUE; -$settings['reverse_proxy_addresses'] = ['172.0.0.0/8']; - -if(FALSE !== getenv('CACHE_HOST')) { - $settings['redis.connection']['interface'] = 'PhpRedis'; - $settings['redis.connection']['base'] = getenv('CACHE_BASE') ?: 0; - $settings['redis.connection']['host'] = getenv('CACHE_HOST') ?: 'redis'; - $settings['redis.connection']['port'] = getenv('CACHE_PORT') ?: 6379; - $settings['redis.connection']['password'] = getenv('CACHE_PASSWORD') ?: NULL; - - /** - * The following configuration can only be used after the Redis module - * has been enabled. It uses Redis as the primary cache bin, but uses - * the chainedfast (Redis + APCu) backend for frequently used items. - */ -// $settings['container_yamls'][] = __DIR__ .'/redis.services.yml'; -// $settings['cache']['default'] = 'cache.backend.redis'; -// $settings['cache']['bins']['bootstrap'] = 'cache.backend.chainedfast'; -// $settings['cache']['bins']['config'] = 'cache.backend.chainedfast'; -// $settings['cache']['bins']['discovery'] = 'cache.backend.chainedfast'; -} - diff --git a/web/sites/default/settings.lando.php b/web/sites/default/settings.lando.php new file mode 100644 index 0000000..122abce --- /dev/null +++ b/web/sites/default/settings.lando.php @@ -0,0 +1,12 @@ + 'drupal8', + 'username' => 'drupal8', + 'password' => 'drupal8', + 'prefix' => '', + 'host' => 'database', + 'port' => '3306', + 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', + 'driver' => 'mysql', +); diff --git a/web/sites/default/settings.php b/web/sites/default/settings.php index e937208..04fe4e4 100644 --- a/web/sites/default/settings.php +++ b/web/sites/default/settings.php @@ -22,8 +22,8 @@ require __DIR__.'/settings.pantheon.php'; // Load environment-specific configuration overrides, if applicable. -if(FALSE !== getenv('DOCKER_ENV') && file_exists(__DIR__ . '/settings.docker.php')) { - require __DIR__ . '/settings.docker.php'; +if((isset($_ENV['LANDO'])) && ($_ENV['LANDO'] === 'ON') && (file_exists(__DIR__ . '/settings.lando.php'))) { + require __DIR__ . '/settings.lando.php'; } // Include an optional local settings override. Assumes Pantheon is production From 19b1fae27f8a7e35f00e4c593b337acc05d27766 Mon Sep 17 00:00:00 2001 From: Jeff Landfried Date: Wed, 11 Mar 2020 13:50:55 -0400 Subject: [PATCH 21/28] add default readme for config dir --- config/README.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 config/README.txt diff --git a/config/README.txt b/config/README.txt new file mode 100644 index 0000000..e74ef61 --- /dev/null +++ b/config/README.txt @@ -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 From ba972b270775f999f7b2e85484ceb66226202110 Mon Sep 17 00:00:00 2001 From: Jeff Landfried Date: Wed, 11 Mar 2020 13:52:09 -0400 Subject: [PATCH 22/28] Add ability to pull latest database from pantheon using lando tooling. Move environment config from docker directory to .env --- .circleci/config.yml | 12 ++++++------ .env/default.private.env | 9 +++++++++ {docker => .env}/drupal.env | 8 +++++--- .gitignore | 2 +- .lando.yml | 13 +++++++++++++ CHANGELOG.md | 2 +- bin/create-artifact-environment-pantheon | 2 +- bin/refresh-local-pantheon | 6 +++--- docker-compose.yml | 8 ++++---- docs/scaffold.md | 4 ++-- src/Resources/manifests/scaffold.json | 2 +- 11 files changed, 46 insertions(+), 22 deletions(-) create mode 100644 .env/default.private.env rename {docker => .env}/drupal.env (84%) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1fa3ebf..33dde04 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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: # # * TERMINUS_SITE -# * TERMINUS_SOURCE_ENVIRONMENT +# * TERMINUS_ENV # version: 2.1 @@ -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'} @@ -105,14 +105,14 @@ jobs: 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: diff --git a/.env/default.private.env b/.env/default.private.env new file mode 100644 index 0000000..112c8f1 --- /dev/null +++ b/.env/default.private.env @@ -0,0 +1,9 @@ +# 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 diff --git a/docker/drupal.env b/.env/drupal.env similarity index 84% rename from docker/drupal.env rename to .env/drupal.env index 89b49db..508dff5 100644 --- a/docker/drupal.env +++ b/.env/drupal.env @@ -5,12 +5,14 @@ # Terminus, and will be used in several different workflows. # Machine name for site, used for setting cache prefix. -SITE_NAME=scaffold +#SITE_NAME=scaffold +SITE_NAME=wit-d8 # Machine name of Pantheon site. If you don't know, see the # "name" column of the `terminus sites` command. -TERMINUS_SITE=scaffold +#TERMINUS_SITE=scaffold +TERMINUS_SITE=wit-d8 # 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 diff --git a/.gitignore b/.gitignore index f737594..180e07c 100644 --- a/.gitignore +++ b/.gitignore @@ -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: diff --git a/.lando.yml b/.lando.yml index e5a7272..cea20bf 100644 --- a/.lando.yml +++ b/.lando.yml @@ -6,6 +6,9 @@ config: via: nginx drush: ^8 xdebug: false +env_file: + - .env/drupal.env + - .env/private.env proxy: mannequin: - mannequin.lndo.site @@ -13,6 +16,10 @@ services: appserver: build: - composer install + build_as_root: + - 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' node: type: node build: @@ -44,3 +51,9 @@ tooling: 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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e17487..149d5f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/bin/create-artifact-environment-pantheon b/bin/create-artifact-environment-pantheon index 25ebfa7..27e8faf 100755 --- a/bin/create-artifact-environment-pantheon +++ b/bin/create-artifact-environment-pantheon @@ -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 diff --git a/bin/refresh-local-pantheon b/bin/refresh-local-pantheon index 33099eb..cc11b22 100755 --- a/bin/refresh-local-pantheon +++ b/bin/refresh-local-pantheon @@ -12,7 +12,7 @@ Refresh your local environment from Pantheon. Options: -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). @@ -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 @@ -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" diff --git a/docker-compose.yml b/docker-compose.yml index d7fd8d4..7407766 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 @@ -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. diff --git a/docs/scaffold.md b/docs/scaffold.md index b4ecec7..e228843 100644 --- a/docs/scaffold.md +++ b/docs/scaffold.md @@ -26,7 +26,7 @@ Customizing your Project As soon as you're up and running, you will want to remove the references to the "scaffold" nature of this project and make it your own. - [ ] Set the name of your project under the `name` key in `composer.json` and `package.json`. You don't ever need to publish the project using Composer or NPM, but it will help new developers get oriented. - [ ] Rename the `scaffold` theme to something that fits your project. -- [ ] Open [`docker/drupal.env`](/docker/drupal.env) and set the environment variables there. +- [ ] Open [`.env/drupal.env`](/.env/drupal.env) and set the environment variables there. - [ ] Open [`web/private/scripts/deploy-steps.php`](/web/private/scripts/deploy-steps.php) and choose the deployment steps you want to use. - [ ] Copy [`.env.example`](/.env.example) to `.env` and optionally set the variables in this file. This file should not be committed. - [ ] Customize README.md by renaming, and removing everything above the horizontal rule. @@ -44,7 +44,7 @@ Upgrading an older project is a very manual process - once you start a project, - [ ] Run `composer upstream-files:update` to pull down the latest versions of all scaffold files and quasi-core files. REVIEW CAREFULLY BEFORE COMMITTING - you will definitely need to revert or manually merge some of the files. - [ ] Run `yarn install` to install NPM dependencies and create a `yarn.lock` file. - [ ] Cleanup any leftover files: `rm -rf default.behat.local.yml ci package-lock.json backstop phantomas ci circle.yml .travis.yml docker-compose.debug.yml web/drush` -- [ ] Open [`docker/drupal.env`](/docker/drupal.env) and set the environment variables there. +- [ ] Open [`.env/drupal.env`](/.env/drupal.env) and set the environment variables there. - [ ] Copy [`.env.example`](/.env.example) to `.env` and optionally set the variables in this file. This file should not be committed. - [ ] In CircleCI, add the `TERMINUS_MACHINE_TOKEN` variable (previously known as `PMACHINE`). - [ ] Push a new `p-` branch to GitHub to trigger a circle build, and create a new PR to review your changes. diff --git a/src/Resources/manifests/scaffold.json b/src/Resources/manifests/scaffold.json index e4058c9..9d0a205 100644 --- a/src/Resources/manifests/scaffold.json +++ b/src/Resources/manifests/scaffold.json @@ -11,7 +11,7 @@ "../../../behat.yml": "behat.yml", "../../../src/ComposerHandler.php": "src/ComposerHandler.php", "../../../docker/default.vcl": "docker/default.vcl", - "../../../docker/drupal.env": "docker/drupal.env", + "../../../.env/drupal.env": ".env/drupal.env", "../../../docker/mysql-extra.cnf": "docker/mysql-extra.cnf", "../../../docker-compose.yml": "docker-compose.yml", "../../../drush/drushrc.php": "drush/drushrc.php", From de3fb76d34b22fa17f7e92618d2a48ffc7ab57d1 Mon Sep 17 00:00:00 2001 From: Jeff Landfried Date: Wed, 11 Mar 2020 14:29:23 -0400 Subject: [PATCH 23/28] fix environment config, add back docker settings for CI --- .env/drupal.env | 6 ++-- web/sites/default/settings.docker.php | 41 +++++++++++++++++++++++++++ web/sites/default/settings.php | 4 +++ 3 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 web/sites/default/settings.docker.php diff --git a/.env/drupal.env b/.env/drupal.env index 508dff5..ec6fb14 100644 --- a/.env/drupal.env +++ b/.env/drupal.env @@ -5,13 +5,11 @@ # Terminus, and will be used in several different workflows. # Machine name for site, used for setting cache prefix. -#SITE_NAME=scaffold -SITE_NAME=wit-d8 +SITE_NAME=scaffold # Machine name of Pantheon site. If you don't know, see the # "name" column of the `terminus sites` command. -#TERMINUS_SITE=scaffold -TERMINUS_SITE=wit-d8 +TERMINUS_SITE=scaffold # Machine name of Pantheon environment to pull db from. This is # also the environment new multidev instances start from. diff --git a/web/sites/default/settings.docker.php b/web/sites/default/settings.docker.php new file mode 100644 index 0000000..a7ceca1 --- /dev/null +++ b/web/sites/default/settings.docker.php @@ -0,0 +1,41 @@ + 'mysql', + 'collation' => 'utf8mb4_general_ci', + 'host' => getenv('MYSQL_HOST') ?: 'mysql', + 'database' => getenv('MYSQL_DATABASE'), + 'username' => getenv('MYSQL_USER'), + 'password' => getenv('MYSQL_PASSWORD'), +]; + +// Important: set a consistent cache prefix. Otherwise, +// prefix will be different between drush and web runs. +$prefix = sprintf("%s:%s", getenv('SITE_NAME'), getenv('DOCKER_ENV')); +$settings['cache_prefix'] = $prefix; +$settings['hash_salt'] = getenv('DRUPAL_HASH_SALT') ?: 'insecurehashsalt'; +$config['search_api_solr.settings']['site_hash'] = $prefix; + +// Allow any docker container to serve as a reverse +// proxy for this one. +$settings['reverse_proxy'] = TRUE; +$settings['reverse_proxy_addresses'] = ['172.0.0.0/8']; + +if(FALSE !== getenv('CACHE_HOST')) { + $settings['redis.connection']['interface'] = 'PhpRedis'; + $settings['redis.connection']['base'] = getenv('CACHE_BASE') ?: 0; + $settings['redis.connection']['host'] = getenv('CACHE_HOST') ?: 'redis'; + $settings['redis.connection']['port'] = getenv('CACHE_PORT') ?: 6379; + $settings['redis.connection']['password'] = getenv('CACHE_PASSWORD') ?: NULL; + + /** + * The following configuration can only be used after the Redis module + * has been enabled. It uses Redis as the primary cache bin, but uses + * the chainedfast (Redis + APCu) backend for frequently used items. + */ +// $settings['container_yamls'][] = __DIR__ .'/redis.services.yml'; +// $settings['cache']['default'] = 'cache.backend.redis'; +// $settings['cache']['bins']['bootstrap'] = 'cache.backend.chainedfast'; +// $settings['cache']['bins']['config'] = 'cache.backend.chainedfast'; +// $settings['cache']['bins']['discovery'] = 'cache.backend.chainedfast'; +} diff --git a/web/sites/default/settings.php b/web/sites/default/settings.php index 04fe4e4..6cc3d2e 100644 --- a/web/sites/default/settings.php +++ b/web/sites/default/settings.php @@ -22,6 +22,10 @@ require __DIR__.'/settings.pantheon.php'; // Load environment-specific configuration overrides, if applicable. +if(FALSE !== getenv('DOCKER_ENV') && file_exists(__DIR__ . '/settings.docker.php')) { + require __DIR__ . '/settings.docker.php'; +} + if((isset($_ENV['LANDO'])) && ($_ENV['LANDO'] === 'ON') && (file_exists(__DIR__ . '/settings.lando.php'))) { require __DIR__ . '/settings.lando.php'; } From 35cee91a02dc3228741a4f936a073a995cf73e62 Mon Sep 17 00:00:00 2001 From: Jeff Landfried Date: Wed, 11 Mar 2020 14:37:22 -0400 Subject: [PATCH 24/28] indicate that we removed docker directory (moved to .env/) and added lando tooling for importing from pantheon --- TODO.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/TODO.md b/TODO.md index f66cf6b..2da89b3 100644 --- a/TODO.md +++ b/TODO.md @@ -16,10 +16,10 @@ TODO - [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` - - Remove `docker` directory -- [ ] LOCAL DEVELOPMENT TOOLS: + - [ ] Remove `docker-compose.yml` + - [x] Remove `docker` directory +- [x] LOCAL DEVELOPMENT TOOLS: - Determine if we need the `site-import` tooling in `appserver` - If yes: - - Add terminus commands and scripts for importing a database - - Add acquia API commands for importing databases + - [x] Add terminus commands and scripts for importing a database + - [ ] Add acquia API commands for importing databases From 70ff7cab7f335ab4160d9f190071556c69b4cd7d Mon Sep 17 00:00:00 2001 From: Jeff Landfried Date: Wed, 11 Mar 2020 14:38:26 -0400 Subject: [PATCH 25/28] we don't already have an acquia import, so we're not recreating it for this purpose --- TODO.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TODO.md b/TODO.md index 2da89b3..6f8e1ed 100644 --- a/TODO.md +++ b/TODO.md @@ -22,4 +22,4 @@ TODO - 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 + - ~~[ ] Add acquia API commands for importing databases~~ From 9413c42f77e824940dd1a6316cac45e3ef728239 Mon Sep 17 00:00:00 2001 From: Jeff Landfried Date: Fri, 13 Mar 2020 10:26:23 -0400 Subject: [PATCH 26/28] Blackfire WIP. Remaining step is to have a way to ensure that `blackfire-agent` is always running. --- .env/default.private.env | 8 ++++++++ .lando.yml | 13 ++++++++++--- .lando/config/php.ini | 28 ++++++++++++++++++++++++++++ .lando/init/blackfire.sh | 23 +++++++++++++++++++++++ .lando/init/terminus.sh | 5 +++++ 5 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 .lando/config/php.ini create mode 100755 .lando/init/blackfire.sh create mode 100755 .lando/init/terminus.sh diff --git a/.env/default.private.env b/.env/default.private.env index 112c8f1..3e45403 100644 --- a/.env/default.private.env +++ b/.env/default.private.env @@ -7,3 +7,11 @@ # 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 diff --git a/.lando.yml b/.lando.yml index cea20bf..191ca44 100644 --- a/.lando.yml +++ b/.lando.yml @@ -16,10 +16,14 @@ services: appserver: build: - composer install + config: + conf: .lando/init/php.ini build_as_root: - - 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' + - .lando/init/terminus.sh + - .lando/init/blackfire.sh + run_as_root: + # TODO: This doesn't seem to run at the correct time to ensure that blackfire-agent is running after a service rebuild. + - "/etc/init.d/blackfire-agent restart" node: type: node build: @@ -57,3 +61,6 @@ tooling: service: appserver description: Updates the database from the latest Pantheon backup cmd: bin/refresh-local-pantheon + blackfire: + service: appserver + user: root diff --git a/.lando/config/php.ini b/.lando/config/php.ini new file mode 100644 index 0000000..f74e7ad --- /dev/null +++ b/.lando/config/php.ini @@ -0,0 +1,28 @@ +# Blackfire Suggestions + +[blackfire] +; Enterprise does not have the option to update Blackfire settings via .platform.app.yaml +; We're giving ourselves auto-update capabilities here + +; Sets the socket where the agent is listening. +; Possible value can be a unix socket or a TCP address. +; Defaults to unix:///var/run/blackfire/agent.sock on Linux, +; unix:///usr/local/var/run/blackfire-agent.sock on MacOSX, +; and to tcp://127.0.0.1:8307 on Windows. +; blackfire.agent_socket = unix:///var/run/blackfire/agent.sock + +; Log verbosity level (4: debug, 3: info, 2: warning, 1: error) +; blackfire.log_level = 4 + +; Log file (STDERR by default) +; blackfire.log_file = "${LANDO_MOUNT}"/log/blackfire.log + +; Sets fine-grained configuration for Probe. +; This should be left blank in most cases. For most installs, +; the server credentials should only be set in the agent. +blackfire.server_id="${BLACKFIRE_SERVER_ID}" + +; Sets fine-grained configuration for Probe. +; This should be left blank in most cases. For most installs, +; the server credentials should only be set in the agent. +blackfire.server_token="${BLACKFIRE_SERVER_TOKEN}" diff --git a/.lando/init/blackfire.sh b/.lando/init/blackfire.sh new file mode 100755 index 0000000..8168197 --- /dev/null +++ b/.lando/init/blackfire.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# Configure Blackfire Repository +wget -q -O - https://packagecloud.io/gpg.key | apt-key add - +echo 'deb http://packages.blackfire.io/debian any main' | tee /etc/apt/sources.list.d/blackfire.list +apt-get update + +# Install Blackfire Agent +apt-get --yes --force-yes install blackfire-agent +printf "%s\n" $BLACKFIRE_CLIENT_ID $BLACKFIRE_CLIENT_TOKEN | blackfire config + +# Install Blackfire Probe +version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") +curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$version +tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp +mv /tmp/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so + +# Enable Blackfire Probe +docker-php-ext-enable blackfire + +# Start blackfire on-boot +# TODO: this doesn't seem to run at the correct time to ensure that blackfire-agent is running when the service is rebuilt. +/etc/init.d/blackfire-agent restart diff --git a/.lando/init/terminus.sh b/.lando/init/terminus.sh new file mode 100755 index 0000000..cf06e47 --- /dev/null +++ b/.lando/init/terminus.sh @@ -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 From aaadd558e66be4c274757417f7ef87ad669ee2bf Mon Sep 17 00:00:00 2001 From: Jeff Landfried Date: Fri, 13 Mar 2020 10:39:47 -0400 Subject: [PATCH 27/28] update blackfire docs to describe how to use it with lando --- docs/tools/blackfire.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/tools/blackfire.md b/docs/tools/blackfire.md index d5d421a..7f1fc1c 100644 --- a/docs/tools/blackfire.md +++ b/docs/tools/blackfire.md @@ -4,16 +4,19 @@ Blackfire Configuration ------------- -Blackfire is already set up, but profiling requires the entry of your client and server tokens in the `.env` file. See https://blackfire.io to sign up (free) and get those tokens. +Blackfire is already set up, but profiling requires the entry of your client and server tokens in the `.lando/env/private.env` file. See https://blackfire.io to sign up (free) and get those tokens from https://blackfire.io/my/settings/credentials. Running ------- -* From the Drupal container: `blackfire curl http://127.0.0.1/my/page` will run a profile of `/my/page`. -* From the Drupal container: `blackfire run php myscript.php` will run a profile of `myscript.php`. +* From the host: `lando blackfire curl -k https://drupal-scaffold.lndo.site/my/page` will run a profile of `/my/page`. +* From the host: `lando blackfire run php myscript.php` will run a profile of `myscript.php`. Uninstalling ------------ -1. Remove your Blackfire tokens from the `.env` file. -2. Remove the blackfire container from `docker-compose.yml` -3. Remove the BLACKFIRE_* environment variables from `docker-compose.yml`. +1. Remove your Blackfire tokens from the `.lando/env/private.env` file. +2. Remove the blackfire config from `.lando.yml`: + - `build_as_root` in `appserver` service override: remove `.lando/init/blackfire.sh` step + - `config` in `appserver` service override: remove `conf: .lando/init/php.ini` + - TODO: Any other steps in `.lando.yml` that need to be removed? 4. Commit the changes. +5. Rebuild appserver lando service `lando rebuild -s appserver` From 237db6cf91471d027ff4cd1b0bb469c5f75c1f3d Mon Sep 17 00:00:00 2001 From: Rob Bayliss Date: Tue, 26 May 2020 18:08:54 -0400 Subject: [PATCH 28/28] Use external blackfire agent, install only probe/cli on appserver --- .lando.yml | 23 ++++++++++++++++++----- .lando/config/php.ini | 28 ---------------------------- .lando/init/blackfire.sh | 27 +++++++-------------------- 3 files changed, 25 insertions(+), 53 deletions(-) delete mode 100644 .lando/config/php.ini diff --git a/.lando.yml b/.lando.yml index 191ca44..60493e5 100644 --- a/.lando.yml +++ b/.lando.yml @@ -16,14 +16,14 @@ services: appserver: build: - composer install - config: - conf: .lando/init/php.ini build_as_root: - .lando/init/terminus.sh - .lando/init/blackfire.sh - run_as_root: - # TODO: This doesn't seem to run at the correct time to ensure that blackfire-agent is running after a service rebuild. - - "/etc/init.d/blackfire-agent restart" + overrides: + environment: + BLACKFIRE_CLIENT_ID: + BLACKFIRE_CLIENT_TOKEN: + node: type: node build: @@ -35,6 +35,19 @@ services: 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 diff --git a/.lando/config/php.ini b/.lando/config/php.ini deleted file mode 100644 index f74e7ad..0000000 --- a/.lando/config/php.ini +++ /dev/null @@ -1,28 +0,0 @@ -# Blackfire Suggestions - -[blackfire] -; Enterprise does not have the option to update Blackfire settings via .platform.app.yaml -; We're giving ourselves auto-update capabilities here - -; Sets the socket where the agent is listening. -; Possible value can be a unix socket or a TCP address. -; Defaults to unix:///var/run/blackfire/agent.sock on Linux, -; unix:///usr/local/var/run/blackfire-agent.sock on MacOSX, -; and to tcp://127.0.0.1:8307 on Windows. -; blackfire.agent_socket = unix:///var/run/blackfire/agent.sock - -; Log verbosity level (4: debug, 3: info, 2: warning, 1: error) -; blackfire.log_level = 4 - -; Log file (STDERR by default) -; blackfire.log_file = "${LANDO_MOUNT}"/log/blackfire.log - -; Sets fine-grained configuration for Probe. -; This should be left blank in most cases. For most installs, -; the server credentials should only be set in the agent. -blackfire.server_id="${BLACKFIRE_SERVER_ID}" - -; Sets fine-grained configuration for Probe. -; This should be left blank in most cases. For most installs, -; the server credentials should only be set in the agent. -blackfire.server_token="${BLACKFIRE_SERVER_TOKEN}" diff --git a/.lando/init/blackfire.sh b/.lando/init/blackfire.sh index 8168197..873b2b8 100755 --- a/.lando/init/blackfire.sh +++ b/.lando/init/blackfire.sh @@ -1,23 +1,10 @@ #!/usr/bin/env bash +set -e -# Configure Blackfire Repository -wget -q -O - https://packagecloud.io/gpg.key | apt-key add - -echo 'deb http://packages.blackfire.io/debian any main' | tee /etc/apt/sources.list.d/blackfire.list -apt-get update +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 -# Install Blackfire Agent -apt-get --yes --force-yes install blackfire-agent -printf "%s\n" $BLACKFIRE_CLIENT_ID $BLACKFIRE_CLIENT_TOKEN | blackfire config - -# Install Blackfire Probe -version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") -curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$version -tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp -mv /tmp/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so - -# Enable Blackfire Probe -docker-php-ext-enable blackfire - -# Start blackfire on-boot -# TODO: this doesn't seem to run at the correct time to ensure that blackfire-agent is running when the service is rebuilt. -/etc/init.d/blackfire-agent restart +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