From 12f0711f2fb8c496f55ad005e12a354581140aa3 Mon Sep 17 00:00:00 2001 From: jholderdevops Date: Fri, 10 Jan 2025 15:01:21 +0000 Subject: [PATCH 01/18] adding html page with a 429 msg --- usr/share/nginx/html/error-429.html | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 usr/share/nginx/html/error-429.html diff --git a/usr/share/nginx/html/error-429.html b/usr/share/nginx/html/error-429.html new file mode 100644 index 0000000..616021c --- /dev/null +++ b/usr/share/nginx/html/error-429.html @@ -0,0 +1,22 @@ + + + + + + Too Many Requests + + + +

Oops! Too Many Requests

+

You have made too many requests in a short period. Please try again later.

+ + From f221bbdb8555dfc9bf402854ab514acdb40d0a7b Mon Sep 17 00:00:00 2001 From: jholderdevops Date: Fri, 10 Jan 2025 17:47:31 +0000 Subject: [PATCH 02/18] adding html page with a 429 msg as config --- kube/app/deployment.yml | 5 +++++ kube/configmaps/configmap-nginx.yaml | 27 +++++++++++++++++++++++++++ usr/share/nginx/html/error-429.html | 22 ---------------------- 3 files changed, 32 insertions(+), 22 deletions(-) create mode 100644 kube/configmaps/configmap-nginx.yaml delete mode 100644 usr/share/nginx/html/error-429.html diff --git a/kube/app/deployment.yml b/kube/app/deployment.yml index 82fd3d6..200fc47 100644 --- a/kube/app/deployment.yml +++ b/kube/app/deployment.yml @@ -112,8 +112,13 @@ spec: volumeMounts: - mountPath: /public name: public + - mountPath: /usr/share/nginx/html/ + - name: custom-errors securityContext: runAsNonRoot: true volumes: - name: public emptyDir: {} + - name: custom-errors + configMap: + name: custom-error-pages diff --git a/kube/configmaps/configmap-nginx.yaml b/kube/configmaps/configmap-nginx.yaml new file mode 100644 index 0000000..2ce5b7f --- /dev/null +++ b/kube/configmaps/configmap-nginx.yaml @@ -0,0 +1,27 @@ +piVersion: v1 +kind: ConfigMap +metadata: + name: custom-error-pages +data: + error-429.html: | + + + + + Too Many Requests + + + +

Rate Limit Exceeded

+

Please try again later.

+ + diff --git a/usr/share/nginx/html/error-429.html b/usr/share/nginx/html/error-429.html deleted file mode 100644 index 616021c..0000000 --- a/usr/share/nginx/html/error-429.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - Too Many Requests - - - -

Oops! Too Many Requests

-

You have made too many requests in a short period. Please try again later.

