Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FMRF-5: Add file-vault deployment files #795

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 71 additions & 53 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ name: default
type: kubernetes

environment:
APP_NAME: biometric-residence-permit
PROD_ENV: brp
STG_ENV: brp-stg
APP_NAME: fmr
PROD_ENV: sas-fmr-prod
STG_ENV: sas-fmr-stg
UAT_ENV: brp-uat
BRANCH_ENV: brp-branch
PRODUCTION_URL: www.biometric-residence-permit.service.gov.uk
PRODUCTION_URL: www.request-reference-evisa.homeoffice.gov.uk
IMAGE_URL: quay.io/ukhomeofficedigital
IMAGE_REPO: brpapp
IMAGE_REPO: fmr
GIT_REPO: UKHomeOffice/brp_enquiry_forms
HOF_CONFIG: hof-services-config/Biometric_Residency_Permit
HOF_CONFIG: hof-services-config/For_My_Reference_Form
NON_PROD_AVAILABILITY: Mon-Fri 08:00-23:00 Europe/London
READY_FOR_TEST_DELAY: 20s
NOTIFY_STUB: stub
Expand All @@ -25,15 +25,15 @@ trigger:

linting: &linting
pull: if-not-exists
image: node:18
image: node:20.16.0-alpine3.20@sha256:eb8101caae9ac02229bd64c024919fe3d4504ff7f329da79ca60a04db08cef52
environment:
NOTIFY_KEY: USE_MOCK
commands:
- yarn run test:lint

unit_tests: &unit_tests
pull: if-not-exists
image: node:18
image: node:20.16.0-alpine3.20@sha256:eb8101caae9ac02229bd64c024919fe3d4504ff7f329da79ca60a04db08cef52
environment:
NOTIFY_KEY: USE_MOCK
commands:
Expand Down Expand Up @@ -68,9 +68,26 @@ steps:
- master
event: [push, pull_request]

# Trivy Security Scannner for scanning OS related vulnerabilities in Base image of Dockerfile
- name: scan_image_os
pull: always
image: 340268328991.dkr.ecr.eu-west-2.amazonaws.com/acp/trivy/client:latest
resources:
limits:
cpu: 1000
memory: 1024Mi
environment:
IMAGE_NAME: node:20.16.0-alpine3.20@sha256:eb8101caae9ac02229bd64c024919fe3d4504ff7f329da79ca60a04db08cef52
SEVERITY: MEDIUM,HIGH,CRITICAL --dependency-tree
FAIL_ON_DETECTION: false
IGNORE_UNFIXED: false
ALLOW_CVE_LIST_FILE: hof-services-config/infrastructure/trivy/.trivyignore.yaml
when:
event: [push, pull_request]

- name: setup_deploy
pull: if-not-exists
image: node:18
image: node:20.16.0-alpine3.20@sha256:eb8101caae9ac02229bd64c024919fe3d4504ff7f329da79ca60a04db08cef52
environment:
NOTIFY_KEY: USE_MOCK
commands:
Expand Down Expand Up @@ -132,25 +149,22 @@ steps:
branch: master
event: [push, pull_request]

# Trivy Security Scannner
- name: scan-image
# Trivy Security Scannner for scanning nodejs packages in Yarn
- name: scan_node_packages
pull: always
image: 340268328991.dkr.ecr.eu-west-2.amazonaws.com/acp/trivy/client:latest
resources:
limits:
cpu: 1000
memory: 1024Mi
environment:
IMAGE_NAME: brpapp:${DRONE_COMMIT_SHA}
SEVERITY: MEDIUM,HIGH,CRITICAL
IMAGE_NAME: fmr:${DRONE_COMMIT_SHA}
SEVERITY: MEDIUM,HIGH,CRITICAL --dependency-tree
FAIL_ON_DETECTION: false
IGNORE_UNFIXED: true
ALLOW_CVE_LIST_FILE: hof-services-config/Biometric_Residency_Permit/trivy-cve-exceptions.txt
IGNORE_UNFIXED: false
ALLOW_CVE_LIST_FILE: hof-services-config/infrastructure/trivy/.trivyignore.yaml
when:
event:
- pull_request
- push
- tag
event: [push, pull_request]

# Deploy to pull request UAT environment
- name: deploy_to_branch
Expand All @@ -170,7 +184,7 @@ steps:

