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

Sync branches - merge main into demo #109

Closed
wants to merge 77 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
e30646f
Composer update to trigger build
MalcolmVonMoJ Aug 9, 2023
2d7fd34
Merge pull request #90 from ministryofjustice/cu
MalcolmVonMoJ Aug 9, 2023
0a7de94
Trigger Rebuild
RobLoweMOJ Aug 10, 2023
c1ad146
Merge pull request #91 from ministryofjustice/dev
RobLoweMOJ Aug 15, 2023
1a0d857
Trigger rebuild
RobLoweMOJ Aug 15, 2023
8166ed8
Update README.md
RobLoweMOJ Aug 15, 2023
3b05b5d
Trigger Build - brookhouse
RobLoweMOJ Aug 16, 2023
a9ace24
Update README.md
RobLoweMOJ Aug 21, 2023
0fc3282
Update README.md
RobLoweMOJ Aug 21, 2023
74953fc
Activate feed parser - add job listing
RobLoweMOJ Aug 22, 2023
36db4ba
Merge pull request #93 from ministryofjustice/activate-feed-parser
RobLoweMOJ Aug 22, 2023
99379bf
Add latest tag to feed parser
brown-a2 Aug 25, 2023
49d4f82
Add mask password
brown-a2 Aug 25, 2023
21ba990
Move with directive
brown-a2 Aug 25, 2023
9333c98
Job filters now merged into main
brown-a2 Aug 25, 2023
0ef4a10
Hale version 3.11.1 deploy
MalcolmVonMoJ Aug 29, 2023
2c3f519
Add Always to image pull
brown-a2 Aug 29, 2023
d749430
Add masked password directive
brown-a2 Aug 29, 2023
1c4789b
Add latest Feed Parser and Always pull
brown-a2 Aug 29, 2023
a2f18a1
Hale version 3.11.2 deploy
MalcolmVonMoJ Aug 30, 2023
5175817
Hale version 3.11.3 deploy
MalcolmVonMoJ Aug 30, 2023
c48c060
Update Brookhouse domain creds in ingress
brown-a2 Aug 31, 2023
eac6514
Merge pull request #94 from ministryofjustice/brookhouse-domain-migra…
brown-a2 Aug 31, 2023
2736533
Hale version 3.11.4 deploy
MalcolmVonMoJ Aug 31, 2023
a0999a7
Add Law Com legacy theme
brown-a2 Sep 3, 2023
69022db
Add lawcom to build assets
brown-a2 Sep 4, 2023
9c43efb
Add classic editor plugin
brown-a2 Sep 4, 2023
66e7853
Hale version 3.11.5 deploy
MalcolmVonMoJ Sep 6, 2023
b7239a6
Add JusticeJobs theme
brown-a2 Sep 6, 2023
0eac64c
Add JusticeJobs compile to deployment
brown-a2 Sep 6, 2023
c44ef87
Add JusticeJobs support plugins
brown-a2 Sep 6, 2023
75628b9
Fix composer.json formatting
brown-a2 Sep 6, 2023
62ceda8
Test new error handling method
brown-a2 Sep 7, 2023
7ef782f
Remove WP Error handling
brown-a2 Sep 7, 2023
926724f
Hale version 3.11.6 deploy
MalcolmVonMoJ Sep 11, 2023
8c798cc
Add prisonandprobationjobs.gov.uk (PPJ) domain to ingress
brown-a2 Sep 20, 2023
1a036ca
Merge pull request #95 from ministryofjustice/hale-ppj-domain-migration
brown-a2 Sep 20, 2023
33d5ba4
Trigger
RobLoweMOJ Sep 20, 2023
3a0ec06
Remove plugins we do not use
brown-a2 Sep 21, 2023
8cfef53
Merge pull request #96 from ministryofjustice/dev-merge
brown-a2 Sep 21, 2023
122ea8a
Upgrade Hale to WP 6.3
brown-a2 Sep 21, 2023
6e1be01
Modify how ingress handles security txt redirect
brown-a2 Sep 21, 2023
3612677
Update README.md
brown-a2 Sep 21, 2023
44f8e65
Update README.md
brown-a2 Sep 21, 2023
54dc94a
Merge pull request #98 from ministryofjustice/brown-a2-patch-1
brown-a2 Sep 21, 2023
93bc687
Update README.md
brown-a2 Sep 21, 2023
5ddee97
Merge pull request #99 from ministryofjustice/brown-a2-patch-1
brown-a2 Sep 21, 2023
e9a5c02
Merge pull request #97 from ministryofjustice/dev-update-wp-nginx
brown-a2 Sep 21, 2023
60ac05c
Test increase nginx header size
RobLoweMOJ Sep 22, 2023
9c3ef69
Test client_max_body_size increase
RobLoweMOJ Sep 22, 2023
7c15da4
Remove test nginx settings
RobLoweMOJ Sep 22, 2023
cd3c7ef
Revert nginx settings
RobLoweMOJ Sep 22, 2023
866133d
Update README.md
brown-a2 Sep 22, 2023
0e4e87e
Update README.md
brown-a2 Sep 22, 2023
c97fc43
Merge pull request #100 from ministryofjustice/brown-a2-patch-1
brown-a2 Sep 22, 2023
34e34b4
Update README.md
brown-a2 Sep 22, 2023
e185afb
Hale version 3.11.10 deploy
MalcolmVonMoJ Sep 22, 2023
6177871
Hale version 3.11.11 deploy
MalcolmVonMoJ Sep 25, 2023
72d9cb6
Hale version 3.11.12 and MoJ Blocks version 3.9.0 deploy
MalcolmVonMoJ Sep 25, 2023
1f0b07c
Hale version 3.11.13 deploy
MalcolmVonMoJ Sep 26, 2023
a211cc9
Adjust PHP FPM processes to match available memory
brown-a2 Sep 27, 2023
bc61fa7
Merge pull request #103 from ministryofjustice/dev-server-adjustment
brown-a2 Sep 27, 2023
c796b74
Add htop
brown-a2 Sep 27, 2023
946a572
Turn on HPA for testing
brown-a2 Sep 27, 2023
89fe30b
Set CPU target to 90%
brown-a2 Sep 27, 2023
245e6ff
Merge pull request #104 from ministryofjustice/hpa-rollout
brown-a2 Sep 27, 2023
b8d54f0
Increase replica count
brown-a2 Sep 27, 2023
42a0635
Merge pull request #105 from ministryofjustice/pod-count
brown-a2 Sep 27, 2023
07e60fa
Add Hale Dash child theme
brown-a2 Oct 3, 2023
88a4721
Merge pull request #106 from ministryofjustice/add-child-theme
brown-a2 Oct 3, 2023
3952c10
Increase HPA percentage
brown-a2 Oct 3, 2023
4af7a7e
Merge pull request #107 from ministryofjustice/hpa-scale
brown-a2 Oct 3, 2023
8cc6e77
Fix depricated HPA API in helm
brown-a2 Oct 4, 2023
9b2f7bd
Merge pull request #108 from ministryofjustice/update-hpa-version
brown-a2 Oct 4, 2023
77eb149
Tweak PHP-FPM
brown-a2 Oct 4, 2023
a92a03e
Remove auto set Hale theme
brown-a2 Oct 5, 2023
c7dac7f
Trigger Build
brown-a2 Oct 6, 2023
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
20 changes: 14 additions & 6 deletions .github/workflows/rw-build-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
environment:
required: true
type: string
secrets:
secrets:
ecr-role:
required: true
ecr-region:
Expand Down Expand Up @@ -88,13 +88,15 @@ jobs:
- name: Login to ECR
uses: aws-actions/amazon-ecr-login@v1
id: login-ecr
with:
mask-password: true
- name: Build and Push Nginx Image
run: |
docker build --pull --no-cache --tag $REGISTRY/$REPOSITORY:hale-platform_nginx-$IMAGE_TAG --file nginx.dockerfile .
docker push $REGISTRY/$REPOSITORY:hale-platform_nginx-$IMAGE_TAG
docker push $REGISTRY/$REPOSITORY:hale-platform_nginx-$IMAGE_TAG
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: ${{ secrets.ecr-repo }}
REPOSITORY: ${{ secrets.ecr-repo }}
IMAGE_TAG: ${{ github.sha }}
- name: Run Composer
run: |
Expand All @@ -106,13 +108,19 @@ jobs:
npm run production --if-present --prefix ./wordpress/wp-content/themes/hale
npm install --prefix ./wordpress/wp-content/themes/brookhouse
npm run production --if-present --prefix ./wordpress/wp-content/themes/brookhouse
npm install --prefix ./wordpress/wp-content/themes/lawcom
npm run production --if-present --prefix ./wordpress/wp-content/themes/lawcom
npm install --prefix ./wordpress/wp-content/themes/justicejobs
npm run production --if-present --prefix ./wordpress/wp-content/themes/justicejobs
npm install --prefix ./wordpress/wp-content/themes/hale-dash
npm run production --if-present --prefix ./wordpress/wp-content/themes/hale-dash
- name: Build and Push Wordpress Image
run: |
docker build --pull --no-cache --tag $REGISTRY/$REPOSITORY:hale-platform_wordpress-$IMAGE_TAG --file wp.dockerfile .
docker push $REGISTRY/$REPOSITORY:hale-platform_wordpress-$IMAGE_TAG
docker push $REGISTRY/$REPOSITORY:hale-platform_wordpress-$IMAGE_TAG
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: ${{ secrets.ecr-repo }}
REPOSITORY: ${{ secrets.ecr-repo }}
IMAGE_TAG: ${{ github.sha }}

