Skip to content

Commit cb35534

Browse files
CCM-18536 adding localised devcontainer build (#248)
* CCM-18536 adding localised devcontainer build * CCM-18536 adding localised devcontainer build * CCM-18536 adding localised devcontainer build * CCM-18536 adding localised devcontainer build * CCM-18536 adding localised devcontainer build * CCM-18536 adding localised devcontainer build
1 parent 9a2d743 commit cb35534

13 files changed

Lines changed: 324 additions & 3 deletions

File tree

‎.devcontainer/devcontainer.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
}
5757
},
5858
"forwardPorts": [4000],
59-
"image": "ghcr.io/nhsdigital/nhs-notify-template-repository:latest",
59+
"image": "ghcr.io/nhsdigital/nhs-notify-web-cms:latest",
6060
"name": "Jekyll",
6161
"runArgs": ["--platform=linux/amd64"]
6262
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: "Build and publish devcontainer"
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- gem.lock
9+
- docs/Gemfile.lock
10+
- src/jekyll-devcontainer/**
11+
workflow_dispatch:
12+
13+
permissions:
14+
contents: read
15+
packages: write
16+
17+
jobs:
18+
build-and-publish:
19+
name: "Build and publish Jekyll devcontainer"
20+
runs-on: ubuntu-latest
21+
timeout-minutes: 30
22+
env:
23+
BUILD_TARGET: devcontainer
24+
DEVCONTAINER_IMAGE: ghcr.io/nhsdigital/nhs-notify-web-cms
25+
steps:
26+
- name: "Checkout code"
27+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
28+
29+
- name: "Set up Node.js"
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: "22"
33+
34+
- name: "Log in to GitHub Container Registry"
35+
run: |
36+
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
37+
38+
- name: "Build devcontainer image"
39+
run: |
40+
make build
41+
42+
- name: "Publish devcontainer image"
43+
run: |
44+
make publish

‎Makefile‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,26 @@ include scripts/init.mk
77

88
# Example CI/CD targets are: dependencies, build, publish, deploy, clean, etc.
99

10+
DEVCONTAINER_DIR ?= src/jekyll-devcontainer
11+
DEVCONTAINER_IMAGE ?= ghcr.io/nhsdigital/nhs-notify-web-cms
12+
1013
dependencies: # Install dependencies needed to build and test the project @Pipeline
1114
# TODO: Implement installation of your project dependencies
1215

1316
build: # Build the project artefact @Pipeline
14-
(cd docs && make build)
17+
if [[ "$${BUILD_TARGET:-all}" != "devcontainer" ]]; then
18+
(cd docs && make build)
19+
fi
20+
make build-devcontainer
1521

1622
publish: # Publish the project artefact @Pipeline
17-
# TODO: Implement the artefact publishing step
23+
make publish-devcontainer
24+
25+
build-devcontainer: # Build the devcontainer image @Pipeline
26+
make -C ${DEVCONTAINER_DIR} build IMAGE=${DEVCONTAINER_IMAGE}
27+
28+
publish-devcontainer: # Publish the devcontainer image @Pipeline
29+
make -C ${DEVCONTAINER_DIR} publish IMAGE=${DEVCONTAINER_IMAGE}
1830

1931
deploy: # Deploy the project artefact to the target environment @Pipeline
2032
# TODO: Implement the artefact deployment step
@@ -34,7 +46,10 @@ version:
3446

3547
${VERBOSE}.SILENT: \
3648
build \
49+
build-devcontainer \
3750
clean \
3851
config \
3952
dependencies \
4053
deploy \
54+
publish \
55+
publish-devcontainer \

‎src/jekyll-devcontainer/Makefile‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
IMAGE ?= ghcr.io/nhsdigital/nhs-notify-web-cms
2+
3+
build:
4+
$(MAKE) -C ../../ version
5+
ver=$$(head -n 1 ../../.version 2> /dev/null || echo unknown); \
6+
verb=$$(echo $$ver | sed 's/+.*//'); \
7+
echo "version: $$verb"; \
8+
BUILDKIT_PROGRESS=plain npx --yes @devcontainers/cli build --workspace-folder ./src --image-name "${IMAGE}:$$verb"
9+
10+
publish:
11+
ver=$$(head -n 1 ../../.version 2> /dev/null || echo unknown); \
12+
verb=$$(echo $$ver | sed 's/+.*//'); \
13+
echo "version: $$verb"; \
14+
docker image tag ${IMAGE}:$$verb ${IMAGE}:latest; \
15+
docker push "${IMAGE}:$$verb"; \
16+
docker push "${IMAGE}:latest"
17+
18+
debug:
19+
npx --yes @devcontainers/cli up --workspace-folder ./src
20+
npx --yes @devcontainers/cli exec --workspace-folder ./src ls -la ./.devcontainer
21+
npx --yes @devcontainers/cli exec --workspace-folder ./src cat ./.devcontainer/packages.txt
22+
npx --yes @devcontainers/cli exec --workspace-folder ./src ./.devcontainer/check.sh

