Skip to content

Commit 2297ee2

Browse files
authored
Chore: [AEA-0000] - use container image (#2757)
## Summary - Routine Change ### Details - use devcontainer image
1 parent bb22403 commit 2297ee2

34 files changed

Lines changed: 313 additions & 1734 deletions

.cfnlintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
ignore_checks:
22
- W3002
3+
- E2002

.devcontainer/Dockerfile

Lines changed: 11 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,15 @@
1-
FROM mcr.microsoft.com/devcontainers/base:ubuntu
2-
3-
# provide DOCKER_GID via build args if you need to force group id to match host
4-
ARG DOCKER_GID
5-
ARG TARGETARCH
6-
ENV TARGETARCH=${TARGETARCH}
7-
8-
ARG ASDF_VERSION
9-
COPY .tool-versions.asdf /tmp/.tool-versions.asdf
10-
11-
# Anticipate and resolve potential permission issues with apt
12-
RUN mkdir -p /tmp && chmod 1777 /tmp
13-
14-
RUN apt-get update \
15-
&& export DEBIAN_FRONTEND=noninteractive \
16-
&& apt-get -y dist-upgrade \
17-
&& apt-get -y install --no-install-recommends htop vim curl git build-essential \
18-
libffi-dev libssl-dev libxml2-dev libxslt1-dev libjpeg8-dev libbz2-dev \
19-
zlib1g-dev unixodbc unixodbc-dev libsecret-1-0 libsecret-1-dev libsqlite3-dev \
20-
jq apt-transport-https ca-certificates gnupg-agent \
21-
software-properties-common bash-completion python3-pip make libbz2-dev \
22-
libreadline-dev libsqlite3-dev wget llvm libncurses5-dev libncursesw5-dev \
23-
xz-utils tk-dev liblzma-dev netcat-traditional libyaml-dev
24-
25-
# Download correct AWS CLI for arch
26-
RUN if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" = "aarch64" ]; then \
27-
wget -O /tmp/awscliv2.zip "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip"; \
28-
else \
29-
wget -O /tmp/awscliv2.zip "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip"; \
30-
fi && \
31-
unzip /tmp/awscliv2.zip -d /tmp/aws-cli && \
32-
/tmp/aws-cli/aws/install && \
33-
rm /tmp/awscliv2.zip && rm -rf /tmp/aws-cli
34-
35-
# Download correct SAM CLI for arch
36-
RUN if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" = "aarch64" ]; then \
37-
wget -O /tmp/aws-sam-cli.zip "https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-arm64.zip"; \
38-
else \
39-
wget -O /tmp/aws-sam-cli.zip "https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip"; \
40-
fi && \
41-
unzip /tmp/aws-sam-cli.zip -d /tmp/aws-sam-cli && \
42-
/tmp/aws-sam-cli/install && \
43-
rm /tmp/aws-sam-cli.zip && rm -rf /tmp/aws-sam-cli
44-
45-
# Install ASDF
46-
RUN ASDF_VERSION=$(awk '!/^#/ && NF {print $1; exit}' /tmp/.tool-versions.asdf) && \
47-
if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" == "aarch64" ]; then \
48-
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"; \
49-
else \
50-
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"; \
51-
fi && \
52-
tar -xzf /tmp/asdf.tar.gz -C /tmp && \
53-
mkdir -p /usr/bin && \
54-
mv /tmp/asdf /usr/bin/asdf && \
55-
chmod +x /usr/bin/asdf && \
56-
rm -rf /tmp/asdf.tar.gz
1+
ARG IMAGE_NAME=node_24_python_3_14
2+
ARG IMAGE_VERSION=latest
3+
FROM ghcr.io/nhsdigital/eps-devcontainers/${IMAGE_NAME}:${IMAGE_VERSION}
574

5+
USER root
586
# specify DOCKER_GID to force container docker group id to match host
597
RUN if [ -n "${DOCKER_GID}" ]; then \
60-
if ! getent group docker; then \
61-
groupadd -g ${DOCKER_GID} docker; \
62-
else \
63-
groupmod -g ${DOCKER_GID} docker; \
64-
fi && \
65-
usermod -aG docker vscode; \
8+
if ! getent group docker; then \
9+
groupadd -g ${DOCKER_GID} docker; \
10+
else \
11+
groupmod -g ${DOCKER_GID} docker; \
12+
fi && \
13+
usermod -aG docker vscode; \
6614
fi
67-
68-
USER vscode
69-
70-
ENV PATH="/home/vscode/.asdf/shims/:$PATH"
71-
RUN \
72-
echo 'PATH="/home/vscode/.asdf/shims/:$PATH"' >> ~/.bashrc; \
73-
echo '. <(asdf completion bash)' >> ~/.bashrc; \
74-
echo '# Install Ruby Gems to ~/gems' >> ~/.bashrc; \
75-
echo 'export GEM_HOME="$HOME/gems"' >> ~/.bashrc; \
76-
echo 'export PATH="$HOME/gems/bin:$PATH"' >> ~/.bashrc;
77-
78-
# Install ASDF plugins
79-
RUN asdf plugin add python && \
80-
asdf plugin add poetry https://github.com/asdf-community/asdf-poetry.git && \
81-
asdf plugin add shellcheck https://github.com/luizm/asdf-shellcheck.git && \
82-
asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git && \
83-
asdf plugin add direnv && \
84-
asdf plugin add actionlint && \
85-
asdf plugin add ruby https://github.com/asdf-vm/asdf-ruby.git
86-
87-
WORKDIR /workspaces/eps-prescription-status-update-api
88-
ADD .tool-versions /workspaces/eps-prescription-status-update-api/.tool-versions
89-
ADD .tool-versions /home/vscode/.tool-versions
90-
91-
# install python before poetry to ensure correct python version is used
92-
RUN asdf install python && \
93-
asdf install
15+

.devcontainer/devcontainer.json

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
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
2+
"name": "PSU",
63
"build": {
74
"dockerfile": "Dockerfile",
85
"context": "..",
96
"args": {
10-
"DOCKER_GID": "${env:DOCKER_GID:}"
11-
}
7+
"DOCKER_GID": "${env:DOCKER_GID:}",
8+
"IMAGE_NAME": "node_24_python_3_12",
9+
"IMAGE_VERSION": "v1.0.7",
10+
"USER_UID": "${localEnv:USER_ID:}",
11+
"USER_GID": "${localEnv:GROUP_ID:}"
12+
},
13+
"updateRemoteUserUID": false
1214
},
15+
"postAttachCommand": "git-secrets --register-aws; git-secrets --add-provider -- cat /usr/share/secrets-scanner/nhsd-rules-deny.txt",
1316
"mounts": [
1417
"source=${env:HOME}${env:USERPROFILE}/.aws,target=/home/vscode/.aws,type=bind",
1518
"source=${env:HOME}${env:USERPROFILE}/.ssh,target=/home/vscode/.ssh,type=bind",
@@ -47,10 +50,10 @@
4750
"python.testing.pytestEnabled": true,
4851
"pylint.enabled": false,
4952
"python.linting.flake8Enabled": true,
50-
"python.linting.enabled": true, // required to format on save
51-
"editor.formatOnPaste": false, // required
52-
"editor.formatOnType": false, // required
53-
"editor.formatOnSave": true, // optional
53+
"python.linting.enabled": true,
54+
"editor.formatOnPaste": false,
55+
"editor.formatOnType": false,
56+
"editor.formatOnSave": true,
5457
"editor.formatOnSaveMode": "file",
5558
"cSpell.words": ["fhir", "Formik", "pino", "serialisation"],
5659
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
@@ -59,14 +62,6 @@
5962
}
6063
},
6164
"remoteEnv": { "LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}" },
62-
"updateRemoteUserUID": true,
63-
"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",
6465
"features": {
65-
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {
66-
"version": "latest",
67-
"moby": "true",
68-
"installDockerBuildx": "true"
69-
},
70-
"ghcr.io/devcontainers/features/github-cli:1": {}
7166
}
7267
}

0 commit comments

Comments
 (0)