- - From 72162a0bd3c1937d98058c7f3cba81fddac5fead Mon Sep 17 00:00:00 2001 From: jholderdevops Date: Fri, 10 Jan 2025 18:07:48 +0000 Subject: [PATCH 03/18] syntax error --- kube/app/deployment.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kube/app/deployment.yml b/kube/app/deployment.yml index 200fc47..0342de0 100644 --- a/kube/app/deployment.yml +++ b/kube/app/deployment.yml @@ -113,7 +113,8 @@ spec: - mountPath: /public name: public - mountPath: /usr/share/nginx/html/ - - name: custom-errors + name: custom-errors + readOnly: true securityContext: runAsNonRoot: true volumes: From 6ebc894eac30e5bc1de471d57f8a1b04176c91ee Mon Sep 17 00:00:00 2001 From: jholderdevops Date: Mon, 13 Jan 2025 11:39:33 +0000 Subject: [PATCH 04/18] fixing error on configmap header --- kube/configmaps/configmap-nginx.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kube/configmaps/configmap-nginx.yaml b/kube/configmaps/configmap-nginx.yaml index 2ce5b7f..c4d0730 100644 --- a/kube/configmaps/configmap-nginx.yaml +++ b/kube/configmaps/configmap-nginx.yaml @@ -1,4 +1,5 @@ -piVersion: v1 +--- +apiVersion: v1 kind: ConfigMap metadata: name: custom-error-pages From 654092e8ad1fe4ad55715d5d27b67b7e9150875f Mon Sep 17 00:00:00 2001 From: jholderdevops Date: Tue, 14 Jan 2025 11:24:07 +0000 Subject: [PATCH 05/18] HOFF-1043 - adding custom 429 adjustment --- kube/app/deployment.yml | 5 +++-- kube/configmaps/configmap-nginx.yaml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/kube/app/deployment.yml b/kube/app/deployment.yml index 0342de0..200b252 100644 --- a/kube/app/deployment.yml +++ b/kube/app/deployment.yml @@ -112,7 +112,8 @@ spec: volumeMounts: - mountPath: /public name: public - - mountPath: /usr/share/nginx/html/ + - mountPath: /etc/nginx/html + subPath: error-429.html name: custom-errors readOnly: true securityContext: @@ -122,4 +123,4 @@ spec: emptyDir: {} - name: custom-errors configMap: - name: custom-error-pages + name: custom-errors diff --git a/kube/configmaps/configmap-nginx.yaml b/kube/configmaps/configmap-nginx.yaml index c4d0730..87be733 100644 --- a/kube/configmaps/configmap-nginx.yaml +++ b/kube/configmaps/configmap-nginx.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: ConfigMap metadata: - name: custom-error-pages + name: custom-errors data: error-429.html: | From 41855f94f067be893619d24ca68c077389edd320 Mon Sep 17 00:00:00 2001 From: jholderdevops Date: Tue, 14 Jan 2025 14:52:12 +0000 Subject: [PATCH 06/18] HOFF-1043 - changing the mount path directory --- kube/configmaps/configmap-nginx.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kube/configmaps/configmap-nginx.yaml b/kube/configmaps/configmap-nginx.yaml index 87be733..674c6c2 100644 --- a/kube/configmaps/configmap-nginx.yaml +++ b/kube/configmaps/configmap-nginx.yaml @@ -4,7 +4,7 @@ kind: ConfigMap metadata: name: custom-errors data: - error-429.html: | + 429.html: | From f80629cbe83454540e8c59c27ef9c7c97ff5f4d5 Mon Sep 17 00:00:00 2001 From: jholderdevops Date: Tue, 14 Jan 2025 15:09:13 +0000 Subject: [PATCH 07/18] HOFF-1043 Mounting the 429 nginx error HTML into docker-nginx folder --- kube/app/deployment.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kube/app/deployment.yml b/kube/app/deployment.yml index 200b252..49ed9ab 100644 --- a/kube/app/deployment.yml +++ b/kube/app/deployment.yml @@ -112,8 +112,7 @@ spec: volumeMounts: - mountPath: /public name: public - - mountPath: /etc/nginx/html - subPath: error-429.html + - mountPath: /usr/local/openresty/nginx/html/429.html name: custom-errors readOnly: true securityContext: From 816182e56f6ba68ae13a527f180ef72626270fd7 Mon Sep 17 00:00:00 2001 From: jholderdevops Date: Tue, 14 Jan 2025 15:20:11 +0000 Subject: [PATCH 08/18] simple hello world starting page, so we can focus on testing the requests --- server.js | 74 +++++++------------------------------------------------ 1 file changed, 9 insertions(+), 65 deletions(-) diff --git a/server.js b/server.js index be56c3b..45a7ce4 100644 --- a/server.js +++ b/server.js @@ -1,67 +1,11 @@ -/* eslint-disable no-undef */ +const express = require('express') +const app = express() +const port = 8080 -'use strict'; +app.get('/', (req, res) => { + res.send('Hello World!') +}) -const hof = require('hof'); -let settings = require('./hof.settings'); -const ExclusionDates = require('./apps/are_form/models/exclusion_dates'); -const config = require('./config.js'); - -settings = Object.assign({}, settings, { - behaviours: settings.behaviours.map(require), - routes: settings.routes.map(require), - getCookies: false, - getTerms: false, - getAccessibility: false, - csp: { - imgSrc: [ - 'www.google-analytics.com', - 'ssl.gstatic.com', - 'www.google.co.uk/ads/ga-audiences' - ], - connectSrc: [ - 'https://www.google-analytics.com', - 'https://region1.google-analytics.com', - 'https://region1.analytics.google.com' - ] - } -}); - -// overwrite exclusion_days.json once a day -setInterval(() => { - const exclusionDates = new ExclusionDates(); - exclusionDates.saveExclusionDays(); -}, 1000 * 60 * 60 * 24); - -// overwrite exclusion_days.json with latest API data and start the application -const exclusionDates = new ExclusionDates(); - -exclusionDates.saveExclusionDays() - .then(() => { - const app = hof(settings); - - app.use((req, res, next) => { - res.locals.htmlLang = 'en'; - // Set feedback link and phase banner - res.locals.feedbackUrl = config.feedbackUrl; - next(); - }); - - // Set feedback and phase banner on cookies, accessibility and terms pages - // along with the getTerms: false, getCookies: false, getAccessibility: false config - app.use('/terms-and-conditions', (req, res, next) => { - res.locals = Object.assign({}, res.locals, req.translate('terms')); - next(); - }); - - app.use('/cookies', (req, res, next) => { - res.locals = Object.assign({}, res.locals, req.translate('cookies')); - next(); - }); - - app.use('/accessibility', (req, res, next) => { - res.locals = Object.assign({}, res.locals, req.translate('accessibility')); - next(); - }); - module.exports = app; - }); +app.listen(port, () => { + console.log(`Example app listening on port ${port}`) +}) From 719a952d772fcf1f70136ecf84bad29eb4aef7e4 Mon Sep 17 00:00:00 2001 From: jholderdevops Date: Tue, 14 Jan 2025 16:19:08 +0000 Subject: [PATCH 09/18] HOFF-1043 adding the right path without a directory --- kube/app/deployment.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kube/app/deployment.yml b/kube/app/deployment.yml index 49ed9ab..6d30f2b 100644 --- a/kube/app/deployment.yml +++ b/kube/app/deployment.yml @@ -112,7 +112,8 @@ spec: volumeMounts: - mountPath: /public name: public - - mountPath: /usr/local/openresty/nginx/html/429.html + - mountPath: /usr/local/openresty/nginx/html + subPath: 429.html name: custom-errors readOnly: true securityContext: From c63153d04ae14890da744f62fc134590345de5c2 Mon Sep 17 00:00:00 2001 From: jholderdevops Date: Tue, 14 Jan 2025 16:37:16 +0000 Subject: [PATCH 10/18] Error adding the mounting --- kube/app/deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kube/app/deployment.yml b/kube/app/deployment.yml index 6d30f2b..56fa57f 100644 --- a/kube/app/deployment.yml +++ b/kube/app/deployment.yml @@ -112,7 +112,7 @@ spec: volumeMounts: - mountPath: /public name: public - - mountPath: /usr/local/openresty/nginx/html + - mountPath: /usr/local/openresty/nginx/html/429.html subPath: 429.html name: custom-errors readOnly: true From b1855ef6e335baab6d1d40a61384eefb0802f37d Mon Sep 17 00:00:00 2001 From: jholderdevops Date: Tue, 14 Jan 2025 17:58:35 +0000 Subject: [PATCH 11/18] HOFF-1043- adding nginx.conf files as well as adding it as a config --- .../{configmap-nginx.yaml => configmap-nginx.yml} | 0 kube/configmaps/nginx-config.yml | 7 +++++++ 2 files changed, 7 insertions(+) rename kube/configmaps/{configmap-nginx.yaml => configmap-nginx.yml} (100%) create mode 100644 kube/configmaps/nginx-config.yml diff --git a/kube/configmaps/configmap-nginx.yaml b/kube/configmaps/configmap-nginx.yml similarity index 100% rename from kube/configmaps/configmap-nginx.yaml rename to kube/configmaps/configmap-nginx.yml diff --git a/kube/configmaps/nginx-config.yml b/kube/configmaps/nginx-config.yml new file mode 100644 index 0000000..efe6dbc --- /dev/null +++ b/kube/configmaps/nginx-config.yml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: nginx-config +data: + custom-http-errors: "429" + error-pages-location: "/usr/local/openresty/nginx/html/" From 50031a858b76ff278fbafbf6d0c5cd84cd2e8806 Mon Sep 17 00:00:00 2001 From: jholderdevops Date: Wed, 15 Jan 2025 10:54:17 +0000 Subject: [PATCH 12/18] HOFF-1043 redeploying for the test - new IP added --- .drone.yml | 92 +++++++++++++++++++++++++++--------------------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/.drone.yml b/.drone.yml index 5ac1b17..aded74e 100644 --- a/.drone.yml +++ b/.drone.yml @@ -23,31 +23,31 @@ trigger: - feature/* - master -linting: &linting - pull: if-not-exists - image: node:20 - environment: - NOTIFY_KEY: USE_MOCK - commands: - - yarn run test:lint - -unit_tests: &unit_tests - pull: if-not-exists - image: node:20 - environment: - NOTIFY_KEY: USE_MOCK - commands: - - yarn run test:unit - -sonar_scanner: &sonar_scanner - pull: if-not-exists - image: quay.io/ukhomeofficedigital/sonar-scanner-nodejs:latest - commands: - - sonar-scanner -Dproject.settings=./sonar-project.properties - -acceptance_tests: &acceptance_tests - pull: if-not-exists - image: mcr.microsoft.com/playwright:v1.12.3-focal +# linting: &linting +# pull: if-not-exists +# image: node:20 +# environment: +# NOTIFY_KEY: USE_MOCK +# commands: +# - yarn run test:lint + +# unit_tests: &unit_tests +# pull: if-not-exists +# image: node:20 +# environment: +# NOTIFY_KEY: USE_MOCK +# commands: +# - yarn run test:unit + +# sonar_scanner: &sonar_scanner +# pull: if-not-exists +# image: quay.io/ukhomeofficedigital/sonar-scanner-nodejs:latest +# commands: +# - sonar-scanner -Dproject.settings=./sonar-project.properties + +# acceptance_tests: &acceptance_tests +# pull: if-not-exists +# image: mcr.microsoft.com/playwright:v1.12.3-focal steps: - name: clone_repos @@ -80,29 +80,29 @@ steps: - master event: push - - name: linting_deploy - <<: *linting - when: - branch: - include: - - master - event: push + # - name: linting_deploy + # <<: *linting + # when: + # branch: + # include: + # - master + # event: push - - name: unit_tests_deploy - <<: *unit_tests - when: - branch: - include: - - master - event: push + # - name: unit_tests_deploy + # <<: *unit_tests + # when: + # branch: + # include: + # - master + # event: push - - name: sonar_scanner_deploy - <<: *sonar_scanner - when: - branch: - include: - - master - event: push + # - name: sonar_scanner_deploy + # <<: *sonar_scanner + # when: + # branch: + # include: + # - master + # event: push - name: build_image image: 340268328991.dkr.ecr.eu-west-2.amazonaws.com/acp/dind From fded0e078d84b51e5ba312e4c3f9e4fada8eb906 Mon Sep 17 00:00:00 2001 From: jholderdevops Date: Wed, 15 Jan 2025 10:56:40 +0000 Subject: [PATCH 13/18] HOFF-1043 trigger building cmt --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e438bdc..b6c62bf 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ A calculator to determine Appeal Rights Exhausted # Setup +# Trigger build ## Install prerequisites From 6552e213d5a67a7458ee19dce9acb672eddc2f9b Mon Sep 17 00:00:00 2001 From: jholderdevops Date: Wed, 15 Jan 2025 10:59:50 +0000 Subject: [PATCH 14/18] HOFF-1043 remiving uncessary branches in this branch --- .drone.yml | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/.drone.yml b/.drone.yml index aded74e..766ed67 100644 --- a/.drone.yml +++ b/.drone.yml @@ -182,32 +182,32 @@ steps: - feature/* event: pull_request - - name: linting_branch - <<: *linting - when: - branch: - include: - - master - - feature/* - event: pull_request + # - name: linting_branch + # <<: *linting + # when: + # branch: + # include: + # - master + # - feature/* + # event: pull_request - - name: unit_tests_branch - <<: *unit_tests - when: - branch: - include: - - master - - feature/* - event: pull_request + # - name: unit_tests_branch + # <<: *unit_tests + # when: + # branch: + # include: + # - master + # - feature/* + # event: pull_request - - name: sonar_scanner_branch - <<: *sonar_scanner - when: - branch: - include: - - master - - feature/* - event: pull_request + # - name: sonar_scanner_branch + # <<: *sonar_scanner + # when: + # branch: + # include: + # - master + # - feature/* + # event: pull_request - name: build_acceptance_branch pull: if-not-exists From afe7fcd9f0ef841f7adfb3d589a28e9c954d7356 Mon Sep 17 00:00:00 2001 From: jholderdevops Date: Wed, 15 Jan 2025 17:18:16 +0000 Subject: [PATCH 15/18] HOFF_1043 trying acp-nginx-proxy --- kube/app/deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kube/app/deployment.yml b/kube/app/deployment.yml index 56fa57f..34c6013 100644 --- a/kube/app/deployment.yml +++ b/kube/app/deployment.yml @@ -97,7 +97,7 @@ spec: - name: nginx-proxy # nginx-proxy-govuk:v4 - image: quay.io/ukhomeofficedigital/nginx-proxy-govuk@sha256:4470064d0b1d20ae08c5fd85551576cb687f342a22d6cb456fda9b2c4ce8c8df + image: quay.io/ukhomeofficedigital/acp-nginx-proxy:7356ad9362d760c3044e86e977c2f7a29357abce resources: requests: memory: 10Mi From 48dcf3e9bbd11bb5f9580fc19926084bf590acaf Mon Sep 17 00:00:00 2001 From: jholderdevops Date: Wed, 15 Jan 2025 17:26:23 +0000 Subject: [PATCH 16/18] HOFF-1043 using the acp 0.1.3 nginx proxy image --- kube/app/deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kube/app/deployment.yml b/kube/app/deployment.yml index 34c6013..527ce30 100644 --- a/kube/app/deployment.yml +++ b/kube/app/deployment.yml @@ -97,7 +97,7 @@ spec: - name: nginx-proxy # nginx-proxy-govuk:v4 - image: quay.io/ukhomeofficedigital/acp-nginx-proxy:7356ad9362d760c3044e86e977c2f7a29357abce + image: quay.io/ukhomeofficedigital/acp-nginx-proxy:0.1.3 resources: requests: memory: 10Mi From 458d78e92152df7c5d258f57f30ca35b1b01cb85 Mon Sep 17 00:00:00 2001 From: jholderdevops Date: Fri, 17 Jan 2025 11:50:10 +0000 Subject: [PATCH 17/18] HOFF-1043 adding new hof nginx image --- kube/app/deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kube/app/deployment.yml b/kube/app/deployment.yml index 527ce30..7c4c058 100644 --- a/kube/app/deployment.yml +++ b/kube/app/deployment.yml @@ -97,7 +97,7 @@ spec: - name: nginx-proxy # nginx-proxy-govuk:v4 - image: quay.io/ukhomeofficedigital/acp-nginx-proxy:0.1.3 + image: 340268328991.dkr.ecr.eu-west-2.amazonaws.com/sas/hof-docker-nginx-proxy:89a68570de03813257d1fbdab3dc8733996e93e7 resources: requests: memory: 10Mi From 7ec6105c1e7dd9d023d82da8b56473876e719ac8 Mon Sep 17 00:00:00 2001 From: jholderdevops Date: Fri, 17 Jan 2025 14:34:15 +0000 Subject: [PATCH 18/18] HOFF-1043 testing update image --- kube/app/deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kube/app/deployment.yml b/kube/app/deployment.yml index 7c4c058..ec542e4 100644 --- a/kube/app/deployment.yml +++ b/kube/app/deployment.yml @@ -97,7 +97,7 @@ spec: - name: nginx-proxy # nginx-proxy-govuk:v4 - image: 340268328991.dkr.ecr.eu-west-2.amazonaws.com/sas/hof-docker-nginx-proxy:89a68570de03813257d1fbdab3dc8733996e93e7 + image: 340268328991.dkr.ecr.eu-west-2.amazonaws.com/sas/hof-docker-nginx-proxy:70a0bc2dd6011e70ead6c5f09612faa4d7a95916 resources: requests: memory: 10Mi