Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Drupal VM for Drupal 8 Dev - MidCamp 2017

1,329 views

Published on

These slides were used in my presentation "Developing for Drupal 8 with Drupal VM", given at MidCamp in Chicago, IL on 2017-04-01.

Learn how to build a modern Drupal 8 website using Composer and Drupal VM for local and prod!

Published in: Software
  • Be the first to comment

  • Be the first to like this

Drupal VM for Drupal 8 Dev - MidCamp 2017

  1. 1. DRUPAL VM A VM for Drupal development, built with Vagrant + Ansible ★ #MidCamp 2017 – Jeff Geerling
  2. 2. @geerlingguy • Drupalist ...of genus Acquian • Writer • Automator of things
  3. 3. DRUPAL VM • Info: www.drupalvm.com • Docs: docs.drupalvm.com • Code: GitHub
  4. 4. DRUPAL VM • Quick Start: 1. Install VirtualBox and Vagrant 2. Download Drupal VM 3. vagrant up
  5. 5. HOW DO I BUILD AND MAINTAIN DRUPAL 8 PROJECTS?
  6. 6. Drush was never designed as a dependency management tool.
  7. 7.
  8. 8. DRUPAL-PROJECT $ composer create-project drupal-composer/drupal-project:8.x-dev bacon --stability dev --no-interaction
  9. 9. DRUPAL VM composer require --dev geerlingguy/drupal-vm
  10. 10. PREP THE VM --- vagrant_hostname: local.bacon.com drupal_build_composer_project: false drupal_build_composer: false drupal_composer_dependencies: [] installed_extras: - drush - drupalconsole - mailhog - nodejs - xdebug - varnish vm/config.yml {
  11. 11. PREP DRUPAL PROJECT ENV['DRUPALVM_PROJECT_ROOT'] = "#{__dir__}" ENV['DRUPALVM_CONFIG_DIR'] = "vm" ENV['DRUPALVM_DIR'] = "vendor/geerlingguy/drupal-vm" # Load Drupal VM's Vagrantfile load "#{__dir__}/#{ENV['DRUPALVM_DIR']}/Vagrantfile" Vagrantfile {
  12. 12. vagrant up
  13. 13. WHAT ABOUT PROD?
  14. 14. WHAT ABOUT PROD? --- # Deploy from the project's Git repository. drupal_deploy: true drupal_deploy_repo: "git@github.com:my/bacon.git" drupal_deploy_dir: /var/www/drupal # Set the domain for this site appropriately. drupal_domain: "prod.bacon.com" vagrant_hostname: "{{ drupal_domain }}" vm/prod.config.yml {
  15. 15. WHAT ABOUT PROD? $ DRUPALVM_ENV=prod 
 ansible-playbook -i vm/inventory 
 vendor/geerlingguy/drupal-vm/provisioning/playbook.yml 
 -e "config_dir=$(pwd)/vm" 
 --become --ask-become-pass 
 --ask-vault-pass
  16. 16. WHAT ABOUT PROD? • Dogfooding: project is on GitHub • Everybody loves secrets (.yml) • Full writeup on my blog:
 https://www.jeffgeerling.com/drupal-vm-local-prod
  17. 17. GOING DEEPER
  18. 18. EXAMPLE: SOLR SEARCH
  19. 19. EXAMPLE: SOLR SEARCH • Step 1: Add Solr to Drupal VM • Add solr to installed_extras • Copy Drupal VM's example configure-solr.sh to scripts/configure-solr.sh • Add script to vm/config.yml: post_provision_scripts:
 - "../../../../scripts/configure-solr.sh"
  20. 20. EXAMPLE: SOLR SEARCH • Step 2: Add Drupal modules composer require drupal/search_api:^1.0 drupal/search_api_solr:^1.0 drush @local.example.com en -y search_api search_api_solr search_api_solr_defaults
  21. 21. EXAMPLE: SOLR SEARCH • Step 3: Export the config and deploy! • Disable Search API Solr Defaults module • Export: drush @local.bacon.com cex -y • Commit and push • Deploy: Run the playbook on prod!
  22. 22. It's alive!!!
  23. 23. EXAMPLE: BEHAT TESTS
  24. 24. EXAMPLE: BEHAT TESTS
  25. 25. EXAMPLE: BEHAT TESTS • Step 1: Add Selenium to Drupal VM • Add selenium to installed_extras
  26. 26. EXAMPLE: BEHAT TESTS • Step 2: Add Drupal Extension composer require --dev drupal/drupal-extension
  27. 27. EXAMPLE: BEHAT TESTS • Step 3: Configure Behat (behat.yml) • Add tests directory • Copy the config from Drupal VM's docs • Paste into new tests/behat.yml
  28. 28. EXAMPLE: BEHAT TESTS • Step 4: Initialize Behat • Log into VM • cd into tests • Run ../vendor/bin/behat init
  29. 29. EXAMPLE: BEHAT TESTS • Step 5: Test ALL THE THINGS! • Create feature files in tests/features/web • Example: HomeContent.feature
  30. 30. EXAMPLE: BEHAT TESTS Feature: Test DrupalContext In order to prove Behat is working correctly in Drupal VM
 As a developer
 I need to run a simple interface test Scenario: Viewing content in a region
 Given I am on the homepage
 Then I should see "This is a demonstration" in the "content"
  31. 31. EXAMPLE: BEHAT TESTS
  32. 32. WINDOWS
  33. 33. WINDOWS 😭
  34. 34. WINDOWS 🤗
  35. 35. WINDOWS • Use SMB, rsync, or reverse-mount shared folders • Use WSL/Ubuntu Bash and/or Cmder • Use Unix line endings • Read the docs
  36. 36. • DRUPALVM_ANSIBLE_TAGS=xdebug vagrant provision • Tideways is the new XHProf • Configure ALL THE THINGS in Vagrantfile.local • Add custom pre/post-provision playbooks • Test your modules with PAReview.sh BONUS ROUND!
  37. 37. THE FUTURE • Docker & Libvirt/KVM • Easier config template customization • Certbot + LetsEncrypt (TLS FTW) • MOAR Composer • MOAR Windows
  38. 38. THANKS! • Review this session:
 https://joind.in/talk/8f8fa • Support my work on Patreon:
 https://www.patreon.com/geerlingguy

×