Commit 39f009f6 authored by Yas Naoi's avatar Yas Naoi
Browse files

Issue #3265796 by yas: Compile cloud_dashboard in .tugboat/config.yml

parent 16fadc4c
Loading
Loading
Loading
Loading
+59 −3
Original line number Diff line number Diff line
@@ -6,37 +6,54 @@ services:
    # depends: mysql
    depends: memcached
    commands:
      init: |
        cat /etc/issue
        curl -fsSL https://deb.nodesource.com/setup_16.x | bash -
        apt-get update && apt-get install -y gcc g++ make nodejs yarnpkg zlib1g \
          libfreetype6-dev libjpeg-dev libmemcached-dev libpng-dev libzip-dev
      update: |
        set -eux

        # Avoid an error: "Allowed memory size of 134217728 bytes exhausted"
        export PHP_INI='/usr/local/etc/php/conf.d/my-php.ini'
        echo 'memory_limit = -1' >> "${PHP_INI}"

        # Set up the max execution time.
        echo 'max_execution_time = 600' >> "${PHP_INI}"

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

        # Composer is hungry. You need a Tugboat project with a pretty sizeable
        # chunk of memory.
        export COMPOSER_MEMORY_LIMIT=-1

        # This is an environment variable we added in the Dockerfile that
        # provides the path to Drupal composer root (not the web root).
        cd "${DRUPAL_COMPOSER_ROOT}"

        # We configure the Drupal project to use the checkout of the module as a
        # Composer package repository.
        composer config repositories.tugboat vcs "${TUGBOAT_ROOT}"

        # Install Admin Toolbar.
        composer require drupal/admin_toolbar

        # Install Memcached.
        composer require drupal/memcache

        # Allow "minimum-stability": "dev" and "prefer-stable": true
        composer config minimum-stability dev
        composer config prefer-stable true

        # Now we can require drupal/cloud, specifing the branch name we created
        # above that uses the "${TUGBOAT_REPO_ID}" environment variable.
        composer require "drupal/cloud:dev-${TUGBOAT_REPO_ID}"

        # Set up a drush command.
        ln -s "$(pwd)/vendor/bin/drush" /usr/local/bin/

        # Install Drupal on the site.
        # Use --db-url=mysql://tugboat:tugboat@mysql:3306/tugboat for mysql connection.
        drush -y \
@@ -44,23 +61,28 @@ services:
          --site-name="Cloud Orchestrator live preview for '${TUGBOAT_PREVIEW_NAME}'" \
          --account-pass='admin' \
          si standard

        # Set up a files directory.
        export FILES_DIR='sites/default/files'
        mkdir -p "${DRUPAL_DOCROOT}/${FILES_DIR}"
        chgrp -R www-data "${DRUPAL_DOCROOT}/${FILES_DIR}"
        chmod 2775 "${DRUPAL_DOCROOT}/${FILES_DIR}"
        chmod -R g+w "${DRUPAL_DOCROOT}/${FILES_DIR}"

        # Set a private directory.
        export PRIVATE_DIR="${FILES_DIR}/private"
        mkdir -p "${PRIVATE_DIR}"
        chgrp -R www-data "${PRIVATE_DIR}"
        chmod 2775 "${PRIVATE_DIR}"
        chmod -R g+w "${PRIVATE_DIR}"

        # Set up $settings['file_private_path'] in settings.php
        export SETTINGS_FILE="${DRUPAL_DOCROOT}/sites/default/settings.php"
        echo "\$settings['file_private_path'] = '${PRIVATE_DIR}';" >> "${SETTINGS_FILE}"

        # Set up $settings['trusted_host_patterns'] in settings.php
        echo "\$settings['trusted_host_patterns'] = ['^.+\.tugboat\.qa$'];" >> "${SETTINGS_FILE}"

        # Enable the Cloud family modules.
        drush -y en cloud cloud_dashboard
        drush -y en aws_cloud gapps
