From 2f09db0ec55a2c594170c3752838f9318ae556f3 Mon Sep 17 00:00:00 2001 From: igorkorenfeld Date: Thu, 15 Sep 2022 15:13:04 -0400 Subject: [PATCH 01/11] Add a build script for prearing assets for deploy --- ops/scripts/build.sh | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100755 ops/scripts/build.sh diff --git a/ops/scripts/build.sh b/ops/scripts/build.sh new file mode 100755 index 000000000..0809b58e9 --- /dev/null +++ b/ops/scripts/build.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +# Compile assets +docker compose run node npx gulp compile; +docker compose run node npx gulp copyAssets; + +# Collect assets +docker compose run app python manage.py collectstatic --noinput From 411dcea530b53730d695b8d194ed079a3ed00e17 Mon Sep 17 00:00:00 2001 From: igorkorenfeld Date: Thu, 15 Sep 2022 15:16:37 -0400 Subject: [PATCH 02/11] Create a deploy script --- ops/scripts/deploy.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100755 ops/scripts/deploy.sh diff --git a/ops/scripts/deploy.sh b/ops/scripts/deploy.sh new file mode 100755 index 000000000..7ff641752 --- /dev/null +++ b/ops/scripts/deploy.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +# Compile and collect static assets +../ops/scripts/build.sh + +# Deploy to unstable +cf target -o cisa-getgov-prototyping -s unstable +cf push getgov-unstable -f ../ops/manifests/manifest-unstable.yaml + +cf run-task getgov-unstable --command 'python manage.py migrate' --name migrate From ddcf17c4caf728508cb8a80cc71df387f3152158 Mon Sep 17 00:00:00 2001 From: igorkorenfeld Date: Thu, 15 Sep 2022 15:17:20 -0400 Subject: [PATCH 03/11] Remove collectstatic step from staging deploy --- src/run.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/src/run.sh b/src/run.sh index 452469af4..90cf127a4 100755 --- a/src/run.sh +++ b/src/run.sh @@ -15,5 +15,4 @@ else fi fi -python manage.py collectstatic --settings=registrar.config.settings --noinput gunicorn registrar.config.wsgi -t 60 From 9e38f5cb1e93a79beac99e1ba8150e29bd9b24c6 Mon Sep 17 00:00:00 2001 From: igorkorenfeld Date: Thu, 15 Sep 2022 15:17:58 -0400 Subject: [PATCH 04/11] Change paragraph styling for testing --- .../assets/sass/_theme/_uswds-theme-custom-styles.scss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/registrar/assets/sass/_theme/_uswds-theme-custom-styles.scss b/src/registrar/assets/sass/_theme/_uswds-theme-custom-styles.scss index 74ad72cad..97f13930a 100644 --- a/src/registrar/assets/sass/_theme/_uswds-theme-custom-styles.scss +++ b/src/registrar/assets/sass/_theme/_uswds-theme-custom-styles.scss @@ -26,3 +26,7 @@ i.e. p { color: color('blue-10v'); } + +footer p { + color: color('blue-70v'); +} From c89bb69f467754d7b40d04361929b4e777b277a9 Mon Sep 17 00:00:00 2001 From: igorkorenfeld Date: Thu, 15 Sep 2022 15:46:45 -0400 Subject: [PATCH 05/11] Fix path in ops readme --- ops/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ops/README.md b/ops/README.md index db0e235fd..68827a9de 100644 --- a/ops/README.md +++ b/ops/README.md @@ -3,4 +3,4 @@ This directory contains files related to deploying or running the application(s). -Documentation is in [docs/ops](../docs/ops). \ No newline at end of file +Documentation is in [docs/ops](../docs/operations/). From 5888cd48d4cb91326970576f8aac753ae2e645ec Mon Sep 17 00:00:00 2001 From: igorkorenfeld Date: Thu, 15 Sep 2022 15:47:24 -0400 Subject: [PATCH 06/11] Create symbolic links for build and deploy scripts --- src/build.sh | 1 + src/deploy.sh | 1 + 2 files changed, 2 insertions(+) create mode 120000 src/build.sh create mode 120000 src/deploy.sh diff --git a/src/build.sh b/src/build.sh new file mode 120000 index 000000000..adabf4606 --- /dev/null +++ b/src/build.sh @@ -0,0 +1 @@ +../ops/scripts/build.sh \ No newline at end of file diff --git a/src/deploy.sh b/src/deploy.sh new file mode 120000 index 000000000..528c4899a --- /dev/null +++ b/src/deploy.sh @@ -0,0 +1 @@ +../ops/scripts/deploy.sh \ No newline at end of file From 9796ab7ff2a5cc5a38ecf0c8848a646ec40caae1 Mon Sep 17 00:00:00 2001 From: igorkorenfeld Date: Thu, 15 Sep 2022 15:47:59 -0400 Subject: [PATCH 07/11] Add content about build and deploy scripts to documentation --- docs/operations/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/operations/README.md b/docs/operations/README.md index 05b82d991..c288afaf6 100644 --- a/docs/operations/README.md +++ b/docs/operations/README.md @@ -49,9 +49,10 @@ cf target -o cisa-getgov-prototyping -s unstable cf push getgov-unstable -f ops/manifests/manifest-unstable.yaml cf run-task getgov-unstable --command 'python manage.py migrate' --name migrate ``` +Alternatively, you could run the `deploy.sh` script in the `/src` directory to build the assets and deploy to `unstable`. Similarly, you could run `bash.sh` script to just compile and collect the assets without deploying. ## Serving static assets We are using [WhiteNoise](http://whitenoise.evans.io/en/stable/index.html) plugin to serve our static assets on cloud.gov. This plugin is added to the `MIDDLEWARE` list in our apps `settings.py`. -Note that it’s a good idea to run `collectstatic` locally or in the docker container before pushing files up to `unstable`. This is because `collectstatic` relies on timestamps when deciding to whether to overwrite the existing assets in `/public`. Due the way files are uploaded, the compiled css in the `/assets/css` folder on `unstable` will have a slightly earlier timestamp than the files in `/public/css`, and consequently running `collectstatic` on`unstable` will not update `public/css` as you may expect. +Note that it’s a good idea to run `collectstatic` locally or in the docker container before pushing files up to `unstable`. This is because `collectstatic` relies on timestamps when deciding to whether to overwrite the existing assets in `/public`. Due the way files are uploaded, the compiled css in the `/assets/css` folder on `unstable` will have a slightly earlier timestamp than the files in `/public/css`, and consequently running `collectstatic` on`unstable` will not update `public/css` as you may expect. For convenience, both the `deploy.sh` and `build.sh` scripts will take care of that. From f0e6f0545c6c108784533ca2c0973a9b34909690 Mon Sep 17 00:00:00 2001 From: igorkorenfeld Date: Thu, 15 Sep 2022 15:57:11 -0400 Subject: [PATCH 08/11] Change footer paragraph color for testing --- .../assets/sass/_theme/_uswds-theme-custom-styles.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/registrar/assets/sass/_theme/_uswds-theme-custom-styles.scss b/src/registrar/assets/sass/_theme/_uswds-theme-custom-styles.scss index 97f13930a..db757d668 100644 --- a/src/registrar/assets/sass/_theme/_uswds-theme-custom-styles.scss +++ b/src/registrar/assets/sass/_theme/_uswds-theme-custom-styles.scss @@ -28,5 +28,5 @@ p { } footer p { - color: color('blue-70v'); + color: color('blue-50v'); } From 893e479918d1616572e46735689732dbb18f1799 Mon Sep 17 00:00:00 2001 From: Igor Korenfeld <52677065+igorkorenfeld@users.noreply.github.com> Date: Fri, 16 Sep 2022 10:57:31 -0400 Subject: [PATCH 09/11] Update docs/operations/README.md Fix typo in script name Co-authored-by: Neil MartinsenBurrell --- docs/operations/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/operations/README.md b/docs/operations/README.md index c288afaf6..ad9ac04a1 100644 --- a/docs/operations/README.md +++ b/docs/operations/README.md @@ -49,7 +49,7 @@ cf target -o cisa-getgov-prototyping -s unstable cf push getgov-unstable -f ops/manifests/manifest-unstable.yaml cf run-task getgov-unstable --command 'python manage.py migrate' --name migrate ``` -Alternatively, you could run the `deploy.sh` script in the `/src` directory to build the assets and deploy to `unstable`. Similarly, you could run `bash.sh` script to just compile and collect the assets without deploying. +Alternatively, you could run the `deploy.sh` script in the `/src` directory to build the assets and deploy to `unstable`. Similarly, you could run `build.sh` script to just compile and collect the assets without deploying. ## Serving static assets From 0271574e681b9863261ec6662d8ea5b8c285203e Mon Sep 17 00:00:00 2001 From: igorkorenfeld Date: Fri, 16 Sep 2022 12:43:40 -0400 Subject: [PATCH 10/11] Add comment about running collectstatic as breadcrumb in run script --- src/run.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/run.sh b/src/run.sh index 90cf127a4..6caefccfa 100755 --- a/src/run.sh +++ b/src/run.sh @@ -15,4 +15,7 @@ else fi fi +# Make sure that django's `collectstatic` has been run locally before pushing up to unstable, +# so that the styles and static assets to show up correctly on unstable. + gunicorn registrar.config.wsgi -t 60 From 119180fc0304241efb8e1611ee82fd5289278564 Mon Sep 17 00:00:00 2001 From: igorkorenfeld Date: Fri, 16 Sep 2022 12:50:57 -0400 Subject: [PATCH 11/11] Revert style change used for testing --- .../assets/sass/_theme/_uswds-theme-custom-styles.scss | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/registrar/assets/sass/_theme/_uswds-theme-custom-styles.scss b/src/registrar/assets/sass/_theme/_uswds-theme-custom-styles.scss index db757d668..aab929a51 100644 --- a/src/registrar/assets/sass/_theme/_uswds-theme-custom-styles.scss +++ b/src/registrar/assets/sass/_theme/_uswds-theme-custom-styles.scss @@ -27,6 +27,3 @@ p { color: color('blue-10v'); } -footer p { - color: color('blue-50v'); -}