Commit dfa0fccc authored by Yas Naoi's avatar Yas Naoi
Browse files

Issue #3281500 by yas: Refactor .tugboat/config.yml for live previews

parent 8f8fc74b
Loading
Loading
Loading
Loading
+32 −11
Original line number Diff line number Diff line
services:
  php:
    image: q0rban/tugboat-drupal:latest
    image: q0rban/tugboat-drupal:9.4
    privileged: true
    default: true
    http: false
    depends: memcached
    # depends: mysql
    commands:
      init: |
        set -eux

        curl -fsSL https://deb.nodesource.com/setup_16.x | bash -
        apt-get update > /dev/null 2>&1 && \
        apt-get install -y gcc g++ make nodejs yarnpkg \
          zlib1g \
        apt-get install -y --no-install-recommends gcc g++ make nodejs yarnpkg \
          cron \
          git \
          libfreetype6-dev \
          libjpeg-dev \
          libmemcached-dev \
          libpng-dev \
          libzip-dev > /dev/null 2>&1
      update: |
        set -eux
          libzip-dev \
          sqlite3 \
          unzip \
          zip \
          zlib1g > /dev/null 2>&1

        # Avoid an error: "Allowed memory size of 134217728 bytes exhausted"
        export PHP_INI='/usr/local/etc/php/conf.d/my-php.ini'
@@ -34,7 +40,6 @@ services:

        # Check out a branch using the unique Tugboat ID for this repository, to
        # ensure we don't clobber an existing branch.
        export GIT_REPO_DIR="$(pwd)"
        git checkout -b "${TUGBOAT_REPO_ID}"

        # Install Memcached libraries.
@@ -52,7 +57,7 @@ services:
        docker-php-ext-install -j "$(nproc)" opcache > /dev/null 2>&1

        # Install uploadprogress.
        pecl install uploadprogress
        pecl install uploadprogress > /dev/null 2>&1
        docker-php-ext-enable uploadprogress > /dev/null 2>&1

        # Install graphic libraries.
@@ -79,6 +84,11 @@ services:
        composer config minimum-stability dev
        composer config prefer-stable true

      update: |
        set -eux

        export GIT_REPO_DIR="$(pwd)"

        # Now we can require docomoinnovations/cloud_orchestrator
        cd /var/www && composer create-project docomoinnovations/cloud_orchestrator:5.x-dev cloud_orchestrator

@@ -127,7 +137,7 @@ services:
        # Install Drupal on the site.
        # Use --db-url=mysql://tugboat:tugboat@mysql:3306/tugboat for mysql connection.
        cd "${DRUPAL_DOCROOT}"
        drush si -y \
        drush -y si \
          --db-url="sqlite://${FILES_DIR}/db.sqlite" \
          --site-name="Cloud Orchestrator live preview for '${TUGBOAT_PREVIEW_NAME}'" \
          --account-pass='admin' \
@@ -163,8 +173,17 @@ services:
        EOF

        # Setup crontab.
        { echo '*/1 * * * * www-data cd "$''{DRUPAL_DOCROOT}" && /usr/local/bin/drush cron > /dev/null 2>&1'; } >> /etc/crontab
        { echo '*/15 * * * * www-data cd "$''{DRUPAL_DOCROOT}" && for MODULE in '\''vmware'\'' '\''terraform'\'' '\''openstack'\'' '\''k8s'\'' '\''aws_cloud'\''; do export QUEUES=$(drush queue-list --fields=queue | grep "$''{MODULE}" | sort -r); if [ "$''{QUEUES}" ]; then for QUEUE in $''{QUEUES}; do drush queue-run "$''{QUEUE}" --time-limit=300 > /dev/null 2>&1; done ; fi done'; } >> /etc/crontab
        DRUSH_QUEUE_RUN_SCRIPT="${DRUPAL_DOCROOT}/modules/contrib/cloud/scripts/drush_queue_run.sh"
        chmod +x "${DRUSH_QUEUE_RUN_SCRIPT}"
        tee /etc/crontab > /dev/null <<EOF
        SHELL=/bin/sh
        PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
        MAILTO=''

        */1 * * * * www-data cd '${DRUPAL_DOCROOT}'; drush cron > /dev/null 2>&1
        */15 * * * * www-data cd '${DRUPAL_DOCROOT}'; '${DRUSH_QUEUE_RUN_SCRIPT}' > /dev/null 2>&1
        EOF

      build: |
        set -eux

@@ -191,7 +210,9 @@ services:
        cd "${DRUPAL_DOCROOT}"
        drush -y updb
        drush cr

  # mysql:
  #   image: tugboatqa/mariadb

  memcached:
    image: tugboatqa/memcached