From 63485b32bd2e66512ace737e88b5fbfc15ba95d9 Mon Sep 17 00:00:00 2001 From: Ross Buggins Date: Wed, 3 Jul 2024 17:01:26 +0100 Subject: [PATCH] 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'