Skip to content

Commit 8939513

Browse files
authored
Chore: [AEA-0000] - move to common devcontainer (#466)
## Summary - Routine Change ### Details - move to common dev container
1 parent 0a952cc commit 8939513

18 files changed

Lines changed: 319 additions & 1200 deletions

.devcontainer/Dockerfile

Lines changed: 13 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,15 @@
1-
FROM mcr.microsoft.com/devcontainers/base:ubuntu
2-
3-
ARG TARGETARCH
4-
ENV TARGETARCH=${TARGETARCH}
5-
6-
ARG ASDF_VERSION
7-
COPY .tool-versions.asdf /tmp/.tool-versions.asdf
8-
9-
# Add amd64 architecture if on arm64
10-
RUN if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" = "aarch64" ]; then dpkg --add-architecture amd64; fi
11-
12-
RUN apt-get update \
13-
&& export DEBIAN_FRONTEND=noninteractive \
14-
&& apt-get -y dist-upgrade \
15-
&& apt-get -y install --no-install-recommends htop vim curl git build-essential \
16-
libffi-dev libssl-dev libxml2-dev libxslt1-dev libjpeg8-dev libbz2-dev \
17-
zlib1g-dev unixodbc unixodbc-dev libsecret-1-0 libsecret-1-dev libsqlite3-dev \
18-
jq apt-transport-https ca-certificates gnupg-agent \
19-
software-properties-common bash-completion python3-pip make libbz2-dev \
20-
libreadline-dev libsqlite3-dev wget llvm libncurses5-dev libncursesw5-dev \
21-
xz-utils tk-dev liblzma-dev netcat-traditional ruby-full build-essential zlib1g-dev \
22-
&& apt remove -y openjdk-8-jdk-headless openjdk-8-jre-headless openjdk-8-jre
23-
24-
# Download correct AWS CLI for arch
25-
RUN if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" = "aarch64" ]; then \
26-
wget -O /tmp/awscliv2.zip "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip"; \
1+
ARG IMAGE_NAME=node_24_python_3_14_java_24
2+
ARG IMAGE_VERSION=latest
3+
FROM ghcr.io/nhsdigital/eps-devcontainers/${IMAGE_NAME}:${IMAGE_VERSION}
4+
5+
USER root
6+
# specify DOCKER_GID to force container docker group id to match host
7+
RUN if [ -n "${DOCKER_GID}" ]; then \
8+
if ! getent group docker; then \
9+
groupadd -g ${DOCKER_GID} docker; \
2710
else \
28-
wget -O /tmp/awscliv2.zip "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip"; \
11+
groupmod -g ${DOCKER_GID} docker; \
2912
fi && \
30-
unzip /tmp/awscliv2.zip -d /tmp/aws-cli && \
31-
/tmp/aws-cli/aws/install && \
32-
rm /tmp/awscliv2.zip && rm -rf /tmp/aws-cli
33-
34-
# Download correct SAM CLI for arch
35-
RUN if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" = "aarch64" ]; then \
36-
wget -O /tmp/aws-sam-cli.zip "https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-arm64.zip"; \
37-
else \
38-
wget -O /tmp/aws-sam-cli.zip "https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip"; \
39-
fi && \
40-
unzip /tmp/aws-sam-cli.zip -d /tmp/aws-sam-cli && \
41-
/tmp/aws-sam-cli/install && \
42-
rm /tmp/aws-sam-cli.zip && rm -rf /tmp/aws-sam-cli
43-
44-
# Install ASDF
45-
RUN ASDF_VERSION=$(awk '!/^#/ && NF {print $1; exit}' /tmp/.tool-versions.asdf) && \
46-
if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" = "aarch64" ]; then \
47-
wget -O /tmp/asdf.tar.gz https://github.com/asdf-vm/asdf/releases/download/v${ASDF_VERSION}/asdf-v${ASDF_VERSION}-linux-arm64.tar.gz; \
48-
else \
49-
wget -O /tmp/asdf.tar.gz https://github.com/asdf-vm/asdf/releases/download/v${ASDF_VERSION}/asdf-v${ASDF_VERSION}-linux-amd64.tar.gz; \
50-
fi && \
51-
tar -xvzf /tmp/asdf.tar.gz && \
52-
mv asdf /usr/bin
53-
54-
55-
USER vscode
56-
57-
ENV PATH="/home/vscode/.asdf/shims/:$PATH"
58-
RUN \
59-
echo 'PATH="/home/vscode/.asdf/shims/:$PATH"' >> ~/.bashrc; \
60-
echo '. <(asdf completion bash)' >> ~/.bashrc; \
61-
echo '# Install Ruby Gems to ~/gems' >> ~/.bashrc; \
62-
echo 'export GEM_HOME="$HOME/gems"' >> ~/.bashrc; \
63-
echo 'export PATH="$HOME/gems/bin:$PATH"' >> ~/.bashrc;
64-
65-
# Install ASDF plugins
66-
RUN asdf plugin add python && \
67-
asdf plugin add poetry https://github.com/asdf-community/asdf-poetry.git && \
68-
asdf plugin add shellcheck https://github.com/luizm/asdf-shellcheck.git && \
69-
asdf plugin add java && \
70-
asdf plugin add maven && \
71-
asdf plugin add direnv && \
72-
asdf plugin add actionlint && \
73-
asdf plugin add nodejs;
74-
75-
WORKDIR /workspaces/validation-service-fhir-r4
76-
ADD .tool-versions /workspaces/validation-service-fhir-r4/.tool-versions
77-
ADD .tool-versions /home/vscode/.tool-versions
78-
79-
RUN asdf install python && \
80-
asdf install
13+
usermod -aG docker vscode; \
14+
fi
15+

.devcontainer/devcontainer.json

Lines changed: 67 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,70 @@
1-
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2-
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
31
{
4-
"name": "Ubuntu",
5-
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6-
"build": {
7-
"dockerfile": "Dockerfile",
8-
"context": "..",
9-
"args": {}
10-
},
11-
"mounts": [
12-
"source=${env:HOME}${env:USERPROFILE}/.aws,target=/home/vscode/.aws,type=bind",
13-
"source=${env:HOME}${env:USERPROFILE}/.ssh,target=/home/vscode/.ssh,type=bind",
14-
"source=${env:HOME}${env:USERPROFILE}/.gnupg,target=/home/vscode/.gnupg,type=bind"
15-
],
16-
"customizations": {
17-
"vscode": {
18-
"extensions": [
19-
"AmazonWebServices.aws-toolkit-vscode",
20-
"redhat.vscode-yaml",
21-
"ms-python.python",
22-
"ms-python.flake8",
23-
"eamodio.gitlens",
24-
"github.vscode-pull-request-github",
25-
"orta.vscode-jest",
26-
"42crunch.vscode-openapi",
27-
"mermade.openapi-lint",
28-
"rvest.vs-code-prettier-eslint",
29-
"christian-kohler.npm-intellisense",
30-
"dbaeumer.vscode-eslint",
31-
"lfm.vscode-makefile-term",
32-
"GrapeCity.gc-excelviewer",
33-
"streetsidesoftware.code-spell-checker",
34-
"timonwong.shellcheck",
35-
"github.vscode-github-actions",
36-
"vscjava.vscode-java-pack"
37-
],
38-
"settings": {
39-
"python.defaultInterpreterPath": "/workspaces/eps-FHIR-validator-lambda/.venv/bin/python",
40-
"python.analysis.autoSearchPaths": true,
41-
"python.analysis.extraPaths": [],
42-
"python.testing.unittestEnabled": false,
43-
"python.testing.pytestEnabled": true,
44-
"python.linting.pylintEnabled": false,
45-
"python.linting.flake8Enabled": true,
46-
"python.linting.enabled": true, // required to format on save
47-
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint",
48-
"editor.formatOnPaste": false, // required
49-
"editor.formatOnType": false, // required
50-
"editor.formatOnSave": true, // optional
51-
"editor.formatOnSaveMode": "file",
52-
"cSpell.words": ["fhir", "Formik", "pino", "serialisation"]
53-
}
2+
"name": "eps-validator-lambda",
3+
"build": {
4+
"dockerfile": "Dockerfile",
5+
"context": "..",
6+
"args": {
7+
"DOCKER_GID": "${env:DOCKER_GID:}",
8+
"IMAGE_NAME": "node_24_python_3_14_java_24",
9+
"IMAGE_VERSION": "v1.1.3",
10+
"USER_UID": "${localEnv:USER_ID:}",
11+
"USER_GID": "${localEnv:GROUP_ID:}"
12+
}
13+
},
14+
"mounts": [
15+
"source=${env:HOME}${env:USERPROFILE}/.aws,target=/home/vscode/.aws,type=bind",
16+
"source=${env:HOME}${env:USERPROFILE}/.ssh,target=/home/vscode/.ssh,type=bind",
17+
"source=${env:HOME}${env:USERPROFILE}/.gnupg,target=/home/vscode/.gnupg,type=bind"
18+
],
19+
"customizations": {
20+
"vscode": {
21+
"extensions": [
22+
"AmazonWebServices.aws-toolkit-vscode",
23+
"redhat.vscode-yaml",
24+
"ms-python.python",
25+
"ms-python.flake8",
26+
"eamodio.gitlens",
27+
"github.vscode-pull-request-github",
28+
"orta.vscode-jest",
29+
"42crunch.vscode-openapi",
30+
"mermade.openapi-lint",
31+
"rvest.vs-code-prettier-eslint",
32+
"christian-kohler.npm-intellisense",
33+
"dbaeumer.vscode-eslint",
34+
"lfm.vscode-makefile-term",
35+
"GrapeCity.gc-excelviewer",
36+
"streetsidesoftware.code-spell-checker",
37+
"timonwong.shellcheck",
38+
"github.vscode-github-actions",
39+
"vscjava.vscode-java-pack"
40+
],
41+
"settings": {
42+
"python.defaultInterpreterPath": "/workspaces/eps-FHIR-validator-lambda/.venv/bin/python",
43+
"python.analysis.autoSearchPaths": true,
44+
"python.analysis.extraPaths": [],
45+
"python.testing.unittestEnabled": false,
46+
"python.testing.pytestEnabled": true,
47+
"python.linting.pylintEnabled": false,
48+
"python.linting.flake8Enabled": true,
49+
"python.linting.enabled": true,
50+
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint",
51+
"editor.formatOnPaste": false,
52+
"editor.formatOnType": false,
53+
"editor.formatOnSave": true,
54+
"editor.formatOnSaveMode": "file",
55+
"cSpell.words": [
56+
"fhir",
57+
"Formik",
58+
"pino",
59+
"serialisation"
60+
]
5461
}
55-
},
56-
"remoteEnv": { "LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}" },
57-
"postAttachCommand": "docker build -f https://raw.githubusercontent.com/NHSDigital/eps-workflow-quality-checks/refs/tags/v4.0.4/dockerfiles/nhsd-git-secrets.dockerfile -t git-secrets . && poetry run pre-commit install --install-hooks -f",
58-
"features": {
59-
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {
60-
"version": "latest",
61-
"moby": "true",
62-
"installDockerBuildx": "true"
63-
},
64-
"ghcr.io/devcontainers/features/github-cli:1": {}
65-
}
62+
}
63+
},
64+
"remoteEnv": {
65+
"LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}"
66+
},
67+
"postAttachCommand": "git-secrets --register-aws; git-secrets --add-provider -- cat /usr/share/secrets-scanner/nhsd-rules-deny.txt",
68+
"features": {
6669
}
67-
70+
}

.github/workflows/ci.yml

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,17 @@ env:
88
BRANCH_NAME: ${{ github.event.ref.BRANCH_NAME }}
99

1010
jobs:
11-
get_asdf_version:
12-
runs-on: ubuntu-22.04
13-
outputs:
14-
asdf_version: ${{ steps.asdf-version.outputs.version }}
15-
tag_format: ${{ steps.load-config.outputs.TAG_FORMAT }}
16-
steps:
17-
- name: Checkout code
18-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
19-
20-
- name: Get asdf version
21-
id: asdf-version
22-
run: echo "version=$(awk '!/^#/ && NF {print $1; exit}' .tool-versions.asdf)" >> "$GITHUB_OUTPUT"
23-
- name: Load config value
24-
id: load-config
25-
run: |
26-
TAG_FORMAT=$(yq '.TAG_FORMAT' .github/config/settings.yml)
27-
echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT"
11+
get_config_values:
12+
uses: NHSDigital/eps-common-workflows/.github/workflows/get-repo-config.yml@141907b215220e95e3ed3811d0fe8fa18675dbed
13+
with:
14+
verify_published_from_main_image: true
2815
quality_checks:
29-
uses: NHSDigital/eps-common-workflows/.github/workflows/quality-checks.yml@141907b215220e95e3ed3811d0fe8fa18675dbed
30-
needs: [get_asdf_version]
16+
uses: NHSDigital/eps-common-workflows/.github/workflows/quality-checks-devcontainer.yml@141907b215220e95e3ed3811d0fe8fa18675dbed
17+
needs: [get_config_values]
3118
secrets:
3219
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
3320
with:
34-
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
35-
install_java: true
21+
pinned_image: ${{ needs.get_config_values.outputs.pinned_image }}
3622

3723
get_commit_id:
3824
runs-on: ubuntu-22.04
@@ -45,23 +31,26 @@ jobs:
4531
echo "commit_id=${{ github.sha }}" >> "$GITHUB_OUTPUT"
4632
4733
tag_release:
48-
needs: [quality_checks, get_commit_id, get_asdf_version]
49-
uses: NHSDigital/eps-common-workflows/.github/workflows/tag-release.yml@141907b215220e95e3ed3811d0fe8fa18675dbed
34+
needs: [quality_checks, get_commit_id, get_config_values]
35+
uses: NHSDigital/eps-common-workflows/.github/workflows/tag-release-devcontainer.yml@141907b215220e95e3ed3811d0fe8fa18675dbed
5036
with:
5137
dry_run: true
52-
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
38+
pinned_image: ${{ needs.get_config_values.outputs.pinned_image }}
5339
branch_name: main
54-
tag_format: ${{ needs.get_asdf_version.outputs.tag_format }}
40+
tag_format: ${{ needs.get_config_values.outputs.tag_format }}
5541
secrets: inherit
5642

5743
package_code:
58-
needs: tag_release
44+
needs: [tag_release, get_config_values]
5945
uses: ./.github/workflows/sam_package_code.yml
46+
with:
47+
pinned_image: ${{ needs.get_config_values.outputs.pinned_image }}
6048

6149
release_dev:
62-
needs: [tag_release, package_code, get_commit_id]
50+
needs: [tag_release, package_code, get_commit_id, get_config_values]
6351
uses: ./.github/workflows/sam_release_code.yml
6452
with:
53+
pinned_image: ${{ needs.get_config_values.outputs.pinned_image }}
6554
ARTIFACT_BUCKET_PREFIX: ${{needs.tag_release.outputs.version_tag}}
6655
STACK_NAME: fhir-validator
6756
TARGET_ENVIRONMENT: dev
@@ -81,9 +70,10 @@ jobs:
8170
DEV_CLOUD_FORMATION_EXECUTE_LAMBDA_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_EXECUTE_LAMBDA_ROLE }}
8271

