Skip to content

Commit 9349ec7

Browse files
authored
Merge branch 'main' into jlk/release-new-cricket-header-on-web
2 parents aa10231 + 44c1c48 commit 9349ec7

14 files changed

Lines changed: 2036 additions & 79 deletions

File tree

.github/workflows/cicd.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ on:
44
push:
55

66
jobs:
7-
container:
8-
permissions:
9-
packages: write
10-
uses: ./.github/workflows/container.yml
11-
127
production-container:
138
permissions:
149
contents: read
@@ -17,6 +12,14 @@ jobs:
1712
secrets:
1813
GU_RIFF_RAFF_ROLE_ARN: ${{ secrets.GU_RIFF_RAFF_ROLE_ARN }}
1914

15+
container:
16+
permissions:
17+
packages: write
18+
needs: [production-container]
19+
uses: ./.github/workflows/container.yml
20+
with:
21+
production-image-digest: ${{ needs.production-container.outputs.imageDigest }}
22+
2023
prettier:
2124
uses: ./.github/workflows/prettier.yml
2225

.github/workflows/container.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
# Commercial rely on a container image built from the main branch with the tag 'main'
33
on:
44
workflow_call:
5+
inputs:
6+
production-image-digest:
7+
description: 'Digest of image pushed to AWS ECR to run on AWS ECS. Gets used by `cdk synth`.'
8+
required: true
9+
type: string
510
outputs:
611
container-image:
712
description: 'The generated container image path'
@@ -30,6 +35,8 @@ jobs:
3035
echo 'export const GIT_COMMIT_HASH = "${{ github.sha }}";' > src/server/prout.ts
3136
3237
- name: Generate production bundle
38+
env:
39+
IMAGE_DIGEST: ${{ inputs.production-image-digest }}
3340
run: make riffraff-bundle
3441
working-directory: dotcom-rendering
3542

docker-compose.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# A Docker Compose file for running the production build locally.
2+
# Usage:
3+
# docker compose up -d --build --force-recreate
4+
services:
5+
tag-page-rendering:
6+
build:
7+
dockerfile: ./Production.dockerfile
8+
environment:
9+
NODE_ENV: production
10+
GU_STAGE: PROD
11+
GU_APP: tag-page-rendering
12+
GU_STACK: frontend
13+
14+
# We configure Log4JS based on this environment variable. See `server/lib/logging.ts`.
15+
AWS_EXECUTION_ENV: AWS_ECS_LOCAL
16+
17+
# Explicitly tell AWS SDK where to find credentials
18+
AWS_SHARED_CREDENTIALS_FILE: /.aws/credentials
19+
ports:
20+
- '9000:9000'
21+
22+
# Share the host's AWS credentials with the container
23+
volumes:
24+
- ${HOME}/.aws/credentials:/.aws/credentials:ro
25+
26+
# In Production.dockerfile, we're deliberately using a minimal image that does not have `curl` installed.
27+
# Therefore, we're using Node to make a request to the healthcheck endpoint instead of using `curl`.
28+
healthcheck:
29+
test:
30+
[
31+
'CMD',
32+
'node',
33+
'-e',
34+
"fetch('http://localhost:9000/_healthcheck').then(_ => process.exit(0)).catch(_ => process.exit(1))",
35+
]
36+
interval: 10s
37+
timeout: 5s
38+
retries: 5
39+
40+
# This service is used to make a sample request to tag-page-rendering only after it has started and is healthy.
41+
# It exits immediately after making the request, so it is not a long-running service.
42+
# View the logs via:
43+
# docker logs "$(docker ps -aq --filter "name=sample-request" --latest)"
44+
# The log output is the DCR response, so we can also pipe it through `jq` to pretty-print it, e.g.:
45+
# docker logs "$(docker ps -aq --filter "name=sample-request" --latest)" | jq .
46+
sample-request:
47+
image: curlimages/curl:8.21.0
48+
depends_on:
49+
tag-page-rendering:
50+
condition: service_healthy
51+
command: |
52+
curl "https://www.theguardian.com/tone/minutebyminute.json?dcr=true" --silent > data.json && \
53+
curl -X POST http://localhost:9000/TagPage -d @data.json -H "Content-Type: application/json"

dotcom-rendering/Containerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@ EXPOSE 9000
1111

1212
ENV DISABLE_LOGGING_AND_METRICS=true
1313
ENV NODE_ENV=production
14-
ENV USE_LOCAL_ASSETS=true
1514

1615
ENTRYPOINT ["node", "article-rendering/dist/server.js"]

dotcom-rendering/cdk/bin/cdk.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { App } from 'aws-cdk-lib';
22
import { InstanceClass, InstanceSize, InstanceType } from 'aws-cdk-lib/aws-ec2';
3+
import type { RenderingCDKStackProps } from '../lib/renderingStack';
34
import { RenderingCDKStack } from '../lib/renderingStack';
45

56
const cdkApp = new App();
@@ -96,13 +97,21 @@ new RenderingCDKStack(cdkApp, 'FaciaRendering-PROD', {
9697
});
9798

9899
/** Tag pages */
99-
new RenderingCDKStack(cdkApp, 'TagPageRendering-CODE', {
100+
export const TagPageRenderingPropsCODE: RenderingCDKStackProps = {
100101
guApp: 'tag-page-rendering',
101102
stage: 'CODE',
102103
domainName: 'tag-page-rendering.code.dev-guardianapis.com',
103104
scaling: { minimumInstances: 1, maximumInstances: 3 },
104105
instanceType: InstanceType.of(InstanceClass.T4G, InstanceSize.SMALL),
105-
});
106+
imageIdentifier: process.env.IMAGE_DIGEST ?? 'DEV',
107+
};
108+
109+
new RenderingCDKStack(
110+
cdkApp,
111+
'TagPageRendering-CODE',
112+
TagPageRenderingPropsCODE,
113+
);
114+
106115
new RenderingCDKStack(cdkApp, 'TagPageRendering-PROD', {
107116
guApp: 'tag-page-rendering',
108117
stage: 'PROD',

0 commit comments

Comments
 (0)