Skip to content

Commit

Permalink
update scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfinnarn committed Mar 6, 2024
1 parent e429472 commit 7b401d8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
14 changes: 0 additions & 14 deletions .tugboat/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ services:
# General useful development tools
- apt-get install jq nano

# @todo Can cypress/included image be used instead?
# 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

Expand Down Expand Up @@ -74,7 +73,6 @@ services:
# 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

# @todo These should be aligned with other environments...
# 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.
Expand Down Expand Up @@ -143,7 +141,6 @@ services:
- ./scripts/install-nvm.sh

# Ensure that we're using version 2 of composer.
# @todo I'm guessing it is always version two now...
- composer self-update --2

# Install the Task task runner/build tool.
Expand All @@ -166,7 +163,6 @@ services:
update:
# Install/update packages managed by composer, including drush.
# Composer options are in composer.json, 'config' key.
# @todo Isn't this already done in the build step?
- composer install
- bash -lc 'nvm install'
- bash -lc 'npm install'
Expand Down Expand Up @@ -196,7 +192,6 @@ services:

# 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"
# @todo If this is shared, why not abstract it to a script?
# 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"
Expand Down Expand Up @@ -258,15 +253,6 @@ services:
- 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 {} \+

# 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 /
# @todo Can the config file use set env vars and these commands set them?
# @todo e.g. TUGBOAT_DEFAULT_SERVICE_URL=https://cms-${TUGBOAT_SERVICE_TOKEN}.${TUGBOAT_SERVICE_CONFIG_DOMAIN}
- 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

# Build storybook and the frontends (web, next) in parallel
- bash -lc 'time task --taskfile=tugboat.yml'

Expand Down
15 changes: 7 additions & 8 deletions scripts/next-build-frontend.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ if [ "${next_build_version}" != "__default" ]; then
echo "==> Checking out the requested frontend version" >> ${logfile}
pushd ${reporoot}/next

# Stash any local changes.
git stash &>> ${logfile}
# Reset the working directory to the last commit.
# This is necessary because we set some env vars in "next-start.sh" for Tugboat
# which prevents the checkout from working if the working directory is dirty.
git reset --hard &>> ${logfile}

if echo "${next_build_version}" | grep -qE '^[0-9]+$' > /dev/null; then
echo "==> Checking out PR #${next_build_version}"
Expand All @@ -70,16 +72,11 @@ if [ "${next_build_version}" != "__default" ]; then
fi
git checkout FETCH_HEAD &>> ${logfile}

# Pop the stash if we stashed anything.
git stash pop &>> ${logfile}

popd
else
echo "==> Using default next-build version" >> ${logfile}
fi

# Stop the next server.

# Install 3rd party deps.
echo "==> Installing yarn dependencies" >> ${logfile}
composer va:next:install &>> ${logfile}
Expand All @@ -102,7 +99,9 @@ else
fi

# Build vets-website again.
${reporoot}/scripts/vets-web-setup.sh
# @todo Do the symlinks need to be re-created?
echo "==> Re-building Vets Website" >> ${logfile}
${reporoot}/scripts/vets-web-setup.sh &>> ${logfile}

# Run the build.
echo "==> Starting build" >> ${logfile}
Expand Down
2 changes: 2 additions & 0 deletions scripts/next-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@ echo "Node $(node -v)"
echo "NPM $(npm -v)"
echo "Yarn $(yarn -v)"

# @todo Should the manual steps go here like copying the .env file? or maybe in next-start.sh?

yarn install
13 changes: 13 additions & 0 deletions scripts/next-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,21 @@ NEXT_SERVER_PIDS=$(ps aux | grep '[.]/scripts/yarn/start.js' | awk '{print $2}')

# In case we have multiple processes, loop through them.
for pid in ${NEXT_SERVER_PIDS}; do
echo "Killing process ${pid}..."
kill $pid
done

# Set environment variables if on Tugboat.
if [ "${APP_ENV}" == "tugboat" ]; then
echo "Setting up Tugboat environment variables for Next.js..."

# 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}" >> ${ROOT}/next/envs/.env.tugboat
echo "NEXT_IMAGE_DOMAIN=https://cms-${TUGBOAT_SERVICE_TOKEN}.${TUGBOAT_SERVICE_CONFIG_DOMAIN}" >> ${ROOT}/next/envs/.env.tugboat
echo "DRUPAL_CLIENT_ID=${DRUPAL_CLIENT_ID}" >> ${ROOT}/next/envs/.env.tugboat
echo "DRUPAL_CLIENT_SECRET=${DRUPAL_CLIENT_SECRET}" >> ${ROOT}/next/envs/.env.tugboat
fi

# Start the dev server. Vets-website assets need to be in place prior to this build.
yarn start

0 comments on commit 7b401d8

Please sign in to comment.