Skip to content

Commit cc9315d

Browse files
committed
CCM-7248: update header to point and redirect to /auth
1 parent 6e78175 commit cc9315d

File tree

8 files changed

+162
-9
lines changed

8 files changed

+162
-9
lines changed

Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM node:20-alpine AS base
2+
3+
# Install necessary packages for Puppeteer
4+
# Installs latest Chromium (100) package.
5+
RUN apk add --no-cache \
6+
udev \
7+
ttf-freefont \
8+
chromium
9+
10+
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
11+
12+
WORKDIR /app
13+
14+
COPY package*.json ./
15+
16+
RUN npm install
17+
18+
EXPOSE 3000
19+
20+
CMD ["npm", "run", "dev"]

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,32 +37,36 @@
3737

3838
### Running the project locally
3939

40-
1) Convert the email HTML template into a JSON file that can be packaged with the email sending lambda.
40+
1. Convert the email HTML template into a JSON file that can be packaged with the email sending lambda.
4141

4242
```shell
4343
npm run generate-dependencies
4444
```
4545

46-
2) (Optional) If you want to test sending emails then you will need to set the following environment variables locally.
46+
2. (Optional) If you want to test sending emails then you will need to set the following environment variables locally.
4747

4848
```shell
4949
export ACCOUNT_ID=<aws_account_id>
5050
export NOTIFY_DOMAIN_NAME=<ses_verified_domain>
5151
```
5252

53-
3) To run an Amplify sandbox. To do this, authenticate with an AWS account that has Amplify enabled, then run:
53+
3. To run an Amplify sandbox. To do this, authenticate with an AWS account that has Amplify enabled, then run:
5454

5555
```shell
5656
npx ampx sandbox --profile <the name of the AWS config profile for the account you are authenticated with>
5757
```
5858

59-
4) Then in a separate terminal, run the app locally:
59+
4. Then in a separate terminal, run the app locally:
6060

6161
```shell
6262
npm run dev
6363
```
6464

65-
5) Open your browser and go to `localhost:3000` to view the app.
65+
5. Open your browser and go to `localhost:3000` to view the app.
66+
67+
### Running templates and webauth projects locally
68+
69+
Read more in the [README.md](./local/README.md).
6670

6771
### Other commands
6872

