From a458b198c317585321811aab6ff77f4485ca8d66 Mon Sep 17 00:00:00 2001 From: Ross Buggins Date: Wed, 3 Jul 2024 11:36:54 +0100 Subject: [PATCH 1/4] Adding prebuild container. --- .devcontainer/devcontainer.json | 3 +++ nhs-notify-repository-template.code-workspace | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 0d24b16..1c02988 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -12,12 +12,15 @@ }, "vscode": { "extensions": [ + "AmazonWebServices.aws-toolkit-vscode", "alefragnani.bookmarks", + "chdsbd.github-code-owners", "davidanson.vscode-markdownlint", "dbaeumer.vscode-eslint", "donjayamanne.githistory", "editorconfig.editorconfig", "esbenp.prettier-vscode", + "fvclaus.sort-json-array", "github.codespaces", "github.github-vscode-theme", "github.remotehub", diff --git a/nhs-notify-repository-template.code-workspace b/nhs-notify-repository-template.code-workspace index 1d6f990..ffbdb71 100644 --- a/nhs-notify-repository-template.code-workspace +++ b/nhs-notify-repository-template.code-workspace @@ -84,7 +84,9 @@ "[json]": { "editor.wordWrap": "off", "editor.defaultFormatter": "esbenp.prettier-vscode" - } + }, + "window.title": "${separator}${activeRepositoryName}${separator}${activeRepositoryBranchName}${separator}[${remoteName}]", + "window.titleSeparator": " : " }, "extensions": { "recommendations": [ From 63485b32bd2e66512ace737e88b5fbfc15ba95d9 Mon Sep 17 00:00:00 2001 From: Ross Buggins Date: Wed, 3 Jul 2024 17:01:26 +0100 Subject: [PATCH 2/4] Added prebuilt dev container --- .devcontainer/Dockerfile | 1 - .devcontainer/devcontainer.json | 38 +------ src/Makefile | 3 - src/jekyll-devcontainer/Makefile | 19 ++++ src/jekyll-devcontainer/README.md | 10 ++ .../src/.devcontainer/Dockerfile | 2 + .../src/.devcontainer/devcontainer.json | 105 ++++++++++++++++++ .../nhsnotify/devcontainer-feature.json | 11 ++ .../src/.devcontainer/nhsnotify/install.sh | 18 +++ .../nhsnotify/postcreatecommand.sh | 15 +++ 10 files changed, 181 insertions(+), 41 deletions(-) delete mode 100644 .devcontainer/Dockerfile delete mode 100644 src/Makefile create mode 100644 src/jekyll-devcontainer/Makefile create mode 100644 src/jekyll-devcontainer/README.md create mode 100644 src/jekyll-devcontainer/src/.devcontainer/Dockerfile create mode 100644 src/jekyll-devcontainer/src/.devcontainer/devcontainer.json create mode 100644 src/jekyll-devcontainer/src/.devcontainer/nhsnotify/devcontainer-feature.json create mode 100755 src/jekyll-devcontainer/src/.devcontainer/nhsnotify/install.sh create mode 100755 src/jekyll-devcontainer/src/.devcontainer/nhsnotify/postcreatecommand.sh diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index dc38297..0000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1 +0,0 @@ -FROM --platform=linux/amd64 mcr.microsoft.com/devcontainers/jekyll:2-bullseye diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 1c02988..5888926 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,7 +1,4 @@ { - "build": { - "dockerfile": "Dockerfile" - }, "customizations": { "codespaces": { "openFiles": [ @@ -62,44 +59,11 @@ } } }, - "features": { - "ghcr.io/devcontainers/features/aws-cli:1": { - "version": "latest" - }, - "ghcr.io/devcontainers/features/common-utils:2": { - "configureZshAsDefaultShell": true, - "installOhMyZsh": true, - "installOhMyZshConfig": true, - "installZsh": true, - "upgradePackages": true, - "userGid": "automatic", - "userUid": "automatic", - "username": "automatic" - }, - "ghcr.io/devcontainers/features/docker-in-docker:2": { - "azureDnsAutoDetection": true, - "dockerDashComposeVersion": "latest", - "installDockerBuildx": true, - "installDockerComposeSwitch": true, - "moby": true, - "version": "latest" - }, - "ghcr.io/devcontainers/features/github-cli:1": { - "installDirectlyFromGitHubRelease": true, - "version": "latest" - }, - "ghcr.io/devcontainers/features/node:1": { - "nodeGypDependencies": true, - "nvmVersion": "latest", - "version": "lts" - } - }, "forwardPorts": [ 4000 ], + "image": "ghcr.io/nhsdigital/nhs-notify-template-repository:latest", "name": "Jekyll", - "postCreateCommand": "zsh scripts/devcontainer/postcreatecommand.sh", - "postStartCommand": "zsh scripts/devcontainer/poststartcommand.sh", "runArgs": [ "--platform=linux/amd64" ] diff --git a/src/Makefile b/src/Makefile deleted file mode 100644 index ccfdd5c..0000000 --- a/src/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -build: - -publish: diff --git a/src/jekyll-devcontainer/Makefile b/src/jekyll-devcontainer/Makefile new file mode 100644 index 0000000..f295ce0 --- /dev/null +++ b/src/jekyll-devcontainer/Makefile @@ -0,0 +1,19 @@ +build: + make -C ../../ Makefile version + npm install -g @devcontainers/cli + ver=$$(head -n 1 ../../.version 2> /dev/null || echo unknown); \ + verb=$$(echo $$ver | sed 's/\+.*//'); \ + echo "version: $$verb"; \ + BUILDKIT_PROGRESS=plain devcontainer build --workspace-folder ./src --image-name "ghcr.io/nhsdigital/nhs-notify-template-repository:$$verb" + +publish: + ver=$$(head -n 1 ../../.version 2> /dev/null || echo unknown); \ + verb=$$(echo $$ver | sed 's/\+.*//'); \ + echo "version: $$verb"; \ + docker image tag ghcr.io/nhsdigital/nhs-notify-template-repository:$$verb ghcr.io/nhsdigital/nhs-notify-template-repository:latest; \ + docker push "ghcr.io/nhsdigital/nhs-notify-template-repository:$$verb"; \ + docker push "ghcr.io/nhsdigital/nhs-notify-template-repository:latest" + +debug: + devcontainer up --workspace-folder ./src + devcontainer exec --workspace-folder ./src ls -la diff --git a/src/jekyll-devcontainer/README.md b/src/jekyll-devcontainer/README.md new file mode 100644 index 0000000..99b63a3 --- /dev/null +++ b/src/jekyll-devcontainer/README.md @@ -0,0 +1,10 @@ +# Publishing + +To publish, create classic and docker login before `make publish` + +Docker login: + +```bash +export CR_PAT=YOUR_TOKEN +echo $CR_PAT | docker login ghcr.io -u USERNAME --password-stdin +``` diff --git a/src/jekyll-devcontainer/src/.devcontainer/Dockerfile b/src/jekyll-devcontainer/src/.devcontainer/Dockerfile new file mode 100644 index 0000000..17fd968 --- /dev/null +++ b/src/jekyll-devcontainer/src/.devcontainer/Dockerfile @@ -0,0 +1,2 @@ +FROM --platform=linux/amd64 mcr.microsoft.com/devcontainers/jekyll:2-bullseye +LABEL org.opencontainers.image.source=https://github.com/NHSDigital/nhs-notify-repository-template diff --git a/src/jekyll-devcontainer/src/.devcontainer/devcontainer.json b/src/jekyll-devcontainer/src/.devcontainer/devcontainer.json new file mode 100644 index 0000000..a93bb39 --- /dev/null +++ b/src/jekyll-devcontainer/src/.devcontainer/devcontainer.json @@ -0,0 +1,105 @@ +{ + "build": { + "dockerfile": "Dockerfile" + }, + "customizations": { + "codespaces": { + "openFiles": [ + "README.md", + ".github/SECURITY.md", + "docs/index.md" + ] + }, + "vscode": { + "extensions": [ + "AmazonWebServices.aws-toolkit-vscode", + "alefragnani.bookmarks", + "chdsbd.github-code-owners", + "davidanson.vscode-markdownlint", + "dbaeumer.vscode-eslint", + "donjayamanne.githistory", + "editorconfig.editorconfig", + "esbenp.prettier-vscode", + "fvclaus.sort-json-array", + "github.codespaces", + "github.github-vscode-theme", + "github.remotehub", + "github.vscode-github-actions", + "github.vscode-pull-request-github", + "hediet.vscode-drawio", + "johnpapa.vscode-peacock", + "joshx.workspace-terminals", + "maattdd.gitless", + "mhutchie.git-graph", + "ms-azuretools.vscode-docker", + "ms-vscode-remote.remote-containers", + "ms-vscode-remote.remote-wsl", + "ms-vscode.hexeditor", + "ms-vscode.live-server", + "ms-vsliveshare.vsliveshare", + "redhat.vscode-xml", + "streetsidesoftware.code-spell-checker-british-english", + "takumii.markdowntable", + "tamasfe.even-better-toml", + "tomoki1207.pdf", + "vscode-icons-team.vscode-icons", + "vstirbu.vscode-mermaid-preview", + "wayou.vscode-todo-highlight", + "yzane.markdown-pdf", + "yzhang.dictionary-completion", + "yzhang.markdown-all-in-one", + "zoma.vscode-auto-open-workspace" + ], + "settings": { + "[makefile]": { + "editor.detectIndentation": false, + "editor.insertSpaces": false + }, + "autoOpenWorkspace.enableAutoOpenIfSingleWorkspace": true, + "editor.formatOnSave": true, + "extensions.ignoreRecommendations": true, + "files.insertFinalNewline": true + } + } + }, + "features": { + "./nhsnotify": {}, + "ghcr.io/devcontainers/features/aws-cli:1": { + "version": "latest" + }, + "ghcr.io/devcontainers/features/common-utils:2": { + "configureZshAsDefaultShell": true, + "installOhMyZsh": true, + "installOhMyZshConfig": true, + "installZsh": true, + "upgradePackages": true, + "userGid": "automatic", + "userUid": "automatic", + "username": "automatic" + }, + "ghcr.io/devcontainers/features/docker-in-docker:2": { + "azureDnsAutoDetection": true, + "dockerDashComposeVersion": "latest", + "installDockerBuildx": true, + "installDockerComposeSwitch": true, + "moby": true, + "version": "latest" + }, + "ghcr.io/devcontainers/features/github-cli:1": { + "installDirectlyFromGitHubRelease": true, + "version": "latest" + }, + "ghcr.io/devcontainers/features/node:1": { + "nodeGypDependencies": true, + "nvmVersion": "latest", + "version": "lts" + } + }, + "forwardPorts": [ + 4000 + ], + "name": "NHS Notify Default Dev Container", + "runArgs": [ + "--platform=linux/amd64" + ] +} diff --git a/src/jekyll-devcontainer/src/.devcontainer/nhsnotify/devcontainer-feature.json b/src/jekyll-devcontainer/src/.devcontainer/nhsnotify/devcontainer-feature.json new file mode 100644 index 0000000..f79300c --- /dev/null +++ b/src/jekyll-devcontainer/src/.devcontainer/nhsnotify/devcontainer-feature.json @@ -0,0 +1,11 @@ +{ + "dependsOn": { + "ghcr.io/devcontainers/features/common-utils:2": { + "installOhMyZsh": true + } + }, + "id": "nhsnotify", + "name": "Notify Custom", + "postCreateCommand": "zsh /postcreatecommand.sh", + "version": "1.0.0" +} diff --git a/src/jekyll-devcontainer/src/.devcontainer/nhsnotify/install.sh b/src/jekyll-devcontainer/src/.devcontainer/nhsnotify/install.sh new file mode 100755 index 0000000..56f481a --- /dev/null +++ b/src/jekyll-devcontainer/src/.devcontainer/nhsnotify/install.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +cp ./postcreatecommand.sh /postcreatecommand.sh + +cp ~/.zshrc /.zshrc +rm -Rf /.asdf +git clone https://github.com/asdf-vm/asdf.git /.asdf; +chmod +x /.asdf/asdf.sh; +echo '. /.asdf/asdf.sh' >> /.zshrc +echo '. /.asdf/completions/asdf.bash' >> /.zshrc +sed -i "/plugins=/c\plugins=(git ssh-agent sudo terraform dirhistory zsh-autosuggestions)" /.zshrc + +cat /.zshrc + +cp /.zshrc ~/.zshrc +source ~/.zshrc +mkdir -p /zsh/plugins/zsh-autosuggestions +git clone https://github.com/zsh-users/zsh-autosuggestions /zsh/plugins/zsh-autosuggestions diff --git a/src/jekyll-devcontainer/src/.devcontainer/nhsnotify/postcreatecommand.sh b/src/jekyll-devcontainer/src/.devcontainer/nhsnotify/postcreatecommand.sh new file mode 100755 index 0000000..a844efd --- /dev/null +++ b/src/jekyll-devcontainer/src/.devcontainer/nhsnotify/postcreatecommand.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +cp /.zshrc ~/.zshrc +cp -r /zsh/* ${ZSH_CUSTOM:-~/.oh-my-zsh/custom} +ls -la ${ZSH_CUSTOM:-~/.oh-my-zsh/custom} + +cat ~/.zshrc +source ~/.zshrc +echo 'asdf setup complete' + +make config +echo 'make config complete' + +jekyll --version && cd docs && bundle install +echo 'jekyll setup complete' From 01e4791aaa30df3214022fcff32d2831b157f097 Mon Sep 17 00:00:00 2001 From: Ross Buggins Date: Wed, 3 Jul 2024 08:42:22 +0100 Subject: [PATCH 3/4] Import from HW. --- nhs-notify-repository-template.code-workspace | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nhs-notify-repository-template.code-workspace b/nhs-notify-repository-template.code-workspace index 1d6f990..9668adb 100644 --- a/nhs-notify-repository-template.code-workspace +++ b/nhs-notify-repository-template.code-workspace @@ -12,6 +12,10 @@ "name": "Docs", "path": "./docs" }, + { + "name": "Application Source Code", + "path": "./src" + }, { "name": "Tests", "path": "./tests" From ff2b5a3105907247a7f0c9a734b151e746f329f9 Mon Sep 17 00:00:00 2001 From: Ross Buggins Date: Wed, 3 Jul 2024 17:13:37 +0100 Subject: [PATCH 4/4] Added prebuilt dev container --- .devcontainer/devcontainer.json | 2 +- nhs-notify-repository-template.code-workspace | 81 +++++++++---------- .../src/.devcontainer/devcontainer.json | 2 +- 3 files changed, 41 insertions(+), 44 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 5888926..c4ebb00 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -9,8 +9,8 @@ }, "vscode": { "extensions": [ - "AmazonWebServices.aws-toolkit-vscode", "alefragnani.bookmarks", + "AmazonWebServices.aws-toolkit-vscode", "chdsbd.github-code-owners", "davidanson.vscode-markdownlint", "dbaeumer.vscode-eslint", diff --git a/nhs-notify-repository-template.code-workspace b/nhs-notify-repository-template.code-workspace index 45db74e..a52565d 100644 --- a/nhs-notify-repository-template.code-workspace +++ b/nhs-notify-repository-template.code-workspace @@ -12,10 +12,6 @@ "name": "Docs", "path": "./docs" }, - { - "name": "Application Source Code", - "path": "./src" - }, { "name": "Tests", "path": "./tests" @@ -39,10 +35,9 @@ { "name": "Dev Container", "path": ".devcontainer" - }, + } ], "settings": { - "autoOpenWorkspace.enableAutoOpenIfSingleWorkspace": true, "githubCodeOwners.format.enabled": true, "workspace-terminals.switchTerminal": "always", @@ -94,42 +89,44 @@ }, "extensions": { "recommendations": [ - "zoma.vscode-auto-open-workspace", - "alefragnani.bookmarks", - "davidanson.vscode-markdownlint", - "dbaeumer.vscode-eslint", - "donjayamanne.githistory", - "eamodio.gitlens", - "editorconfig.editorconfig", - "esbenp.prettier-vscode", - "github.codespaces", - "github.github-vscode-theme", - "github.remotehub", - "github.vscode-github-actions", - "github.vscode-pull-request-github", - "hediet.vscode-drawio", - "johnpapa.vscode-peacock", - "mhutchie.git-graph", - "ms-azuretools.vscode-docker", - "ms-vscode-remote.remote-containers", - "ms-vscode-remote.remote-wsl", - "ms-vscode.hexeditor", - "ms-vscode.live-server", - "ms-vsliveshare.vsliveshare", - "redhat.vscode-xml", - "streetsidesoftware.code-spell-checker-british-english", - "tamasfe.even-better-toml", - "tomoki1207.pdf", - "vscode-icons-team.vscode-icons", - "vstirbu.vscode-mermaid-preview", - "wayou.vscode-todo-highlight", - "yzane.markdown-pdf", - "yzhang.dictionary-completion", - "yzhang.markdown-all-in-one", - "joshx.workspace-terminals", - "takumii.markdowntable", - "chdsbd.github-code-owners" - ], + "alefragnani.bookmarks", + "AmazonWebServices.aws-toolkit-vscode", + "chdsbd.github-code-owners", + "davidanson.vscode-markdownlint", + "dbaeumer.vscode-eslint", + "donjayamanne.githistory", + "editorconfig.editorconfig", + "esbenp.prettier-vscode", + "fvclaus.sort-json-array", + "github.codespaces", + "github.github-vscode-theme", + "github.remotehub", + "github.vscode-github-actions", + "github.vscode-pull-request-github", + "hediet.vscode-drawio", + "johnpapa.vscode-peacock", + "joshx.workspace-terminals", + "maattdd.gitless", + "mhutchie.git-graph", + "ms-azuretools.vscode-docker", + "ms-vscode-remote.remote-containers", + "ms-vscode-remote.remote-wsl", + "ms-vscode.hexeditor", + "ms-vscode.live-server", + "ms-vsliveshare.vsliveshare", + "redhat.vscode-xml", + "streetsidesoftware.code-spell-checker-british-english", + "takumii.markdowntable", + "tamasfe.even-better-toml", + "tomoki1207.pdf", + "vscode-icons-team.vscode-icons", + "vstirbu.vscode-mermaid-preview", + "wayou.vscode-todo-highlight", + "yzane.markdown-pdf", + "yzhang.dictionary-completion", + "yzhang.markdown-all-in-one", + "zoma.vscode-auto-open-workspace" +], "unwantedRecommendations": [] } } diff --git a/src/jekyll-devcontainer/src/.devcontainer/devcontainer.json b/src/jekyll-devcontainer/src/.devcontainer/devcontainer.json index a93bb39..26d7357 100644 --- a/src/jekyll-devcontainer/src/.devcontainer/devcontainer.json +++ b/src/jekyll-devcontainer/src/.devcontainer/devcontainer.json @@ -12,8 +12,8 @@ }, "vscode": { "extensions": [ - "AmazonWebServices.aws-toolkit-vscode", "alefragnani.bookmarks", + "AmazonWebServices.aws-toolkit-vscode", "chdsbd.github-code-owners", "davidanson.vscode-markdownlint", "dbaeumer.vscode-eslint",