www.drupaleurope.org

GitLab (Auto)
Review Apps

with Drupal

Markus Orenstrat

DevOps and Backend Development

Become a Drupal contributor Friday from 9am

  • First timers workshop (2.07 aurum)
  • General contribution (spectrum B)
  • Mentored contribution (spectrum C)

Course of Session

  • Overview Review Apps
  • Demo Review Apps
  • Maybe a Screencast
  • Details (Configuration)
  • More Details (Code)

What are Review Apps?

  • One GitLab environment per branch
    • Static GitLab environments (master, develop)
    • Dynamic GitLab environments (feature branches)
  • Automatic Drupal instance per environment
    • Static for master and develop branch
      (only config updates)
    • Dynamic for feature branches
      (created, updated, deleted)

Why use Review Apps?

  • Simple (automatic) isolated tests and reviews
  • Easy feature approval
  • Present your work to...
    • Team members (developers)
    • Product Owner
    • Other Stakeholders

Why GitLab?

Why not provider XY?

  • Costs
  • Data protection
  • Flexibility
  • Integration

How to implement Review Apps

Shell, Docker or Kubernetes?

  • Complexity
  • Performance
  • Stability

Course of Session

  • Overview Review Apps
  • Demo Review Apps
  • Maybe a Screencast
  • Details (Configuration)
  • More Details (Code)

Requirements

  • GitLab Server and GitLab Runner
  • Wildcard DNS *.example.org
  • Linux with sudo, lvm2 and rsync
  • Apache or Nginx
  • MySQL or MariaDB
  • composer, drush
  • Drupal Runner

What is Drupal Runner?

  • Two client Bash scripts
    • .gitlab-ci.yml file
    • .env file
    • settings.php file
    • Drush Alias file
  • Two server Bash scripts
  • One server configuration file

Setup

  • GitLab Server (gitlab-ce.example)
  • GitLab Runner (gitlab-runner.example)
  • Workstation

Course of Session

  • Overview Review Apps
  • Demo Review Apps
  • Maybe a Screencast
  • Details (Configuration)
  • More Details (Code)

Course of Session

  • Overview Review Apps
  • Demo Review Apps
  • Maybe a Screencast
  • Details (Configuration)
  • More Details (Code)

Requirements

  • GitLab Server and GitLab Runner
  • Wildcard DNS *.example.org
  • Linux with sudo, lvm2 and rsync
  • Apache or Nginx
  • MySQL or MariaDB
  • composer, drush
  • Drupal Runner

GitLab Runner

  • GitLab CI Coordinator URL
  • GitLab CI Runner Token
  • GitLab CI Tags
  • Run untagged builds?
  • Lock to current project?
  • Executor (shell, docker, ...)

Apache

Module vhost_alias



          <VirtualHost *:80>
            ServerAlias *.gitlab-runner.example
            VirtualDocumentRoot /var/www/%1/web
          </VirtualHost>

        

MySQL / MariaDB



          CREATE USER 'gitlab-runner'@'localhost';

          GRANT ALL PRIVILEGES ON  `dr\_%` . * TO ↩
            'gitlab-runner'@'localhost';

        

Sudo



          /etc/sudoers.d/gitlab-runner:

          gitlab-runner ALL=(ALL) NOPASSWD: ↩
            /usr/local/bin/drupal-runner-sudo

        

Logical Volume Manager



          /etc/lvm/lvm.conf:

          activation {
            snapshot_autoextend_threshold = 70
            snapshot_autoextend_percent = 20
          }

        

Drupal Runner



          DRUPAL_RUNNER_BASE_DIR="/var/www"
          DRUPAL_RUNNER_LOGICAL_VOLUME_PREFIX="/dev/vg0/dr-"
          DRUPAL_RUNNER_DATABASE_PREFIX="dr_"

        

.gitlab-ci.yml


          variables:
            REVIEW_DOMAIN: gitlab-runner.example

          stages:
            - build
            - test
            - review
            - deploy

          build:
            stage: build
            script: /usr/local/bin/gitlab-runner build

          [...]
            

Course of Session

  • Overview Review Apps
  • Demo Review Apps
  • Maybe a Screencast
  • Details (Configuration)
  • More Details (Code)

Code, Screencast & presentation

https://gitlab.com/morenstrat/drupal-runner

https://youtu.be/psKRuZjz6NE

https://morenstrat.gitlab.io/drupal-runner