deployImage:
Expand Down Expand Up @@ -161,4 +169,4 @@ jobs:
--set ingress.metadata.annotations.setidentifier=hale-platform-ingress-${{ secrets.kube-namespace }}-green \
--set domain=${{ secrets.kube-namespace }}.apps.live.cloud-platform.service.justice.gov.uk \
--set nginx.image.repository=754256621582.dkr.ecr.eu-west-2.amazonaws.com/${{ secrets.ecr-repo }}:hale-platform_nginx-${{ github.sha }} \
--set wp.image.repository=754256621582.dkr.ecr.eu-west-2.amazonaws.com/${{ secrets.ecr-repo }}:hale-platform_wordpress-${{ github.sha }}
--set wp.image.repository=754256621582.dkr.ecr.eu-west-2.amazonaws.com/${{ secrets.ecr-repo }}:hale-platform_wordpress-${{ github.sha }}
143 changes: 10 additions & 133 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,142 +1,19 @@
# Hale Platform WordPress Multisite
[![Hale Platform Deployment](https://github.com/ministryofjustice/hale-platform/actions/workflows/cd.yaml/badge.svg?branch=main)](https://github.com/ministryofjustice/hale-platform/actions/workflows/cd.yaml)

## Installation
# Hale Platform

This launches a working Wordpress site that pulls in the Hale theme.
You can choose to launch the site in Docker or Kubernetes.
This repository provides all the code required to run an instance of WordPress multisite in kubernetes. It uses the [WordPress official Alpine image](https://hub.docker.com/_/wordpress), and is modified to launch a multisite network. It uses PHP dependency manager Composer to pull in all the themes and plugins used by the multisite.

Currently only the Docker build works locally but for CloudPlatform
environments you can use the kubernetes build.
For further technical details around the architecture, visit our wiki [overview](https://github.com/ministryofjustice/hale-platform/wiki).

## Required
## Deploy to a kubernetes environment

- [Docker](https://www.docker.com/) and kubernetes which can be turned on via the Docker-Desktop dashboard.
- Have [Dory proxy](https://github.com/FreedomBen/dory) running for local install so you have a domain `hale.docker`
to work with.
- Install [Helm](https://helm.sh/docs) - `brew install helm`
We use [Helm charts](https://github.com/ministryofjustice/hale-platform/tree/main/helm_deploy/wordpress) to manage our kubernetes manifest files. These are configured to work in the CloudPlatforms kubernetes environment but could be modified to work in any kubernetes cluster. This repo is used to deploy infrastructure changes (ie helm chart/kubernetes changes) and changes to the application, as it pulls in the latest version of the Hale theme and plugins.

## Nice to have
To deploy to one of our environments, push a code change to one of the corresponding branches in this repo which will trigger GitActions that deploy the code into the kubernetes cluster.

- [Kubens and Kubectx - to switch between namespace & clusters](https://github.com/ahmetb/kubectx)
- [Stern - logging and debugging](https://github.com/wercker/stern)
- [JQ - processing JSON](https://stedolan.github.io/jq)
More information about our deployment process, is available in our [Deployment](https://github.com/ministryofjustice/hale-platform/wiki/Deployment) wiki.

## Launch instructions

### Kubernetes

You will need an `.env.local` file in the root of this project with all the
variables needed to run the app. Get this from Rob or Adam until we have
a proper place for it.

1. Run `dory up` to get dory running as you will need this to proxy the
hale.docker domain locally which WP multisite needs.
2. Run `make build` to build all the Docker images you'll need locally for k8s to use.
3. Run `make deploylocal` to run the helm command which launches the site.
3. If all is running, go to `http://hale.docker` in your browser. You will be greeted by a WP installation page.

### Docker
Make sure you have the `.env.local` file with correct .env vars in the root of
this repository.

1. Create and install local TLS certs so the site runs on https.
2. Run `Dory up` from within this repository.
3. Run `make build`. This builds the images required and all assets.
4. Run `make run` to launch the site on https://hale.docker

## Create and install TLS certs (currently only setup for Docker not k8s)

1. Run `brew install mkcert` to install the mkcert app.
2. Run `mkdir -r /bin/certs` in the root of this repository, to create a new /certs folder in the bin/ directory.
3. In the /certs folder run `mkcert hale.docker` to create the certificates.
4. Run `mkcert -install` to apply certificates to your mac.
5. Make sure Dory is running `Dory up`.
6. Run `Make build`, to build the image and pull in the new cert pem files.
7. Go to your browser at the URL https://hale.docker

## Themes and Plugins.

WordPress themes and plugins are loaded as part of the Docker image build. They
are pulled into the build using PHP's Composer dependancy manager. To add or
remove plugins, modify the composer.json file in the root of this directory.

## Deployment
Our deployment pipeline uses GitActions to deploy to our various environments

Hale platform can be deployed to 4 environments:
- Demonstration
- Development
- Staging
- Production

### Demonstration

The Demo environment is for showcases features and site functions to
stakeholders. A commit to the `demo` branch will trigger a build of the site to
the demostration environment.

### Development

The Dev environment is for developers. This can be used for testing and
trailing features and functions in a CloudPlatform environment. A commit to the
`dev` branch will trigger a build in the development environment.

### Staging

The Staging environment is the preprod environment, used to test code
deployments before they reach production. A commit to the `main` branch will
trigger a build to the staging environment.

### Production

The Prod environment is the live environment for the multisite. Once a code
change has been tested on staging, you can trigger the build to move from
staging to production via the `Review deployments` button on the GitAction run
page. If you don't have a review deployments button you may not have the
correct permissions to deploy to production.

## DB Import/Export

This has to be done in steps.

First step, setup a pod in your k8s namespace. Use the following kubectl
command (delete pod after you're done using):

```
kubectl \ :dev
-n <add namespace> \
run port-forward-pod \
--image=ministryofjustice/port-forward \
--port=5432 \
--env="REMOTE_HOST=<add in cloudplatform remote host aws address - port not needed>" \
--env="LOCAL_PORT=5432" \
--env="REMOTE_PORT=3306"
```

Second, step, setup port-forwarding pod with the following command:

```
kubectl \ :dev
-n hale-platform-dev \
port-forward \
port-forward-pod 5432:5432
```

Third, once portforwarding is running, in a new tab, you can import and export using the
scripts db-import.sh and db-export.sh in the /bin directory. They will ask
for the db secrets, which you will need to get via the CloudPlatform brew
tool.

Note: to import you will need to have the `mysql` & `mysqldump` program installed running on your local
machine

### Connect using MySQL Pro

Using the CloudPlatform secrets tool, fill in the fields as following:

Host: 127.0.0.1
Username: <db username>
Password: <db password>
Database: <db database name>
Port: 5432
## Deploy locally on a Mac using Docker

To run this WordPress instance locally, follow our guidance on [local development](https://github.com/ministryofjustice/hale-platform/wiki/Local-development).
11 changes: 8 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@
"vlucas/phpdotenv": "^3.0.0",
"oscarotero/env": "^1.1.0",
"acf/advanced-custom-fields-pro": "*",
"ministryofjustice/wp-hale": "dev-job-listing-page-filters",
"ministryofjustice/wp-hale": "*",
"ministryofjustice/brookhouse": "dev-main",
"ministryofjustice/lawcom": "dev-main",
"ministryofjustice/justicejobs": "dev-main",
"ministryofjustice/hale-dash": "dev-main",
"wpackagist-plugin/wordpress-seo": "*",
"wpackagist-plugin/footnotes-made-easy": "*",
"wpackagist-plugin/simple-301-redirects": "*",
Expand All @@ -46,9 +49,11 @@
"wpackagist-plugin/wp-force-login": "*",
"wpackagist-plugin/safe-svg":"*",
"wpackagist-plugin/redirection": "*",
"wpackagist-plugin/limit-login-attempts-reloaded": "*",
"wpackagist-plugin/wps-hide-login": "*",
"wpackagist-plugin/wps-limit-login": "*",
"wpackagist-plugin/classic-editor":"1.6.3",
"wpackagist-plugin/duplicate-post":"4.5",
"wpackagist-plugin/wp-accessibility":"2.0.1",
"wpackagist-plugin/advanced-custom-fields-table-field":"1.3.20",
"relevanssi/relevanssi-premium": "*",
"ministryofjustice/wp-moj-components": "dev-hale-platform",
"ministryofjustice/wp-user-roles": "*",
Expand Down
4 changes: 2 additions & 2 deletions helm_deploy/wordpress/templates/cron-feedparser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ spec:
serviceAccountName: hale-platform-{{ .Values.configmap.envtype }}-service
containers:
- name: feedparser-cron
image: 754256621582.dkr.ecr.eu-west-2.amazonaws.com/jotw-content-devs/hale-platform-{{ .Values.configmap.envtype }}-feed-parser-ecr:feedparser
imagePullPolicy: IfNotPresent
image: 754256621582.dkr.ecr.eu-west-2.amazonaws.com/jotw-content-devs/hale-platform-{{ .Values.configmap.envtype }}-feed-parser-ecr:latest
imagePullPolicy: Always
envFrom:
- configMapRef:
name: hale-wp-config-{{ .Release.Revision }}
Expand Down
12 changes: 9 additions & 3 deletions helm_deploy/wordpress/templates/hpa-wordpress.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- if .Values.hpa.enabled }}
apiVersion: autoscaling/v1
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: hale-platform-hpa
Expand All @@ -11,7 +11,7 @@ spec:
name: wordpress
{{- if eq .Values.configmap.envtype "prod" }}
minReplicas: 3
maxReplicas: 8
maxReplicas: 12
{{- else if eq .Values.configmap.envtype "staging" }}
minReplicas: 2
maxReplicas: 4
Expand All @@ -22,5 +22,11 @@ spec:
minReplicas: 1
maxReplicas: 1
{{- end }}
targetCPUUtilizationPercentage: 95
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 95
{{- end }}
27 changes: 0 additions & 27 deletions helm_deploy/wordpress/templates/ingress-redirect.yaml

This file was deleted.

57 changes: 57 additions & 0 deletions helm_deploy/wordpress/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ metadata:
SecRuleEngine On
SecDefaultAction "phase:2,pass,log,tag:github_team=hale-platform"
SecRuleRemoveById 949110
nginx.ingress.kubernetes.io/server-snippet: |
location = /.well-known/security.txt {
auth_basic off;
return 301 https://raw.githubusercontent.com/ministryofjustice/security-guidance/main/contact/vulnerability-disclosure-security.txt;
}
spec:
ingressClassName: modsec
tls:
Expand Down Expand Up @@ -48,6 +53,18 @@ spec:
- hosts:
- www.imb.org.uk
secretName: imb-www-cert
- hosts:
- brookhouseinquiry.org.uk
secretName: brookhouse-cert
- hosts:
- www.brookhouseinquiry.org.uk
secretName: brookhouse-www-cert
- hosts:
- prisonandprobationjobs.gov.uk
secretName: ppj-cert
- hosts:
- www.prisonandprobationjobs.gov.uk
secretName: ppj-www-cert
{{- end }}
rules:
- host: {{ .Values.domain }}
Expand Down Expand Up @@ -161,5 +178,45 @@ spec:
name: wordpress
port:
number: 8080
- host: brookhouseinquiry.org.uk
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: wordpress
port:
number: 8080
- host: www.brookhouseinquiry.org.uk
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: wordpress
port:
number: 8080
- host: prisonandprobationjobs.gov.uk
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: wordpress
port:
number: 8080
- host: www.prisonandprobationjobs.gov.uk
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: wordpress
port:
number: 8080
{{- end }}
{{- end }}
Loading