From e1ad954c6a1f20b8298209534f0a6e06aa0301bc Mon Sep 17 00:00:00 2001 From: Tim Cosgrove Date: Wed, 18 Dec 2024 11:17:40 -0800 Subject: [PATCH 1/8] Install and use the correct node version when starting Next Build. --- scripts/next-start.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/next-start.sh b/scripts/next-start.sh index 99f1e59994..3955b5f07e 100755 --- a/scripts/next-start.sh +++ b/scripts/next-start.sh @@ -10,5 +10,8 @@ cd next # Start the dev server. Vets-website assets will be available to the preview server after content-build builds them. # APP_ENV=tugboat yarn dev +# Install the correct node version if necessary and use it. +nvm install && nvm use + # Start the dev server. Vets-website assets need to be in place prior to this build. APP_ENV=tugboat yarn start From 98015349199bca086d7a2f6c7206795c94b9d5c6 Mon Sep 17 00:00:00 2001 From: Tim Cosgrove Date: Wed, 18 Dec 2024 12:28:54 -0800 Subject: [PATCH 2/8] Add nvm install to next-build.sh. --- scripts/next-build.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/next-build.sh b/scripts/next-build.sh index ff134cf6fe..364bdc4929 100755 --- a/scripts/next-build.sh +++ b/scripts/next-build.sh @@ -8,4 +8,7 @@ source ~/.bashrc cd next -APP_ENV=tugboat yarn build:preview \ No newline at end of file +# Install the correct node version if necessary and use it. +nvm install && nvm use + +APP_ENV=tugboat yarn build:preview From f88151114e352105684149f03c73b31087580597 Mon Sep 17 00:00:00 2001 From: Tim Cosgrove Date: Wed, 18 Dec 2024 13:29:46 -0800 Subject: [PATCH 3/8] Add nvm use to storybook & drupal theme build commands. --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index af7d3e5619..a45f9cf69b 100644 --- a/composer.json +++ b/composer.json @@ -610,12 +610,12 @@ ], "va:ds:drupal": [ "# Build the Drupal theme.", - "! ./scripts/should-run-directly.sh || (cd docroot/design-system && npm install && npm run build:drupal)", + "! ./scripts/should-run-directly.sh || (cd docroot/design-system && nvm use && npm install && npm run build:drupal)", "./scripts/should-run-directly.sh || ddev composer va:ds:drupal --" ], "va:ds:storybook": [ "# Build the Storybook.", - "! ./scripts/should-run-directly.sh || (cd docroot/design-system && npm install && npm run build:storybook)", + "! ./scripts/should-run-directly.sh || (cd docroot/design-system && nvm use && npm install && npm run build:storybook)", "./scripts/should-run-directly.sh || ddev composer va:ds:storybook --" ], "va:migrate:sync": [ From f4f847e35d56246d494134f695ad5eff5fb32297 Mon Sep 17 00:00:00 2001 From: Tim Cosgrove Date: Wed, 8 Jan 2025 18:22:50 -0800 Subject: [PATCH 4/8] Change Tugboat command to Next Start. --- tugboat.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tugboat.yml b/tugboat.yml index 0af8f93bac..36c59488bd 100644 --- a/tugboat.yml +++ b/tugboat.yml @@ -1,29 +1,29 @@ version: '3' -dotenv: ['.env'] +dotenv: [ '.env' ] output: 'group' tasks: build-storybook: desc: Build storybook cmds: - - composer va:ds:storybook + - composer va:ds:storybook build-frontend: desc: Request a frontend build cmds: - - drush va-gov-content-release:request:submit + - drush va-gov-content-release:request:submit - build-next: - desc: build next.js preview server + start-next: + desc: start next.js preview server cmds: - - composer va:next:build + - composer va:next:start build: deps: - - build-storybook - - build-frontend - - build-next + - build-storybook + - build-frontend + - start-next default: cmds: - - task: build + - task: build From d2469a444faaccd417a39eef8a93a905cb76c6c8 Mon Sep 17 00:00:00 2001 From: Tim Cosgrove Date: Wed, 29 Jan 2025 10:06:52 -0800 Subject: [PATCH 5/8] Move Next Build server start ahead of tests; mostly formatting changes. --- .tugboat/config.yml | 457 ++++++++++++++++++++++---------------------- 1 file changed, 226 insertions(+), 231 deletions(-) diff --git a/.tugboat/config.yml b/.tugboat/config.yml index 6e628ef6c4..4ec0802912 100644 --- a/.tugboat/config.yml +++ b/.tugboat/config.yml @@ -5,11 +5,10 @@ services: image: tugboatqa/php:8.1-apache-bookworm aliases: - - cms - - web - - storybook - - next - + - cms + - web + - storybook + - next # Set this as the default service. This does a few things # 1. Clones the git repository into the service container # 2. Exposes port 80 to the Tugboat HTTP proxy @@ -17,9 +16,8 @@ services: default: true depends: - - memcache - - mysql - + - memcache + - mysql # A set of commands to run while building this service commands: # Commands that set up the basic preview infrastructure @@ -28,156 +26,154 @@ services: # base previews are refreshed through the scheduled process! A manual # rebuild of the base preview is necessary. init: - - apt-get update - - # TODO: Add "Why" comment for Python, was this for the FE dependencies `yarn install`, if so which dependencies - # so we can remove if they are removed in the future. - #- apt-get install python - - # General useful development tools - - apt-get install jq nano - - # cypress-axe dependencies - https://docs.cypress.io/guides/getting-started/installing-cypress.html#System-requirements - - apt-get install libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb - - # Ensure GD has support for JPEG. - - apt-get install libjpeg-dev - - docker-php-ext-configure gd --with-jpeg --with-webp --with-freetype && docker-php-ext-install gd - - # Install php ZIP extension (drush 10 requires it). - - apt-get install libzip-dev zip - - docker-php-ext-install zip - - # Enable php intl extension - - docker-php-ext-install intl - - # Install opcache, and Apache modules - - docker-php-ext-install opcache - - a2enmod headers rewrite vhost_alias proxy proxy_http - # Install datadog agent for application tracing and profiling. - - DD_API_KEY=" " DD_INSTALL_ONLY=true DD_SITE="ddog-gov.com" bash -c "$(curl -L https://s3.amazonaws.com/dd-agent/scripts/install_script_agent7.sh)" - - # Install Datadog application tracing PHP extension - - php $(curl -w "%{filename_effective}" -LO $(curl -s https://api.github.com/repos/DataDog/dd-trace-php/releases | grep browser_download_url | grep 'setup[.]php' | head -n 1 | cut -d '"' -f 4)) --enable-profiling --php-bin=php - - # Setup web-*. vhost to serve static website. - - cp "${TUGBOAT_ROOT}"/.tugboat/vhost-web.conf /etc/apache2/sites-enabled/ - - # Setup storybook-*. vhost to serve static website. - - cp "${TUGBOAT_ROOT}"/.tugboat/vhost-storybook.conf /etc/apache2/sites-enabled/ - - # Setup next-*. vhost to serve static website. - - cp "${TUGBOAT_ROOT}"/.tugboat/vhost-next.conf /etc/apache2/sites-enabled/ - - # Configure KeepAliveTimeout in apache2.conf. This is set 5 seconds longer than the internal tools ALB. - # The internal tools ALB idle timeout is set to longer than a typical GQL query takes. - - sed -e 's/KeepAliveTimeout 5/KeepAliveTimeout 185/' -i /etc/apache2/apache2.conf - - # BRD Environments are set to 1G, Tugboat and Lando are -1 (unlimited). - - echo "memory_limit = 4G" >> /usr/local/etc/php/conf.d/my-php.ini - # Set unlimited memory limit for PHP CLI to allow Composer to run. - - echo "memory_limit = -1" >> /usr/local/etc/php/conf.d/php-cli.ini - - echo "max_execution_time = 1800" >> /usr/local/etc/php/conf.d/my-php.ini - - # Explicitly enable PHP 8 Opcache JIT (just-in-time compilation) - # https://stitcher.io/blog/php-8-jit-setup - - echo "opcache.enable_cli = 1" >> /usr/local/etc/php/conf.d/php-cli.ini - - echo "opcache.enable = 1" >> /usr/local/etc/php/conf.d/my-php.ini - # Disable JIT for now due to https://github.com/department-of-veterans-affairs/va.gov-cms/issues/11315 - - echo "opcache.jit = disable" >> /usr/local/etc/php/conf.d/my-php.ini - - echo "opcache.jit_buffer_size = 256M" >> /usr/local/etc/php/conf.d/my-php.ini - # Explicitly set opcache.validate_timestamps for documentation in code. PHP default is 1. PROD is 0. - # https://www.php.net/manual/en/opcache.configuration.php#ini.opcache.validate-timestamps - - echo "opcache.validate_timestamps = 1" >> /usr/local/etc/php/conf.d/my-php.ini - - # .tugboat/.env.j2 Jinja2 template file support - - apt-get install python3-apt python3-distutils python3 - - curl -O https://bootstrap.pypa.io/get-pip.py - # Remove externally managed script causing error in bookworm when python3 tries to install packages - - rm /usr/lib/python3.11/EXTERNALLY-MANAGED - - python3 get-pip.py - - echo "export PATH=/var/lib/tugboat/bin:~/.local/bin:$PATH" >> ~/.bashrc - - pip3 install j2cli - - # Set Datadog agent config defaults - - j2 "${TUGBOAT_ROOT}/.tugboat/datadog.yaml.j2" -o "/etc/datadog-agent/datadog.yaml" - - echo "export DD_TAGS=pr:$TUGBOAT_GITHUB_PR,branch:$TUGBOAT_GITHUB_HEAD" >> /etc/apache2/envvars - - # Install VA Root CA - - cp "${TUGBOAT_ROOT}"/.tugboat/*.crt /usr/local/share/ca-certificates - - update-ca-certificates - - # Write OAuth keys to files for next-build Preview Server validation - - echo "${OAUTH_PUBLIC_KEY}" >> ${TUGBOAT_ROOT}/public.key - - echo "${OAUTH_PRIVATE_KEY}" >> ${TUGBOAT_ROOT}/private.key - - # Link the document root to the expected path. This example links /docroot - # to the docroot. - - ln -snf "${TUGBOAT_ROOT}/docroot" "${DOCROOT}" - - mkdir -p "${TUGBOAT_ROOT}/docroot/sites/default/files" "${TUGBOAT_ROOT}/files-private" - - # A common practice in many Drupal projects is to store the config and - # private files outside of the Drupal root. If that's the case for your - # project, you can either specify the absolute paths to those - # directories in your settings.local.php, or you can symlink them in - # here. Here is an example of the latter option: - - ln -snf "${TUGBOAT_ROOT}/config" "${DOCROOT}/../config" - - ln -snf "${TUGBOAT_ROOT}/files-private" "${DOCROOT}/../files-private" - - # Install APCu and enable for CLI as well as HTTP. - - pecl install apcu - - docker-php-ext-enable apcu - - echo "apc.enable=1" >> /usr/local/etc/php/conf.d/my-php.ini - - echo "apc.enable=1" >> /usr/local/etc/php/conf.d/php-cli.ini - - echo "apc.enable_cli=1" >> /usr/local/etc/php/conf.d/php-cli.ini - - # Install memcached extension - #- apt-get install libmemcached-dev - - apt install -y libmemcached-dev zlib1g-dev libssl-dev - - yes '' | pecl install -f memcached - - docker-php-ext-enable memcached - - # Install node and npm. - - ./scripts/install-nvm.sh - - # Ensure that we're using version 2 of composer. - - composer self-update --2 - - # Install the Task task runner/build tool. - - ./scripts/install_task_runner.sh - - # Install GitHub Commenter, which comments on GitHub issues and PRs. - - ./scripts/install_github_commenter.sh - - # Install GitHub Status Updater, which updates the status of GitHub check runs. - - ./scripts/install_github_status_updater.sh - - # Install & build vets-website early for next-build preview - # Build vets-website so assets are available (various widgets, fonts, etc) - - ./scripts/vets-web-setup.sh - + - apt-get update + + # TODO: Add "Why" comment for Python, was this for the FE dependencies `yarn install`, if so which dependencies + # so we can remove if they are removed in the future. + #- apt-get install python + + # General useful development tools + - apt-get install jq nano + + # cypress-axe dependencies - https://docs.cypress.io/guides/getting-started/installing-cypress.html#System-requirements + - apt-get install libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb + + # Ensure GD has support for JPEG. + - apt-get install libjpeg-dev + - docker-php-ext-configure gd --with-jpeg --with-webp --with-freetype && docker-php-ext-install gd + + # Install php ZIP extension (drush 10 requires it). + - apt-get install libzip-dev zip + - docker-php-ext-install zip + + # Enable php intl extension + - docker-php-ext-install intl + + # Install opcache, and Apache modules + - docker-php-ext-install opcache + - a2enmod headers rewrite vhost_alias proxy proxy_http + # Install datadog agent for application tracing and profiling. + - DD_API_KEY=" " DD_INSTALL_ONLY=true DD_SITE="ddog-gov.com" bash -c "$(curl -L https://s3.amazonaws.com/dd-agent/scripts/install_script_agent7.sh)" + + # Install Datadog application tracing PHP extension + - php $(curl -w "%{filename_effective}" -LO $(curl -s https://api.github.com/repos/DataDog/dd-trace-php/releases | grep browser_download_url | grep 'setup[.]php' | head -n 1 | cut -d '"' -f 4)) --enable-profiling --php-bin=php + + # Setup web-*. vhost to serve static website. + - cp "${TUGBOAT_ROOT}"/.tugboat/vhost-web.conf /etc/apache2/sites-enabled/ + + # Setup storybook-*. vhost to serve static website. + - cp "${TUGBOAT_ROOT}"/.tugboat/vhost-storybook.conf /etc/apache2/sites-enabled/ + + # Setup next-*. vhost to serve static website. + - cp "${TUGBOAT_ROOT}"/.tugboat/vhost-next.conf /etc/apache2/sites-enabled/ + + # Configure KeepAliveTimeout in apache2.conf. This is set 5 seconds longer than the internal tools ALB. + # The internal tools ALB idle timeout is set to longer than a typical GQL query takes. + - sed -e 's/KeepAliveTimeout 5/KeepAliveTimeout 185/' -i /etc/apache2/apache2.conf + + # BRD Environments are set to 1G, Tugboat and Lando are -1 (unlimited). + - echo "memory_limit = 4G" >> /usr/local/etc/php/conf.d/my-php.ini + # Set unlimited memory limit for PHP CLI to allow Composer to run. + - echo "memory_limit = -1" >> /usr/local/etc/php/conf.d/php-cli.ini + - echo "max_execution_time = 1800" >> /usr/local/etc/php/conf.d/my-php.ini + + # Explicitly enable PHP 8 Opcache JIT (just-in-time compilation) + # https://stitcher.io/blog/php-8-jit-setup + - echo "opcache.enable_cli = 1" >> /usr/local/etc/php/conf.d/php-cli.ini + - echo "opcache.enable = 1" >> /usr/local/etc/php/conf.d/my-php.ini + # Disable JIT for now due to https://github.com/department-of-veterans-affairs/va.gov-cms/issues/11315 + - echo "opcache.jit = disable" >> /usr/local/etc/php/conf.d/my-php.ini + - echo "opcache.jit_buffer_size = 256M" >> /usr/local/etc/php/conf.d/my-php.ini + # Explicitly set opcache.validate_timestamps for documentation in code. PHP default is 1. PROD is 0. + # https://www.php.net/manual/en/opcache.configuration.php#ini.opcache.validate-timestamps + - echo "opcache.validate_timestamps = 1" >> /usr/local/etc/php/conf.d/my-php.ini + + # .tugboat/.env.j2 Jinja2 template file support + - apt-get install python3-apt python3-distutils python3 + - curl -O https://bootstrap.pypa.io/get-pip.py + # Remove externally managed script causing error in bookworm when python3 tries to install packages + - rm /usr/lib/python3.11/EXTERNALLY-MANAGED + - python3 get-pip.py + - echo "export PATH=/var/lib/tugboat/bin:~/.local/bin:$PATH" >> ~/.bashrc + - pip3 install j2cli + + # Set Datadog agent config defaults + - j2 "${TUGBOAT_ROOT}/.tugboat/datadog.yaml.j2" -o "/etc/datadog-agent/datadog.yaml" + - echo "export DD_TAGS=pr:$TUGBOAT_GITHUB_PR,branch:$TUGBOAT_GITHUB_HEAD" >> /etc/apache2/envvars + + # Install VA Root CA + - cp "${TUGBOAT_ROOT}"/.tugboat/*.crt /usr/local/share/ca-certificates + - update-ca-certificates + + # Write OAuth keys to files for next-build Preview Server validation + - echo "${OAUTH_PUBLIC_KEY}" >> ${TUGBOAT_ROOT}/public.key + - echo "${OAUTH_PRIVATE_KEY}" >> ${TUGBOAT_ROOT}/private.key + + # Link the document root to the expected path. This example links /docroot + # to the docroot. + - ln -snf "${TUGBOAT_ROOT}/docroot" "${DOCROOT}" + - mkdir -p "${TUGBOAT_ROOT}/docroot/sites/default/files" "${TUGBOAT_ROOT}/files-private" + + # A common practice in many Drupal projects is to store the config and + # private files outside of the Drupal root. If that's the case for your + # project, you can either specify the absolute paths to those + # directories in your settings.local.php, or you can symlink them in + # here. Here is an example of the latter option: + - ln -snf "${TUGBOAT_ROOT}/config" "${DOCROOT}/../config" + - ln -snf "${TUGBOAT_ROOT}/files-private" "${DOCROOT}/../files-private" + + # Install APCu and enable for CLI as well as HTTP. + - pecl install apcu + - docker-php-ext-enable apcu + - echo "apc.enable=1" >> /usr/local/etc/php/conf.d/my-php.ini + - echo "apc.enable=1" >> /usr/local/etc/php/conf.d/php-cli.ini + - echo "apc.enable_cli=1" >> /usr/local/etc/php/conf.d/php-cli.ini + + # Install memcached extension + #- apt-get install libmemcached-dev + - apt install -y libmemcached-dev zlib1g-dev libssl-dev + - yes '' | pecl install -f memcached + - docker-php-ext-enable memcached + + # Install node and npm. + - ./scripts/install-nvm.sh + + # Ensure that we're using version 2 of composer. + - composer self-update --2 + + # Install the Task task runner/build tool. + - ./scripts/install_task_runner.sh + + # Install GitHub Commenter, which comments on GitHub issues and PRs. + - ./scripts/install_github_commenter.sh + + # Install GitHub Status Updater, which updates the status of GitHub check runs. + - ./scripts/install_github_status_updater.sh + + # Install & build vets-website early for next-build preview + # Build vets-website so assets are available (various widgets, fonts, etc) + - ./scripts/vets-web-setup.sh # Commands that import files, databases, or other assets. When an # existing preview is refreshed, the build workflow starts here, # skipping the init step, because the results of that step will # already be present. update: - # Install/update packages managed by composer, including drush. - # Composer options are in composer.json, 'config' key. - - composer install - - bash -lc 'nvm install' - - bash -lc 'npm install' - - bash -lc 'composer va:theme:compile' - - bash -lc 'composer va:web:install' - - - curl --remote-name https://dsva-vagov-prod-cms-backup-sanitized.s3-us-gov-west-1.amazonaws.com/files/cms-prod-files-latest.tgz - - tar --extract --gunzip --file cms-prod-files-latest.tgz --directory "${DOCROOT}/sites/default/files/" - - rm cms-prod-files-latest.tgz - - # Set file permissions such that Drupal will not complain - - chgrp -R www-data "${DOCROOT}/sites/default/files" - - find "${DOCROOT}/sites/default/files" -type d -print0 | xargs -0 chmod 2775 - - find "${DOCROOT}/sites/default/files" -type f -print0 | xargs -0 chmod 0664 - + # Install/update packages managed by composer, including drush. + # Composer options are in composer.json, 'config' key. + - composer install + - bash -lc 'nvm install' + - bash -lc 'npm install' + - bash -lc 'composer va:theme:compile' + - bash -lc 'composer va:web:install' + + - curl --remote-name https://dsva-vagov-prod-cms-backup-sanitized.s3-us-gov-west-1.amazonaws.com/files/cms-prod-files-latest.tgz + - tar --extract --gunzip --file cms-prod-files-latest.tgz --directory "${DOCROOT}/sites/default/files/" + - rm cms-prod-files-latest.tgz + + # Set file permissions such that Drupal will not complain + - chgrp -R www-data "${DOCROOT}/sites/default/files" + - find "${DOCROOT}/sites/default/files" -type d -print0 | xargs -0 chmod 2775 + - find "${DOCROOT}/sites/default/files" -type f -print0 | xargs -0 chmod 0664 # Commands that build the site. This is where you would add things # like feature reverts or any other drush commands required to # set up or configure the site. When a preview is built from a @@ -185,87 +181,86 @@ services: # and update steps, because the results of those are inherited # from the base preview. build: - # Currently, resetting to the remote branch/PR SHA since [Task](https://github.com/go-task/task) runs tests status against this commit. - # Tugboat currently merges the branch into master, and we don't need that because we have a GitHub branch rule - # setup to ensure branch is up-to-date. - - git reset --hard $TUGBOAT_PREVIEW_SHA - - # This j2 command is shared in both the build & clone stages. If modifying, change the other too. - - j2 "${TUGBOAT_ROOT}/.tugboat/.env.j2" -o "${TUGBOAT_ROOT}/.env" - # This command is shared by the clone and build stages, make sure to update both stages. - - j2 "${TUGBOAT_ROOT}/.web/403-error-document.j2.html" -o "${TUGBOAT_ROOT}/.web/403-error-document.html" - - j2 "${TUGBOAT_ROOT}/.storybook/403-error-document.j2.html" -o "${TUGBOAT_ROOT}/.storybook/403-error-document.html" - - j2 "${TUGBOAT_ROOT}/.next/403-error-document.j2.html" -o "${TUGBOAT_ROOT}/.next/403-error-document.html" - - j2 "${TUGBOAT_ROOT}/.next/503-error-document.j2.html" -o "${TUGBOAT_ROOT}/.next/503-error-document.html" - - composer install - - bash -lc 'nvm install' - - bash -lc 'npm install' - - bash -lc 'composer va:theme:compile' - - bash -lc 'composer va:web:install' - - bash -lc 'composer va:next:install' - - # Create symlink between vets-website assets and next-build -# - ln -snf "${DOCROOT}/vendor/va-gov/vets-website/build/localhost/generated" "${TUGBOAT_ROOT}/next/public/generated" - - mkdir -p "${TUGBOAT_ROOT}/next/public" - - ln -snf "${TUGBOAT_ROOT}/vets-website/build/localhost/generated" "${TUGBOAT_ROOT}/next/public/generated" - - - # https://www.drush.org/latest/deploycommand/ (updatedb, cache:rebuild, config:import, deploy:hook) - - bash -lc 'drush deploy' - - # Disable sitewide alerts so as not to interfere with testing. - - bash -lc 'drush sitewide-alert:disable' - - # Prevent continuous releases from running on Tugboat, and reset to ready. - - bash -lc 'drush sset va_gov_build_trigger.continuous_release_enabled 0' - - bash -lc 'drush sset va_gov_build_trigger.release_state ready' - - # Setup background processing service. This uses runit to keep process up - # See https://docs.tugboat.qa/setting-up-services/how-to-set-up-services/running-a-background-process - - mkdir -p /etc/service/drupal_events - - mv "${TUGBOAT_ROOT}/scripts/queue_runner/queue_runner.sh" /etc/service/drupal_events/run - - chmod +x /etc/service/drupal_events/run + # Currently, resetting to the remote branch/PR SHA since [Task](https://github.com/go-task/task) runs tests status against this commit. + # Tugboat currently merges the branch into master, and we don't need that because we have a GitHub branch rule + # setup to ensure branch is up-to-date. + - git reset --hard $TUGBOAT_PREVIEW_SHA + + # This j2 command is shared in both the build & clone stages. If modifying, change the other too. + - j2 "${TUGBOAT_ROOT}/.tugboat/.env.j2" -o "${TUGBOAT_ROOT}/.env" + # This command is shared by the clone and build stages, make sure to update both stages. + - j2 "${TUGBOAT_ROOT}/.web/403-error-document.j2.html" -o "${TUGBOAT_ROOT}/.web/403-error-document.html" + - j2 "${TUGBOAT_ROOT}/.storybook/403-error-document.j2.html" -o "${TUGBOAT_ROOT}/.storybook/403-error-document.html" + - j2 "${TUGBOAT_ROOT}/.next/403-error-document.j2.html" -o "${TUGBOAT_ROOT}/.next/403-error-document.html" + - j2 "${TUGBOAT_ROOT}/.next/503-error-document.j2.html" -o "${TUGBOAT_ROOT}/.next/503-error-document.html" + - composer install + - bash -lc 'nvm install' + - bash -lc 'npm install' + - bash -lc 'composer va:theme:compile' + - bash -lc 'composer va:web:install' + - bash -lc 'composer va:next:install' + + # Create symlink between vets-website assets and next-build + # - ln -snf "${DOCROOT}/vendor/va-gov/vets-website/build/localhost/generated" "${TUGBOAT_ROOT}/next/public/generated" + - mkdir -p "${TUGBOAT_ROOT}/next/public" + - ln -snf "${TUGBOAT_ROOT}/vets-website/build/localhost/generated" "${TUGBOAT_ROOT}/next/public/generated" + + # https://www.drush.org/latest/deploycommand/ (updatedb, cache:rebuild, config:import, deploy:hook) + - bash -lc 'drush deploy' + + # Disable sitewide alerts so as not to interfere with testing. + - bash -lc 'drush sitewide-alert:disable' + + # Prevent continuous releases from running on Tugboat, and reset to ready. + - bash -lc 'drush sset va_gov_build_trigger.continuous_release_enabled 0' + - bash -lc 'drush sset va_gov_build_trigger.release_state ready' + + # Setup background processing service. This uses runit to keep process up + # See https://docs.tugboat.qa/setting-up-services/how-to-set-up-services/running-a-background-process + - mkdir -p /etc/service/drupal_events + - mv "${TUGBOAT_ROOT}/scripts/queue_runner/queue_runner.sh" /etc/service/drupal_events/run + - chmod +x /etc/service/drupal_events/run clone: - # This j2 command is shared in both the build & clone stages. If modifying, change the other too. - - j2 "${TUGBOAT_ROOT}/.tugboat/.env.j2" -o "${TUGBOAT_ROOT}/.env" + # This j2 command is shared in both the build & clone stages. If modifying, change the other too. + - j2 "${TUGBOAT_ROOT}/.tugboat/.env.j2" -o "${TUGBOAT_ROOT}/.env" - # This command is shared by the clone and build stages, make sure to update both stages. - - j2 "${TUGBOAT_ROOT}/.web/403-error-document.j2.html" -o "${TUGBOAT_ROOT}/.web/403-error-document.html" - - j2 "${TUGBOAT_ROOT}/.storybook/403-error-document.j2.html" -o "${TUGBOAT_ROOT}/.storybook/403-error-document.html" - - j2 "${TUGBOAT_ROOT}/.next/403-error-document.j2.html" -o "${TUGBOAT_ROOT}/.next/403-error-document.html" - - j2 "${TUGBOAT_ROOT}/.next/503-error-document.j2.html" -o "${TUGBOAT_ROOT}/.next/503-error-document.html" + # This command is shared by the clone and build stages, make sure to update both stages. + - j2 "${TUGBOAT_ROOT}/.web/403-error-document.j2.html" -o "${TUGBOAT_ROOT}/.web/403-error-document.html" + - j2 "${TUGBOAT_ROOT}/.storybook/403-error-document.j2.html" -o "${TUGBOAT_ROOT}/.storybook/403-error-document.html" + - j2 "${TUGBOAT_ROOT}/.next/403-error-document.j2.html" -o "${TUGBOAT_ROOT}/.next/403-error-document.html" + - j2 "${TUGBOAT_ROOT}/.next/503-error-document.j2.html" -o "${TUGBOAT_ROOT}/.next/503-error-document.html" online: - # We only want tests running on PRs, not branches like the base preview build of main. - - if [ "$TUGBOAT_PREVIEW_TYPE" = "pullrequest" ]; then bash -lc 'time task --taskfile=tests.yml'; fi + # Start the next build preview server + - bash -lc 'composer va:next:start' - # Set file permissions so web based build calls work. This must run after all web builds are done in tests. - - chown -R www-data:www-data "${DOCROOT}/vendor/va-gov/content-build" - - find "${DOCROOT}/vendor/va-gov/content-build" -type d -exec chmod 2775 {} \+ - - find "${DOCROOT}/vendor/va-gov/content-build" -type f -exec chmod 0664 {} \+ - - find -L "${DOCROOT}/vendor/va-gov/content-build/node_modules/.bin" -type f -exec chmod +x {} \+ - - find "${DOCROOT}/vendor/va-gov/content-build/script" -type f -exec chmod +x {} \+ + # We only want tests running on PRs, not branches like the base preview build of main. + - if [ "$TUGBOAT_PREVIEW_TYPE" = "pullrequest" ]; then bash -lc 'time task --taskfile=tests.yml'; fi - # Put necessary env variables in place for next's Drupal Preview before building server - # Need to construct this way instead of TUGBOAT_DEFAULT_SERVICE_URL in order to drop the trailing / - - echo "NEXT_PUBLIC_DRUPAL_BASE_URL=https://cms-${TUGBOAT_SERVICE_TOKEN}.${TUGBOAT_SERVICE_CONFIG_DOMAIN}" >> ${TUGBOAT_ROOT}/next/envs/.env.tugboat - - echo "NEXT_IMAGE_DOMAIN=https://cms-${TUGBOAT_SERVICE_TOKEN}.${TUGBOAT_SERVICE_CONFIG_DOMAIN}" >> ${TUGBOAT_ROOT}/next/envs/.env.tugboat - - echo "DRUPAL_CLIENT_ID=${DRUPAL_CLIENT_ID}" >> ${TUGBOAT_ROOT}/next/envs/.env.tugboat - - echo "DRUPAL_CLIENT_SECRET=${DRUPAL_CLIENT_SECRET}" >> ${TUGBOAT_ROOT}/next/envs/.env.tugboat + # Set file permissions so web based build calls work. This must run after all web builds are done in tests. + - chown -R www-data:www-data "${DOCROOT}/vendor/va-gov/content-build" + - find "${DOCROOT}/vendor/va-gov/content-build" -type d -exec chmod 2775 {} \+ + - find "${DOCROOT}/vendor/va-gov/content-build" -type f -exec chmod 0664 {} \+ + - find -L "${DOCROOT}/vendor/va-gov/content-build/node_modules/.bin" -type f -exec chmod +x {} \+ + - find "${DOCROOT}/vendor/va-gov/content-build/script" -type f -exec chmod +x {} \+ - # Build storybook and the frontends (web, next) in parallel - - bash -lc 'time task --taskfile=tugboat.yml' + # Put necessary env variables in place for next's Drupal Preview before building server + # Need to construct this way instead of TUGBOAT_DEFAULT_SERVICE_URL in order to drop the trailing / + - echo "NEXT_PUBLIC_DRUPAL_BASE_URL=https://cms-${TUGBOAT_SERVICE_TOKEN}.${TUGBOAT_SERVICE_CONFIG_DOMAIN}" >> ${TUGBOAT_ROOT}/next/envs/.env.tugboat + - echo "NEXT_IMAGE_DOMAIN=https://cms-${TUGBOAT_SERVICE_TOKEN}.${TUGBOAT_SERVICE_CONFIG_DOMAIN}" >> ${TUGBOAT_ROOT}/next/envs/.env.tugboat + - echo "DRUPAL_CLIENT_ID=${DRUPAL_CLIENT_ID}" >> ${TUGBOAT_ROOT}/next/envs/.env.tugboat + - echo "DRUPAL_CLIENT_SECRET=${DRUPAL_CLIENT_SECRET}" >> ${TUGBOAT_ROOT}/next/envs/.env.tugboat - # Start the next build preview server - - bash -lc 'composer va:next:start' + # Build storybook and the frontends (web, next) in parallel + - bash -lc 'time task --taskfile=tugboat.yml' memcache: image: tugboatqa/memcached:1.6 commands: init: - - sed -e 's/256/1024/' -i /etc/service/memcached/run - - sv restart memcached + - sed -e 's/256/1024/' -i /etc/service/memcached/run + - sv restart memcached # What to call the service hosting MySQL. This name also acts as the # hostname to access the service by from the php service. @@ -277,19 +272,19 @@ services: # A set of commands to run while building this service commands: init: - - printf '[mysqld]\ninnodb_log_file_size = 50331648\nmax_allowed_packet = 128M\n' > /etc/mysql/conf.d/zzz.cnf - - sv restart mariadb - # Give MySQL some time to restart. - - sleep 5 + - printf '[mysqld]\ninnodb_log_file_size = 50331648\nmax_allowed_packet = 128M\n' > /etc/mysql/conf.d/zzz.cnf + - sv restart mariadb + # Give MySQL some time to restart. + - sleep 5 # Commands that import files, databases, or other assets. When an # existing preview is refreshed, the build workflow starts here, # skipping the init step, because the results of that step will # already be present. update: - # Copy a database dump from an external server. The public - # SSH key found in the Tugboat Repository configuration must be - # copied to the external server in order to use scp. - - curl --remote-name https://dsva-vagov-prod-cms-backup-sanitized.s3-us-gov-west-1.amazonaws.com/database/cms-prod-db-sanitized-latest.sql.gz - - mysql -e "DROP DATABASE IF EXISTS tugboat; CREATE DATABASE tugboat"; - - zcat cms-prod-db-sanitized-latest.sql.gz | mysql tugboat - - rm cms-prod-db-sanitized-latest.sql.gz + # Copy a database dump from an external server. The public + # SSH key found in the Tugboat Repository configuration must be + # copied to the external server in order to use scp. + - curl --remote-name https://dsva-vagov-prod-cms-backup-sanitized.s3-us-gov-west-1.amazonaws.com/database/cms-prod-db-sanitized-latest.sql.gz + - mysql -e "DROP DATABASE IF EXISTS tugboat; CREATE DATABASE tugboat"; + - zcat cms-prod-db-sanitized-latest.sql.gz | mysql tugboat + - rm cms-prod-db-sanitized-latest.sql.gz From 04807a86bb62b6ad8d93c8fe787519b8100c93c1 Mon Sep 17 00:00:00 2001 From: Tim Cosgrove Date: Wed, 29 Jan 2025 13:10:28 -0800 Subject: [PATCH 6/8] Build prior to starting next-build server. --- .tugboat/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.tugboat/config.yml b/.tugboat/config.yml index 4ec0802912..ea82e8e2ff 100644 --- a/.tugboat/config.yml +++ b/.tugboat/config.yml @@ -233,6 +233,7 @@ services: online: # Start the next build preview server + - bash -lc 'composer va:next:build' - bash -lc 'composer va:next:start' # We only want tests running on PRs, not branches like the base preview build of main. From 4e882ad78d60a0dedb35cf4178c3d195113d1af3 Mon Sep 17 00:00:00 2001 From: Tim Cosgrove Date: Wed, 29 Jan 2025 13:41:21 -0800 Subject: [PATCH 7/8] Run next server in background so that following items can proceed. --- .tugboat/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.tugboat/config.yml b/.tugboat/config.yml index ea82e8e2ff..802de4b61b 100644 --- a/.tugboat/config.yml +++ b/.tugboat/config.yml @@ -234,7 +234,7 @@ services: online: # Start the next build preview server - bash -lc 'composer va:next:build' - - bash -lc 'composer va:next:start' + - bash -lc 'composer va:next:start' & # We only want tests running on PRs, not branches like the base preview build of main. - if [ "$TUGBOAT_PREVIEW_TYPE" = "pullrequest" ]; then bash -lc 'time task --taskfile=tests.yml'; fi From ced05f7df4f94c733c747c18950a234c6740ccc2 Mon Sep 17 00:00:00 2001 From: Tim Cosgrove Date: Wed, 29 Jan 2025 15:16:29 -0800 Subject: [PATCH 8/8] Remove Next from tugboat.yml since it is out in config.yml. --- tugboat.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tugboat.yml b/tugboat.yml index 36c59488bd..973e30bf53 100644 --- a/tugboat.yml +++ b/tugboat.yml @@ -13,16 +13,10 @@ tasks: cmds: - drush va-gov-content-release:request:submit - start-next: - desc: start next.js preview server - cmds: - - composer va:next:start - build: deps: - build-storybook - build-frontend - - start-next default: cmds: