services:
  php:
    image: tugboatqa/php:7.3-apache
    default: true
    http: false
    depends: mysql
    commands:
      update:
        - docker-php-ext-install opcache
        - a2enmod headers rewrite
        # $DOCROOT = /var/www/html
        # $TUGBOAT_ROOT = /var/lib/tugboat
        - echo $TUGBOAT_REPO_ID
        - export COMPOSER_MEMORY_LIMIT=-1
        # Install drush.
        - composer --no-ansi global require drush/drush:8.1.17
        - ln -sf ~/.composer/vendor/bin/drush /usr/local/bin/drush
        # Download and expand Drupal.
        - curl -L https://ftp.drupal.org/files/projects/drupal-7.79.tar.gz --output ${DOCROOT}/drupal-7.79.tar.gz
        - cd $DOCROOT && tar -xzf ${DOCROOT}/drupal-7.79.tar.gz -C $DOCROOT
        - cd $DOCROOT && mv drupal-7.79/* .
        - cd $DOCROOT && mv drupal-7.79/.htaccess .
        - cd $DOCROOT && drush site-install standard -y --db-url=mysql://tugboat:tugboat@mysql:3306/tugboat --site-name="Live preview for ${TUGBOAT_PREVIEW_NAME}" --account-pass=admin --account-name=admin
        # Download and extract Jquery colorpicker library.
        - curl -L https://www.eyecon.ro/colorpicker/colorpicker.zip --output ${DOCROOT}/colorpicker.zip
        - cd $DOCROOT && unzip ${DOCROOT}/colorpicker.zip -d $DOCROOT/sites/all/libraries/colorpicker
        # Make the module available.
        - cd $DOCROOT && ln -s $TUGBOAT_ROOT sites/all/modules/eu-cookie-compliance
        # Set permissions on the files dir.
        - cd $DOCROOT && chgrp -R www-data "sites/default/files"
        - cd $DOCROOT && chmod 2775 sites/default/files
        - cd $DOCROOT && chmod -R g+w sites/default/files
        # Download and enable modules.
        - drush -r "${DOCROOT}" pm-download ctools jquery_colorpicker smart_ip
        - drush -r "${DOCROOT}" pm-enable --yes ctools jquery_colorpicker smart_ip eu_cookie_compliance
        - drush -r "${DOCROOT}" pm-disable --yes overlay
        # Temporarily print a uli for login since we can't post any forms.
        - drush -r "${DOCROOT}" uli 1
      build:
        - set -eux
        - git branch -D $TUGBOAT_REPO_ID && git checkout -b $TUGBOAT_REPO_ID || true
        - drush -r "${DOCROOT}" --yes updb
        - drush -r "${DOCROOT}" cache-clear all
  mysql:
    image: tugboatqa/mysql:5