- name: setup_branch
pull: if-not-exists
image: node:18
image: node:20.16.0-alpine3.20@sha256:eb8101caae9ac02229bd64c024919fe3d4504ff7f329da79ca60a04db08cef52
environment:
NOTIFY_KEY: USE_MOCK
commands:
Expand Down Expand Up @@ -225,7 +239,7 @@ steps:
# Snyk security scans which run after branch deployment to prevent blocking of PR UAT tests
- name: snyk_scan
pull: if-not-exists
image: node:18
image: node:20.16.0-alpine3.20@sha256:eb8101caae9ac02229bd64c024919fe3d4504ff7f329da79ca60a04db08cef52
environment:
SNYK_TOKEN:
from_secret: snyk_token
Expand Down Expand Up @@ -397,67 +411,71 @@ steps:
cron: security_scans
event: cron

- name: cron_snyk_scan
pull: if-not-exists
image: node:18
- name: cron_trivy_scan_image_os
image: 340268328991.dkr.ecr.eu-west-2.amazonaws.com/acp/trivy/client:latest
pull: always
environment:
SNYK_TOKEN:
from_secret: snyk_token
commands:
- yarn install --frozen-lockfile
- yarn run postinstall
- yarn run test:snyk
IMAGE_NAME: node:20.16.0-alpine3.20@sha256:eb8101caae9ac02229bd64c024919fe3d4504ff7f329da79ca60a04db08cef52
SEVERITY: UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL --dependency-tree
FAIL_ON_DETECTION: true
IGNORE_UNFIXED: false
ALLOW_CVE_LIST_FILE: hof-services-config/infrastructure/trivy/.trivyignore.yaml
when:
cron: security_scans
event: cron

- name: cron_trivy_scan
- name: cron_trivy_scan_node_packages
image: 340268328991.dkr.ecr.eu-west-2.amazonaws.com/acp/trivy/client:latest
pull: always
environment:
IMAGE_NAME: brpapp:${DRONE_COMMIT_SHA}
SEVERITY: MEDIUM,HIGH,CRITICAL
FAIL_ON_DETECTION: false
IGNORE_UNFIXED: true
ALLOW_CVE_LIST_FILE: hof-services-config/Biometric_Residency_Permit/trivy-cve-exceptions.txt
IMAGE_NAME: fmr:${DRONE_COMMIT_SHA}
SEVERITY: UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL --dependency-tree
FAIL_ON_DETECTION: true
IGNORE_UNFIXED: false
ALLOW_CVE_LIST_FILE: hof-services-config/infrastructure/trivy/.trivyignore.yaml
when:
cron: security_scans
event: cron
status: [success, failure]

# Slack notification upon a CRON job fail
- name: cron_notify_slack_tear_down_pr_envs
pull: if-not-exists
image: plugins/slack
image: plugins/slack:1.4.1
settings:
channel: sas-build
channel: sas-hof-build-notify
failure: ignore
icon_url: http://readme.drone.io/0.5/logo_dark.svg
icon.url: http://readme.drone.io/0.5/logo_dark.svg
template: "CRON Job {{build.deployTo}} of BRP has {{build.status}} - <{{build.link}}|#{{build.number}}> {{#success build.status}}\n :thumbsup: :thumbsup: :thumbsup:\n{{else}}\n :x: :x: :x:\n{{/success}} Author: {{build.author}}\n\nDuration: {{since job.started}}\n\nJob: <{{build.link}}|#{{build.number}}>\n\nCommit: {{build.commit}}\n"
username: Drone
template: >
*✘ {{ uppercasefirst build.status }}*: Cron job `tear_down_pr_envs` failed to tear down the deployments in the BRANCH environment.

*Repo* <https://github.com/{{ repo.owner }}/{{ repo.name }}/|{{ repo.owner }}/{{ repo.name }}> | *Branch* <https://github.com/{{ repo.owner }}/{{ repo.name }}/commits/{{ build.branch }}|{{build.branch}}> | *Commit* <https://github.com/{{ repo.owner }}/{{ repo.name }}/commit/{{ build.commit }}|{{ truncate build.commit 8 }}>

*Build <{{build.link}}|#{{build.number}}>*
webhook:
from_secret: slack_webhook
from_secret: slack_sas_hof_build_notify_webhook
when:
cron: tear_down_pr_envs
event: cron
status: failure