8372
release_qa:
84-
needs: [tag_release, release_dev, package_code, get_commit_id]
73+
needs: [tag_release, release_dev, package_code, get_commit_id, get_config_values]
8574
uses: ./.github/workflows/sam_release_code.yml
8675
with:
76+
pinned_image: ${{ needs.get_config_values.outputs.pinned_image }}
8777
ARTIFACT_BUCKET_PREFIX: ${{needs.tag_release.outputs.version_tag}}
8878
STACK_NAME: fhir-validator
8979
TARGET_ENVIRONMENT: qa

.github/workflows/pull_request.yml

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,15 @@ jobs:
1414
secrets:
1515
AUTOMERGE_APP_ID: ${{ secrets.AUTOMERGE_APP_ID }}
1616
AUTOMERGE_PEM: ${{ secrets.AUTOMERGE_PEM }}
17-
get_asdf_version:
18-
runs-on: ubuntu-22.04
19-
outputs:
20-
asdf_version: ${{ steps.asdf-version.outputs.version }}
21-
tag_format: ${{ steps.load-config.outputs.TAG_FORMAT }}
22-
steps:
23-
- name: Checkout code
24-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
25-
26-
- name: Get asdf version
27-
id: asdf-version
28-
run: echo "version=$(awk '!/^#/ && NF {print $1; exit}' .tool-versions.asdf)" >> "$GITHUB_OUTPUT"
29-
- name: Load config value
30-
id: load-config
31-
run: |
32-
TAG_FORMAT=$(yq '.TAG_FORMAT' .github/config/settings.yml)
33-
echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT"
17+
get_config_values:
18+
uses: NHSDigital/eps-common-workflows/.github/workflows/get-repo-config.yml@141907b215220e95e3ed3811d0fe8fa18675dbed
19+
with:
20+
verify_published_from_main_image: false
3421
quality_checks:
35-
uses: NHSDigital/eps-common-workflows/.github/workflows/quality-checks.yml@141907b215220e95e3ed3811d0fe8fa18675dbed
36-
needs: [get_asdf_version]
22+
uses: NHSDigital/eps-common-workflows/.github/workflows/quality-checks-devcontainer.yml@141907b215220e95e3ed3811d0fe8fa18675dbed
23+
needs: [get_config_values]
3724
with:
38-
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
39-
install_java: true
25+
pinned_image: ${{ needs.get_config_values.outputs.pinned_image }}
4026
secrets:
4127
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
4228