@@ -91,3 +95,4 @@ module "amp_branch" {
9195
source = "git::https://github.com/NHSDigital/nhs-notify-shared-modules.git//infrastructure/modules/amp_branch?ref=v1.0.0"
9296
...
9397
}
98+
```

local/.env.template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
TEMPLATE_MANAGEMENT_DIR='your directory path to nhs-notify-web-template-management'
2+
AUTH_DIR='your directory path to nhs-notify-web-iam'

local/README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Experimental: Local setup for both templates-ui and iam-auth applications
2+
3+
This has only been tried on a mac.
4+
5+
If this local setup proves useful for others it would be great to move this `/local` directory to it's own github repo.
6+
7+
## Description
8+
9+
A docker-compose setup to run multiple web applications locally and served to the same domain: `localhost`.
10+
11+
Two web applications have been configured `nhs-notify-web-templates-management` and `nhs-notify-iam-webauth` are both served through `ngix` which acts as a gateway.
12+
13+
- `nhs-notify-web-templates-management` is served to `http://localhost/templates`
14+
- `nhs-notify-iam-webauth` is served to `http://localhost/auth`
15+
16+
The `docker-compose` file is hooked up to local volume of the projects so any changes you make in your webapps will be ported across, you will need to refresh the web page to see the changes.
17+
18+
### Additional information
19+
20+
At first the application may take a few seconds to warm up. After the app has warmed up it's usually just as fast as running the application natively.
21+
22+
If you install a new `npm` package in either webapp then you'll need to rebuild the docker images.
23+
24+
## Requirements
25+
26+
- local version of `nhs-notify-iam-webauth` project
27+
- docker-compose
28+
- If you're on windows you'll need to configure docker to work through WSL2 [here is a guide that might help](https://docs.docker.com/desktop/features/wsl/)
29+
30+
## Setup
31+
32+
### Setup Amplify sandboxes
33+
34+
Setup the Amplify sandboxes in a new terminal as explained in each web-apps [README.md](../README.md#running-the-project-locally)
35+
36+
### Configure project paths
37+
38+
You'll need to set the directory path location for each web application in the `.env` file or as environment variables.
39+
40+
For example:
41+
42+
```bash
43+
TEMPLATE_MANAGEMENT_DIR='~/projects/nhs-notify-web-template-management'
44+
IAM_WEBAUTH_DIR='~/projects/nhs-notify-iam-webauth'
45+
```
46+
47+
If you're using the `.env` file you might need to run `direnv allow`.
48+
49+
### Run
50+
51+
in the `/local/` directory run:
52+
53+
```bash
54+
docker-compose up
55+
```
56+
57+
First time running this it might take some time as `docker` downloads the base images and configures itself. After subsequent uses it will be much faster to start and stop.

local/docker-compose.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
services:
2+
nginx:
3+
image: nginx:latest
4+
ports:
5+
- 80:80
6+
volumes:
7+
- ./nginx.conf:/etc/nginx/nginx.conf:ro
8+
stdin_open: true
9+
tty: true
10+
depends_on:
11+
- templates
12+
- auth
13+
14+
templates:
15+
build:
16+
context: ${TEMPLATE_MANAGEMENT_DIR}
17+
dockerfile: Dockerfile
18+
ports:
19+
- 3000
20+
volumes:
21+
- ${TEMPLATE_MANAGEMENT_DIR}:/app
22+
- /app/node_modules
23+
24+
auth:
25+
build:
26+
context: ${IAM_WEBAUTH_DIR}
27+
dockerfile: Dockerfile
28+
ports:
29+
- 3000
30+
volumes:
31+
- ${IAM_WEBAUTH_DIR}:/app
32+
- /app/node_modules

local/nginx.conf

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
events {
2+
worker_connections 1024;
3+
}
4+
5+
http {
6+
upstream auth {
7+
server auth:3000;
8+
}
9+
10+
upstream templates {
11+
server templates:3000;
12+
}
13+
14+
server {
15+
listen 80;
16+
17+
location /auth {
18+
proxy_pass http://auth/auth;
19+
proxy_set_header Host $host;
20+
proxy_set_header X-Real-IP $remote_addr;
21+
}
22+
23+
location /templates {
24+
proxy_pass http://templates/templates;
25+
proxy_set_header Host $host;
26+
proxy_set_header X-Real-IP $remote_addr;
27+
}
28+
}
29+
}

src/components/molecules/Header/Header.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,12 @@ export function NHSNotifyHeader({ className, dataTestId }: HeaderType) {
5757
{/* I am currently testing the link wrapper, this will change later when we implement auth as the link will change based on auth state */}
5858
{process.env.NEXT_PUBLIC_DISABLE_CONTENT === 'true' ? null : (
5959
<div className='nhsuk-account__login' data-testid='login-link'>
60-
<Link className='nhsuk-account__login--link' href='/'>
61-
{content.components.headerComponent.links.logIn}
62-
</Link>
60+
<a
61+
className='nhsuk-account__login--link'
62+
href={content.components.headerComponent.links.logIn.href}
63+
>
64+
{content.components.headerComponent.links.logIn.text}
65+
</a>
6366
</div>
6467
)}
6568
</div>

src/content/content.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ import { TemplateType } from '@utils/types';
44
const headerComponent = {
55
serviceName: 'Notify',
66
links: {
7-
logIn: 'Log in',
7+
logIn: {
8+
text: 'Log in',
9+
href: `/auth?redirect=${encodeURIComponent(
10+
`${getBasePath()}/create-and-submit-templates`
11+
)}`,
12+
},
813
logOut: 'Log out',
914
},
1015
};

0 commit comments

Comments
 (0)