status: [ failure ]
- name: cron_notify_slack_security_scans
pull: if-not-exists
image: plugins/slack
image: plugins/slack:1.4.1
settings:
channel: sas-build
channel: sas-hof-security
failure: ignore
icon_url: http://readme.drone.io/0.5/logo_dark.svg
icon.url: http://readme.drone.io/0.5/logo_dark.svg
template: "CRON Job {{build.deployTo}} of BRP has {{build.status}} - <{{build.link}}|#{{build.number}}> {{#success build.status}}\n :thumbsup: :thumbsup: :thumbsup:\n{{else}}\n :x: :x: :x:\n{{/success}} Author: {{build.author}}\n\nDuration: {{since job.started}}\n\nJob: <{{build.link}}|#{{build.number}}>\n\nCommit: {{build.commit}}\n"
username: Drone
template: >
*✘ {{ uppercasefirst build.status }}*: Cron job `security_scans` has failed. Prioritise reviewing build logs and addressing issues.

*Repo* <https://github.com/{{ repo.owner }}/{{ repo.name }}/|{{ repo.owner }}/{{ repo.name }}> | *Branch* <https://github.com/{{ repo.owner }}/{{ repo.name }}/commits/{{ build.branch }}|{{build.branch}}> | *Commit* <https://github.com/{{ repo.owner }}/{{ repo.name }}/commit/{{ build.commit }}|{{ truncate build.commit 8 }}>

*Build <{{build.link}}|#{{build.number}}>*
webhook:
from_secret: slack_webhook
from_secret: slack_sas_hof_security_webhook
when:
cron: security_scans
event: cron
status: failure
status: [ failure ]

services:
- name: docker
Expand Down
63 changes: 0 additions & 63 deletions .snyk

This file was deleted.

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18-alpine@sha256:2322b1bb3917b313f2e9308395aa5c39d51b91cc92a5d4d5be6d0451fcfb4d24
FROM node:20.16.0-alpine3.20@sha256:eb8101caae9ac02229bd64c024919fe3d4504ff7f329da79ca60a04db08cef52

USER root

Expand Down
14 changes: 10 additions & 4 deletions bin/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export INGRESS_INTERNAL_ANNOTATIONS=$HOF_CONFIG/ingress-internal-annotations.yam
export INGRESS_EXTERNAL_ANNOTATIONS=$HOF_CONFIG/ingress-external-annotations.yaml
export CONFIGMAP_VALUES=$HOF_CONFIG/configmap-values.yaml
export NGINX_SETTINGS=$HOF_CONFIG/nginx-settings.yaml
export FILEVAULT_NGINX_SETTINGS=$HOF_CONFIG/filevault-nginx-settings.yaml
export FILEVAULT_INGRESS_EXTERNAL_ANNOTATIONS=$HOF_CONFIG/filevault-ingress-external-annotations.yaml

kd='kd --insecure-skip-tls-verify --timeout 10m --check-interval 10s'

Expand All @@ -23,19 +25,23 @@ export KUBE_NAMESPACE=$1
export DRONE_SOURCE_BRANCH=$(echo $DRONE_SOURCE_BRANCH | tr '[:upper:]' '[:lower:]' | tr '/' '-')

if [[ ${KUBE_NAMESPACE} == ${BRANCH_ENV} ]]; then
$kd -f kube/file-vault/file-vault-ingress.yml
$kd -f kube/configmaps -f kube/certs
$kd -f kube/redis -f kube/app
$kd -f kube/redis -f kube/app -f kube/file-vault
elif [[ ${KUBE_NAMESPACE} == ${UAT_ENV} ]]; then
$kd -f kube/file-vault/file-vault-ingress.yml
$kd -f kube/configmaps/configmap.yml
$kd -f kube/redis -f kube/app
$kd -f kube/redis -f kube/file-vault -f kube/app
elif [[ ${KUBE_NAMESPACE} == ${STG_ENV} ]]; then
$kd -f kube/file-vault/file-vault-ingress.yml
$kd -f kube/configmaps/configmap.yml -f kube/app/service.yml
$kd -f kube/app/networkpolicy-internal.yml -f kube/app/ingress-internal.yml
$kd -f kube/redis -f kube/app/deployment.yml
$kd -f kube/redis -f kube/file-vault -f kube/app/deployment.yml
elif [[ ${KUBE_NAMESPACE} == ${PROD_ENV} ]]; then
$kd -f kube/configmaps/configmap.yml -f kube/app/service.yml
$kd -f kube/file-vault/file-vault-ingress.yml
$kd -f kube/app/networkpolicy-external.yml -f kube/app/ingress-external.yml
$kd -f kube/redis -f kube/app/deployment.yml
$kd -f kube/redis -f kube/file-vault -f kube/app/deployment.yml
fi

sleep $READY_FOR_TEST_DELAY
Expand Down
Loading