@@ -68,30 +90,51 @@ services:
        drush -y en openstack
        drush -y en terraform
        drush -y en vmware

        # Enable the other modules.
        drush -y en admin_toolbar
        drush -y en entity_export_csv
        drush -y en geocoder
        drush -y en simple_oauth

        # Enable the themes.
        drush -y then bootstrap_cloud
        drush -y then claro
        drush -y cset system.theme default bootstrap_cloud
        drush -y cset system.theme admin claro

        # Install Memcached libraries.
        apt-get install -y libmemcached-dev
        git clone https://github.com/php-memcached-dev/php-memcached /usr/src/php/ext/memcached
        cd /usr/src/php/ext/memcached
        docker-php-ext-configure memcached
        docker-php-ext-install memcached

        # Install APCU libraries.
        git clone https://github.com/krakjoe/apcu /usr/src/php/ext/apcu
        cd /usr/src/php/ext/apcu
        docker-php-ext-configure apcu
        docker-php-ext-install apcu
        # Install OpCache

        # Install OpCache.
        docker-php-ext-install -j "$(nproc)" opcache
        # Setup Memcache module

        # Install uploadprogress.
        pecl install uploadprogress
        git clone https://github.com/php/pecl-php-uploadprogress /usr/src/php/ext/uploadprogress
        cd /usr/src/php/ext/uploadprogress
        docker-php-ext-configure uploadprogress
        docker-php-ext-install uploadprogress

        # Install graphic libraries.
        docker-php-ext-configure gd \
          --with-freetype \
          --with-jpeg
        docker-php-ext-configure zip
        docker-php-ext-install -j "$(nproc)" \
          gd \
          zip

        # Setup Memcache module.
        drush en -y memcache memcache_admin
        tee -a "${SETTINGS_FILE}" > /dev/null <<EOF
        \$settings['memcache']['servers'] = ['memcached:11211' => 'default'];
@@ -99,21 +142,34 @@ services:
        \$settings['memcache']['key_prefix'] = '';
        \$settings['cache']['default'] = 'cache.backend.memcache';
        EOF

        # Setup crontab.
        { echo '*/5 * * * * www-data cd /var/www/cloud_orchestrator && /usr/local/bin/drush cron > /dev/null 2>&1'; } >> /etc/crontab
        { echo '*/5 * * * * www-data cd /var/www/html/web && for MODULE in '\''aws_cloud'\'' '\''k8s'\'' '\''openstack'\'' '\''vmware'\'' '\''terraform'\''; do export QUEUE=$(drush queue-list | grep "$''{MODULE}" | awk '\''{print $1}'\''); if [ "$''{QUEUE}" ]; then drush queue-run "$''{QUEUE}" --time-limit=120 > /dev/null 2>&1; fi done'; } >> /etc/crontab
      build: |
        set -eux

        # Delete and re-check out this branch in case this is built from a Base Preview.
        git checkout 5.x && git branch -D "${TUGBOAT_REPO_ID}" && git checkout -b "${TUGBOAT_REPO_ID}" || true
        export COMPOSER_MEMORY_LIMIT=-1
        cd "${DRUPAL_COMPOSER_ROOT}"
        composer install --optimize-autoloader

        # Update installed modules.
        composer update drupal/admin_toolbar
        composer update "drupal/cloud:dev-${TUGBOAT_REPO_ID}" --with-all-dependencies
        composer update drupal/memcache

        # Build and install cloud_dashboard.
        export NODE_PATH='/usr/lib/nodejs:/usr/share/nodejs'
        cd "${DRUPAL_DOCROOT}/modules/contrib/cloud/modules/cloud_dashboard/cloud_dashboard"
        npm install -g npm@8.3.0
        npm install babel-runtime
        ln -s /usr/bin/yarnpkg /usr/bin/yarn
        ./build.sh

        # Update databases and clear cache.
        cd "${DRUPAL_DOCROOT}"
        drush -y updb
        drush cr
  # mysql:
+1 −1
Original line number Diff line number Diff line
# Build cloud_dashboard
export YARN='yarn'
if [ $(echo cat /etc/issue | grep -e Debian -e Ubuntu) ]; then
if [ "$(cat /etc/issue | grep -e Debian -e Ubuntu)" ]; then
  export YARN='yarnpkg'
fi