‎src/jekyll-devcontainer/README.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Publishing
2+
3+
To publish, create a classic token and run `docker login` before `make publish`.
4+
5+
Docker login:
6+
7+
```bash
8+
export CR_PAT=YOUR_TOKEN
9+
echo "$CR_PAT" | docker login ghcr.io -u USERNAME --password-stdin
10+
```
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM --platform=linux/amd64 mcr.microsoft.com/devcontainers/jekyll:3.4-bookworm
2+
LABEL org.opencontainers.image.source=https://github.com/NHSDigital/nhs-notify-web-cms
3+
4+
COPY packages.txt packages.txt
5+
6+
RUN apt-get update && DEBIAN_FRONTEND=noninteractive xargs apt-get -yq install < packages.txt
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#! /bin/zsh
2+
3+
cd ./.devcontainer
4+
cat packages.txt
5+
apt-get -s install < packages.txt
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"features": {
3+
"ghcr.io/devcontainers/features/aws-cli:1": {
4+
"version": "1.1.4",
5+
"resolved": "ghcr.io/devcontainers/features/aws-cli@sha256:1f93c8315b7a6d76982ebb2269f8b0d50413fc0f965c032edf4aee0caceb73ef",
6+
"integrity": "sha256:1f93c8315b7a6d76982ebb2269f8b0d50413fc0f965c032edf4aee0caceb73ef"
7+
},
8+
"ghcr.io/devcontainers/features/common-utils:2": {
9+
"version": "2.5.9",
10+
"resolved": "ghcr.io/devcontainers/features/common-utils@sha256:cb0c4d3c276f157eed17935747e364178d75fee17f55c4e129966f64633deb3a",
11+
"integrity": "sha256:cb0c4d3c276f157eed17935747e364178d75fee17f55c4e129966f64633deb3a"
12+
},
13+
"ghcr.io/devcontainers/features/docker-in-docker:2": {
14+
"version": "2.17.0",
15+
"resolved": "ghcr.io/devcontainers/features/docker-in-docker@sha256:25b9f05705ffba7dbe503230ac76081419306f8c8bc88e0ce78c4ecd99a0c78c",
16+
"integrity": "sha256:25b9f05705ffba7dbe503230ac76081419306f8c8bc88e0ce78c4ecd99a0c78c"
17+
},
18+
"ghcr.io/devcontainers/features/github-cli:1": {
19+
"version": "1.1.0",
20+
"resolved": "ghcr.io/devcontainers/features/github-cli@sha256:d22f50b70ed75339b4eed1ba9ecde3a1791f90e88d37936517e3bace0bbad671",
21+
"integrity": "sha256:d22f50b70ed75339b4eed1ba9ecde3a1791f90e88d37936517e3bace0bbad671"
22+
},
23+
"ghcr.io/devcontainers/features/node:1": {
24+
"version": "1.7.1",
25+
"resolved": "ghcr.io/devcontainers/features/node@sha256:8c0de46939b61958041700ee89e3493f3b2e4131a06dc46b4d9423427d06e5f6",
26+
"integrity": "sha256:8c0de46939b61958041700ee89e3493f3b2e4131a06dc46b4d9423427d06e5f6"
27+
}
28+
}
29+
}
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
{
2+
"build": {
3+
"dockerfile": "Dockerfile"
4+
},
5+
"customizations": {
6+
"codespaces": {
7+
"openFiles": [
8+
"README.md",
9+
".github/SECURITY.md",
10+
"docs/pages/index.md"
11+
]
12+
},
13+
"vscode": {
14+
"extensions": [
15+
"alefragnani.bookmarks",
16+
"AmazonWebServices.aws-toolkit-vscode",
17+
"chdsbd.github-code-owners",
18+
"davidanson.vscode-markdownlint",
19+
"dbaeumer.vscode-eslint",
20+
"donjayamanne.githistory",
21+
"editorconfig.editorconfig",
22+
"esbenp.prettier-vscode",
23+
"fvclaus.sort-json-array",
24+
"github.codespaces",
25+
"github.github-vscode-theme",
26+
"github.remotehub",
27+
"github.vscode-github-actions",
28+
"github.vscode-pull-request-github",
29+
"hediet.vscode-drawio",
30+
"johnpapa.vscode-peacock",
31+
"joshx.workspace-terminals",
32+
"maattdd.gitless",
33+
"mhutchie.git-graph",
34+
"ms-azuretools.vscode-docker",
35+
"ms-vscode-remote.remote-containers",
36+
"ms-vscode-remote.remote-wsl",
37+
"ms-vscode.hexeditor",
38+
"ms-vscode.live-server",
39+
"ms-vsliveshare.vsliveshare",
40+
"redhat.vscode-xml",
41+
"streetsidesoftware.code-spell-checker-british-english",
42+
"takumii.markdowntable",
43+
"tamasfe.even-better-toml",
44+
"tomoki1207.pdf",
45+
"vscode-icons-team.vscode-icons",
46+
"vstirbu.vscode-mermaid-preview",
47+
"wayou.vscode-todo-highlight",
48+
"yzane.markdown-pdf",
49+
"yzhang.dictionary-completion",
50+
"yzhang.markdown-all-in-one",
51+
"zoma.vscode-auto-open-workspace"
52+
],
53+
"settings": {
54+
"[makefile]": {
55+
"editor.detectIndentation": false,
56+
"editor.insertSpaces": false
57+
},
58+
"autoOpenWorkspace.enableAutoOpenIfSingleWorkspace": true,
59+
"editor.formatOnSave": true,
60+
"extensions.ignoreRecommendations": true,
61+
"files.insertFinalNewline": true
62+
}
63+
}
64+
},
65+
"features": {
66+
"./nhsnotify": {
67+
"version": "1.0.1"
68+
},
69+
"ghcr.io/devcontainers/features/aws-cli:1": {
70+
"version": "latest"
71+
},
72+
"ghcr.io/devcontainers/features/common-utils:2": {
73+
"configureZshAsDefaultShell": true,
74+
"installOhMyZsh": true,
75+
"installOhMyZshConfig": true,
76+
"installZsh": true,
77+
"upgradePackages": true,
78+
"userGid": "automatic",
79+
"userUid": "automatic",
80+
"username": "automatic"
81+
},
82+
"ghcr.io/devcontainers/features/docker-in-docker:2": {
83+
"azureDnsAutoDetection": true,
84+
"dockerDashComposeVersion": "latest",
85+
"installDockerBuildx": true,
86+
"installDockerComposeSwitch": true,
87+
"moby": true,
88+
"version": "latest"
89+
},
90+
"ghcr.io/devcontainers/features/github-cli:1": {
91+
"installDirectlyFromGitHubRelease": true,
92+
"version": "latest"
93+
},
94+
"ghcr.io/devcontainers/features/node:1": {
95+
"nodeGypDependencies": true,
96+
"nvmVersion": "latest",
97+
"version": "lts"
98+
}
99+
},
100+
"forwardPorts": [
101+
4000
102+
],
103+
"name": "NHS Notify Web CMS Dev Container",
104+
"runArgs": [
105+
"--platform=linux/amd64"
106+
]
107+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"dependsOn": {
3+
"ghcr.io/devcontainers/features/common-utils:2": {
4+
"installOhMyZsh": true
5+
}
6+
},
7+
"id": "nhsnotify",
8+
"name": "Notify Custom",
9+
"postCreateCommand": "zsh /postcreatecommand.sh",
10+
"version": "1.0.1"
11+
}

0 commit comments

Comments
 (0)