Skip to content

Commit

Permalink
USAGOV-2149: Deploy to prod (#2147)
Browse files Browse the repository at this point in the history
  • Loading branch information
akf authored Dec 31, 2024
2 parents 5a46167 + cd13df7 commit dd4e2e6
Show file tree
Hide file tree
Showing 38 changed files with 1,647 additions and 870 deletions.
102 changes: 51 additions & 51 deletions .docker/Dockerfile-cms
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ RUN COMPOSER_MEMORY_LIMIT=-1 composer install --ignore-platform-reqs --no-intera

# USER www-data
###############################################################
FROM node:20.10-bullseye-slim AS theme-builder
FROM node:20-bullseye-slim AS theme-builder

ARG BUID=1000
ARG BGID=1000
Expand Down Expand Up @@ -104,7 +104,7 @@ RUN npm install --production=false --prefix /var/www/web/themes/custom/usagov \
&& chown -R node:node /var/www/web/themes

###############################################################
FROM alpine:3.18 AS cms
FROM alpine:3.20 AS cms

ARG S6_VERSION
ENV S6_VERSION ${S6_VERSION:-v2.2.0.3}
Expand Down Expand Up @@ -153,54 +153,54 @@ RUN sed -E -i "s/:x:${BUID}:/:x:1919:/g" /etc/passwd \
mariadb-connector-c \
nginx \
nginx-mod-http-lua \
php81 \
php81-fpm \
php81-bcmath \
php81-bz2 \
php81-calendar \
php81-curl \
php81-ctype \
php81-dom \
php81-fileinfo \
php81-ftp \
php81-gd \
php81-intl \
php81-iconv \
php81-imap \
php81-intl \
php81-json \
php81-ldap \
php81-mbstring \
php81-mysqlnd \
php81-openssl \
php81-opcache \
php81-pcntl \
php81-pdo \
php81-pdo_mysql \
php81-pdo_sqlite \
php81-pear \
php81-pecl-imagick \
php81-pecl-xdebug \
php81-phar \
php81-posix \
php81-session \
php81-simplexml \
php81-shmop \
php81-soap \
php81-sockets \
php81-sodium \
php81-sqlite3 \
php81-sysvmsg \
php81-sysvsem \
php81-sysvshm \
php81-tokenizer \
php81-tidy \
php81-xsl \
php81-xml \
php81-xmlreader \
php81-xmlwriter \
php81-zip \
php81-zlib \
php83 \
php83-fpm \
php83-bcmath \
php83-bz2 \
php83-calendar \
php83-curl \
php83-ctype \
php83-dom \
php83-fileinfo \
php83-ftp \
php83-gd \
php83-intl \
php83-iconv \
php83-imap \
php83-intl \
php83-json \
php83-ldap \
php83-mbstring \
php83-mysqlnd \
php83-openssl \
php83-opcache \
php83-pcntl \
php83-pdo \
php83-pdo_mysql \
php83-pdo_sqlite \
php83-pear \
php83-pecl-imagick \
php83-pecl-xdebug \
php83-phar \
php83-posix \
php83-session \
php83-simplexml \
php83-shmop \
php83-soap \
php83-sockets \
php83-sodium \
php83-sqlite3 \
php83-sysvmsg \
php83-sysvsem \
php83-sysvshm \
php83-tokenizer \
php83-tidy \
php83-xsl \
php83-xml \
php83-xmlreader \
php83-xmlwriter \
php83-zip \
php83-zlib \
&& mkdir -p /var/www/web/sites/default/files \
# s6 supervisor setup
&& tar xzf /tmp/s6overlay.tar.gz -C / \
Expand All @@ -217,7 +217,7 @@ RUN sed -E -i "s/:x:${BUID}:/:x:1919:/g" /etc/passwd \
&& mkdir -p /run/nginx/ \
&& touch /run/nginx/nginx.pid \
# php setup
&& ln -s /usr/sbin/php-fpm81 /usr/sbin/php-fpm
&& ln -s /usr/sbin/php-fpm83 /usr/sbin/php-fpm

# new relic setup
COPY bin/src/newrelic.sh /local/newrelic.sh
Expand Down
102 changes: 51 additions & 51 deletions .docker/Dockerfile-www
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

###############################################################
FROM alpine:3.18 AS www
FROM alpine:3.20 AS www

ARG S6_VERSION
ENV S6_VERSION ${S6_VERSION:-v2.2.0.3}
Expand Down Expand Up @@ -49,54 +49,54 @@ RUN sed -E -i "s/:x:${BUID}:/:x:1919:/g" /etc/passwd \
mariadb-connector-c \
nginx \
nginx-mod-http-lua \
php81 \
# php81-fpm \
php81-bcmath \
php81-bz2 \
php81-calendar \
php81-curl \
php81-ctype \
php81-dom \
php81-fileinfo \
php81-ftp \
php81-gd \
php81-intl \
php81-iconv \
php81-imap \
php81-intl \
php81-json \
php81-ldap \
php81-mbstring \
php81-mysqlnd \
php81-openssl \
php81-opcache \
php81-pcntl \
php81-pdo \
php81-pdo_mysql \
php81-pdo_sqlite \
php81-pear \
php81-pecl-imagick \
php81-pecl-xdebug \
php81-phar \
php81-posix \
php81-session \
php81-simplexml \
php81-shmop \
php81-soap \
php81-sockets \
php81-sodium \
php81-sqlite3 \
php81-sysvmsg \
php81-sysvsem \
php81-sysvshm \
php81-tokenizer \
php81-tidy \
php81-xsl \
php81-xml \
php81-xmlreader \
php81-xmlwriter \
php81-zip \
php81-zlib \
php83 \
# php83-fpm \
php83-bcmath \
php83-bz2 \
php83-calendar \
php83-curl \
php83-ctype \
php83-dom \
php83-fileinfo \
php83-ftp \
php83-gd \
php83-intl \
php83-iconv \
php83-imap \
php83-intl \
php83-json \
php83-ldap \
php83-mbstring \
php83-mysqlnd \
php83-openssl \
php83-opcache \
php83-pcntl \
php83-pdo \
php83-pdo_mysql \
php83-pdo_sqlite \
php83-pear \
php83-pecl-imagick \
php83-pecl-xdebug \
php83-phar \
php83-posix \
php83-session \
php83-simplexml \
php83-shmop \
php83-soap \
php83-sockets \
php83-sodium \
php83-sqlite3 \
php83-sysvmsg \
php83-sysvsem \
php83-sysvshm \
php83-tokenizer \
php83-tidy \
php83-xsl \
php83-xml \
php83-xmlreader \
php83-xmlwriter \
php83-zip \
php83-zlib \
&& mkdir -p /var/www/web/sites/default/files \
# s6 supervisor setup
&& tar xzf /tmp/s6overlay.tar.gz -C / \
Expand All @@ -111,10 +111,10 @@ RUN sed -E -i "s/:x:${BUID}:/:x:1919:/g" /etc/passwd \
&& ln -s /dev/stderr /var/log/nginx/error.log \
&& ln -s /dev/stdout /var/log/nginx/access.log \
&& mkdir -p /run/nginx/ \
&& touch /run/nginx/nginx.pid
&& touch /run/nginx/nginx.pid
# \
# php setup
#&& ln -s /usr/sbin/php-fpm81 /usr/sbin/php-fpm
#&& ln -s /usr/sbin/php-fpm83 /usr/sbin/php-fpm

# new relic setup
COPY bin/src/newrelic.sh /local/newrelic.sh
Expand Down
1 change: 1 addition & 0 deletions .docker/src-cms/50_xdebug.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ xdebug.client_host=host.docker.internal
xdebug.idekey=VSCODE
xdebug.max_nesting_level=1500
xdebug.mode=debug
# xdebug.start_with_request=1
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ daemonize = no

events.mechanism = epoll

include=/etc/php81/php-fpm.d/*.conf
include=/etc/php83/php-fpm.d/*.conf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ report_memleaks = On
track_errors = Off
html_errors = On

auto_prepend_file = /etc/php81/auto_prepend.php
auto_prepend_file = /etc/php83/auto_prepend.php
auto_append_file =

default_mimetype = "text/html"
Expand Down
4 changes: 0 additions & 4 deletions .docker/src-waf/etc/nginx/conf.d/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,6 @@ server {
if ($http_x_usa_forwarded_host ~* ^(www\.)?govloans\.gov$) {
set $HostMatchFail "matched";
}
# gsa.benefits.gov is for testing; we can remove it after cutover
if ($http_x_usa_forwarded_host ~* ^gsa\.benefits\.gov$) {
set $HostMatchFail "matched";
}

if ($HostMatchFail = "NOMATCH") {
# didn't match expected host; redirect to home page.
Expand Down
6 changes: 0 additions & 6 deletions .docker/src-waf/etc/nginx/snippets/domain-redirects.conf
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,6 @@
break;
}

## gsa.benefits.gov is for testing of the benefits rewrites and can be removed after cutover:
if ($cf_forwarded_host ~* ^gsa\.benefits\.gov$) {
set $port 8889;
break;
}

## govloans.gov (part of the benefits.gov transition)
if ($cf_forwarded_host ~* ^(www\.)?govloans\.gov$) {
set $port 8889;
Expand Down
26 changes: 21 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ To access the Drupal Portal to make any additional configurations, you will need
Log out as root, and log in with your own user account.
**Note:** You will need to repeat these steps any time you re-load the database from a backup.
**Note:** You will need to repeat these steps any time you re-load the database from a backup.
### Automated tests setup (cypress)
Expand All @@ -183,20 +183,20 @@ We use [Cypress](cypress.io). Note that we use only the Cypress App, _not_ Cypre
* Tests run in the `cypress` Docker container.
* The tests themselves are in the `automated_tests/e2e-cypress` directory.
* Twig debugging will break some of the tests! Turn it off before running tests to get the most accurate results.
* Twig debugging will break some of the tests! Turn it off before running tests to get the most accurate results.
## Minimal setup for headless tests
1. Supply Drupal *credentials* for the automated tests: Edit the file `env.local.cypress`. Supply a valid Drupal user name and password for `cypressCmsUser` and `cypressCmsPass`.
1. Supply Drupal *credentials* for the automated tests: Edit the file `env.local.cypress`. Supply a valid Drupal user name and password for `cypressCmsUser` and `cypressCmsPass`.
2. Run `docker compose up` to (re-)create the cypress container with the new environment variables.
3. Run `bin/cypress-ssh` to open a shell in the cypress container
You can run `npx cypress run --spec cypress/e2e` to run the entire test suite, or specify a smaller subset like `cypress/e2e/functional`.
The **Report** will be written to automated_tests/e2e-cypress/cypress/reports/html/index.html and you can open it in your web browser by navigating to that file and opening it. Cypress will report that it wrote the tests to /app/e2e-cypress/cypress/reports/html/index.html, which is the location of that file in the volume mounted to the cypress docker container.
The **Report** will be written to automated_tests/e2e-cypress/cypress/reports/html/index.html and you can open it in your web browser by navigating to that file and opening it. Cypress will report that it wrote the tests to /app/e2e-cypress/cypress/reports/html/index.html, which is the location of that file in the volume mounted to the cypress docker container.
Note: The first time you run bin/init, it will create the `env.local.cypress` file by copying `env.default.cypress`. The default `cypressBaseUrl` in that file should be correct for running tests against your local dev site.
Expand Down Expand Up @@ -232,7 +232,7 @@ This assumes you're using homebrew.
The "network client" you're enabling this for is the virtual machine running in your cypress container.
4. Reboot your computer. (You need to reboot once after installing XQuartz. Thereafter, when you change your XQuartz settings you need to restart XQuartz, but not reboot.)
4. Reboot your computer. (You need to reboot once after installing XQuartz. Thereafter, when you change your XQuartz settings you need to restart XQuartz, but not reboot.)
Proceed to [Allow cypress to open an X window](#allow-cypress-to-open-an-x-window)
Expand Down Expand Up @@ -320,6 +320,22 @@ If you make any changes to the `scss` or `js` files, make sure to check for lint
[back to top](#usagov-2021)
## Checking PHP Code style and syntax errors
PHPCodesniffer and the parallel linting tools should be installed automatically on a local environment via `composer install`. PHPCodeSniffer is used to ensure new code follows Drupal's coding standard. The parallel linter will check for PHP syntax errors. If they detect any errors, they must be fixed before a PR of changes can be accepted.
The following composer scripts are aliases for running these tools.
* Check for code style errors across all project files. Must have zero errors:
`./bin/composer phpcs-errors`:
* Check for code style errors and warnings across all project files.
`./bin/composer phpcs-strict`
* Check for code style errors in current branch. Must have zero errors:
`./bin/composer phpcs-changes`
* Check for code style errors and warnings in current branch.
`./bin/composer phpcs-changes-strict`
* Check for PHP lint errors
`./bin/composer php-lint`
## Project Restart/Reset
Sometimes, Docker problems arise after an upgrade and a more complete restart is needed. After closing down and destroying the existing containers, networks, and volumes the procedure is the same as the full project setup.
Expand Down
9 changes: 9 additions & 0 deletions bin/changed-files
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

CURRENT_BRANCH=`git branch --show-current`
# Get the changes between current branch and dev
CHANGED=`git diff --name-only --diff-filter=ARM dev $CURRENT_BRANCH`

if [ "$CURRENT_BRANCH" != "dev" ]; then
echo $CHANGED;
fi
9 changes: 9 additions & 0 deletions bin/composer-reqs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -e

docker compose run \
--rm \
--no-deps \
--workdir /var/www \
composer \
composer "$@"
Loading

0 comments on commit dd4e2e6

Please sign in to comment.