@@ -71,13 +57,13 @@ jobs:
7157
result-encoding: string
7258

7359
tag_release:
74-
needs: [get_asdf_version]
75-
uses: NHSDigital/eps-common-workflows/.github/workflows/tag-release.yml@141907b215220e95e3ed3811d0fe8fa18675dbed
60+
needs: [get_config_values]
61+
uses: NHSDigital/eps-common-workflows/.github/workflows/tag-release-devcontainer.yml@141907b215220e95e3ed3811d0fe8fa18675dbed
7662
with:
7763
dry_run: true
78-
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
64+
pinned_image: ${{ needs.get_config_values.outputs.pinned_image }}
7965
branch_name: ${{ github.event.pull_request.head.ref }}
80-
tag_format: ${{ needs.get_asdf_version.outputs.tag_format }}
66+
tag_format: ${{ needs.get_config_values.outputs.tag_format }}
8167
secrets: inherit
8268

8369
get_commit_id:
@@ -91,13 +77,16 @@ jobs:
9177
echo "commit_id=${{ github.sha }}" >> "$GITHUB_OUTPUT"
9278
9379
package_code:
94-
needs: get_issue_number
80+
needs: [get_issue_number, get_config_values]
9581
uses: ./.github/workflows/sam_package_code.yml
82+
with:
83+
pinned_image: ${{ needs.get_config_values.outputs.pinned_image }}
9684

9785
release_code:
98-
needs: [get_issue_number, package_code, get_commit_id]
86+
needs: [get_issue_number, package_code, get_commit_id, get_config_values]
9987
uses: ./.github/workflows/sam_release_code.yml
10088
with:
89+
pinned_image: ${{ needs.get_config_values.outputs.pinned_image }}
10190
STACK_NAME: fhir-validator-pr-${{needs.get_issue_number.outputs.issue_number}}
10291
ARTIFACT_BUCKET_PREFIX: fhir-validator-PR-${{needs.get_issue_number.outputs.issue_number}}
10392
TARGET_ENVIRONMENT: dev-pr

0 commit comments

Comments
 (0)