-
Notifications
You must be signed in to change notification settings - Fork 0
Chore: [AEA-0000] - Use common dev container #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e2f228d
ddbe311
d0be713
fa65932
890ce6c
906f8a0
3a69e97
3f0575b
6af21f1
b471edb
1a64425
9c160c3
9c520a0
0700205
03c9bcd
f175aaa
5eecb7b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,110 +1,14 @@ | ||
| FROM alpine:3.23.3 AS build | ||
| ARG TARGETARCH | ||
| RUN apk add --no-cache cosign bash curl jq | ||
| COPY src/base/.devcontainer/scripts/install_trivy.sh /tmp/install_trivy.sh | ||
| RUN case "${TARGETARCH}" in \ | ||
| x86_64|amd64) TRIVY_ARCH=64bit ;; \ | ||
| aarch64|arm64) TRIVY_ARCH=ARM64 ;; \ | ||
| *) echo "Unsupported TARGETARCH: ${TARGETARCH}" && exit 1 ;; \ | ||
| esac \ | ||
| && INSTALL_DIR=/tmp/trivy/ ARCH="${TRIVY_ARCH}" /tmp/install_trivy.sh | ||
|
|
||
|
|
||
| FROM mcr.microsoft.com/devcontainers/base:ubuntu-22.04 | ||
| ARG TARGETARCH | ||
| ENV TARGETARCH=${TARGETARCH} | ||
|
|
||
| # Install essential packages first | ||
| RUN apt-get update && apt-get install -y \ | ||
| curl \ | ||
| wget \ | ||
| git \ | ||
| sudo \ | ||
| unzip \ | ||
| && apt-get clean \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Copy ASDF version file | ||
| ARG ASDF_VERSION | ||
| COPY .tool-versions.asdf /tmp/.tool-versions.asdf | ||
|
|
||
| # Add amd64 architecture if on arm64 | ||
| RUN if [ "$TARGETARCH" == "arm64" ] || [ "$TARGETARCH" == "aarch64" ]; then dpkg --add-architecture amd64; fi | ||
|
|
||
| RUN apt-get update \ | ||
| && export DEBIAN_FRONTEND=noninteractive \ | ||
| && apt-get -y dist-upgrade \ | ||
| && apt-get -y install --no-install-recommends htop vim curl git build-essential \ | ||
| libffi-dev libssl-dev libxml2-dev libxslt1-dev libjpeg8-dev libbz2-dev \ | ||
| zlib1g-dev unixodbc unixodbc-dev libsecret-1-0 libsecret-1-dev libsqlite3-dev \ | ||
| jq apt-transport-https ca-certificates gnupg-agent \ | ||
| software-properties-common bash-completion python3-pip make libbz2-dev \ | ||
| libreadline-dev libsqlite3-dev wget llvm libncurses5-dev libncursesw5-dev \ | ||
| xz-utils tk-dev liblzma-dev netcat-traditional libyaml-dev uuid-runtime xxd unzip | ||
|
|
||
| # install aws stuff | ||
| # Download correct AWS CLI for arch | ||
| RUN if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" == "aarch64" ]; then \ | ||
| wget -O /tmp/awscliv2.zip "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip"; \ | ||
| else \ | ||
| wget -O /tmp/awscliv2.zip "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip"; \ | ||
| fi && \ | ||
| unzip /tmp/awscliv2.zip -d /tmp/aws-cli && \ | ||
| /tmp/aws-cli/aws/install && \ | ||
| rm /tmp/awscliv2.zip && rm -rf /tmp/aws-cli | ||
|
|
||
| # Install ASDF | ||
| RUN ASDF_VERSION=$(awk '!/^#/ && NF {print $1; exit}' /tmp/.tool-versions.asdf) && \ | ||
| if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" == "aarch64" ]; then \ | ||
| 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"; \ | ||
| else \ | ||
| 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"; \ | ||
| fi && \ | ||
| tar -xzf /tmp/asdf.tar.gz -C /tmp && \ | ||
| mkdir -p /usr/bin && \ | ||
| mv /tmp/asdf /usr/bin/asdf && \ | ||
| chmod +x /usr/bin/asdf && \ | ||
| rm -rf /tmp/asdf.tar.gz | ||
|
|
||
| # install gitsecrets | ||
| RUN git clone https://github.com/awslabs/git-secrets.git /tmp/git-secrets && \ | ||
| cd /tmp/git-secrets && \ | ||
| make install && \ | ||
| cd && \ | ||
| rm -rf /tmp/git-secrets && \ | ||
| mkdir -p /usr/share/secrets-scanner && \ | ||
| chmod 755 /usr/share/secrets-scanner && \ | ||
| curl -L https://raw.githubusercontent.com/NHSDigital/software-engineering-quality-framework/main/tools/nhsd-git-secrets/nhsd-rules-deny.txt -o /usr/share/secrets-scanner/nhsd-rules-deny.txt | ||
|
|
||
| COPY --from=build /tmp/trivy/trivy /usr/local/bin/trivy | ||
|
|
||
| USER vscode | ||
|
|
||
| ENV PATH="/home/vscode/.asdf/shims:/home/vscode/.local/bin:$PATH:/workspaces/eps-devcontainers/node_modules/.bin" | ||
| RUN \ | ||
| echo 'PATH="/home/vscode/.asdf/shims:/home/vscode/.local/bin:$PATH:/workspaces/eps-devcontainers/node_modules/.bin"' >> ~/.bashrc; \ | ||
| echo '. <(asdf completion bash)' >> ~/.bashrc; \ | ||
| echo '# Install Ruby Gems to ~/gems' >> ~/.bashrc; \ | ||
| echo 'export GEM_HOME="$HOME/gems"' >> ~/.bashrc; \ | ||
| echo 'export PATH="$HOME/gems/bin:$PATH"' >> ~/.bashrc; | ||
|
|
||
| # Install ASDF plugins | ||
| RUN asdf plugin add python; \ | ||
| asdf plugin add poetry https://github.com/asdf-community/asdf-poetry.git; \ | ||
| asdf plugin add shellcheck https://github.com/luizm/asdf-shellcheck.git; \ | ||
| asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git; \ | ||
| asdf plugin add direnv; \ | ||
| asdf plugin add actionlint; \ | ||
| asdf plugin add ruby https://github.com/asdf-vm/asdf-ruby.git; \ | ||
| asdf plugin add yq https://github.com/sudermanjr/asdf-yq.git; | ||
|
|
||
| WORKDIR /workspaces/eps-devcontainers | ||
| COPY .tool-versions /workspaces/eps-devcontainers/.tool-versions | ||
| COPY .tool-versions /home/vscode/.tool-versions | ||
|
|
||
| # install python before poetry to ensure correct python version is used | ||
| RUN asdf install python; \ | ||
| asdf install | ||
|
|
||
| RUN git-secrets --register-aws --global && \ | ||
| git-secrets --add-provider --global -- cat /usr/share/secrets-scanner/nhsd-rules-deny.txt | ||
| ARG IMAGE_NAME=regression_tests | ||
| ARG IMAGE_VERSION=latest | ||
| FROM ghcr.io/nhsdigital/eps-devcontainers/${IMAGE_NAME}:${IMAGE_VERSION} | ||
|
|
||
| USER root | ||
| # specify DOCKER_GID to force container docker group id to match host | ||
| RUN if [ -n "${DOCKER_GID}" ]; then \ | ||
| if ! getent group docker; then \ | ||
| groupadd -g ${DOCKER_GID} docker; \ | ||
| else \ | ||
| groupmod -g ${DOCKER_GID} docker; \ | ||
| fi && \ | ||
| usermod -aG docker vscode; \ | ||
| fi | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| # This can be used to bootstrap devcontainer when no images have been pushed | ||
| FROM alpine:3.23.3 AS build | ||
| ARG TARGETARCH | ||
| RUN apk add --no-cache cosign bash curl jq | ||
| COPY src/base/.devcontainer/scripts/install_trivy.sh /tmp/install_trivy.sh | ||
| RUN case "${TARGETARCH}" in \ | ||
| x86_64|amd64) TRIVY_ARCH=64bit ;; \ | ||
| aarch64|arm64) TRIVY_ARCH=ARM64 ;; \ | ||
| *) echo "Unsupported TARGETARCH: ${TARGETARCH}" && exit 1 ;; \ | ||
| esac \ | ||
| && INSTALL_DIR=/tmp/trivy/ ARCH="${TRIVY_ARCH}" /tmp/install_trivy.sh | ||
|
|
||
|
|
||
| FROM mcr.microsoft.com/devcontainers/base:ubuntu-22.04 | ||
| ARG TARGETARCH | ||
| ENV TARGETARCH=${TARGETARCH} | ||
|
|
||
| # Install essential packages first | ||
| RUN apt-get update && apt-get install -y \ | ||
| curl \ | ||
| wget \ | ||
| git \ | ||
| sudo \ | ||
| unzip \ | ||
| && apt-get clean \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Copy ASDF version file | ||
| ENV ASDF_VERSION=0.18.1 | ||
|
|
||
| # Add amd64 architecture if on arm64 | ||
| RUN if [ "$TARGETARCH" == "arm64" ] || [ "$TARGETARCH" == "aarch64" ]; then dpkg --add-architecture amd64; fi | ||
|
|
||
| RUN apt-get update \ | ||
| && export DEBIAN_FRONTEND=noninteractive \ | ||
| && apt-get -y dist-upgrade \ | ||
| && apt-get -y install --no-install-recommends htop vim curl git build-essential \ | ||
| libffi-dev libssl-dev libxml2-dev libxslt1-dev libjpeg8-dev libbz2-dev \ | ||
| zlib1g-dev unixodbc unixodbc-dev libsecret-1-0 libsecret-1-dev libsqlite3-dev \ | ||
| jq apt-transport-https ca-certificates gnupg-agent \ | ||
| software-properties-common bash-completion python3-pip make libbz2-dev \ | ||
| libreadline-dev libsqlite3-dev wget llvm libncurses5-dev libncursesw5-dev \ | ||
| xz-utils tk-dev liblzma-dev netcat-traditional libyaml-dev uuid-runtime xxd unzip | ||
|
|
||
| # install aws stuff | ||
| # Download correct AWS CLI for arch | ||
| RUN if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" == "aarch64" ]; then \ | ||
| wget -O /tmp/awscliv2.zip "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip"; \ | ||
| else \ | ||
| wget -O /tmp/awscliv2.zip "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip"; \ | ||
| fi && \ | ||
| unzip /tmp/awscliv2.zip -d /tmp/aws-cli && \ | ||
| /tmp/aws-cli/aws/install && \ | ||
| rm /tmp/awscliv2.zip && rm -rf /tmp/aws-cli | ||
|
|
||
| # Install ASDF | ||
| RUN if [ "$TARGETARCH" = "arm64" ] || [ "$TARGETARCH" == "aarch64" ]; then \ | ||
| 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"; \ | ||
| else \ | ||
| 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"; \ | ||
| fi && \ | ||
| tar -xzf /tmp/asdf.tar.gz -C /tmp && \ | ||
| mkdir -p /usr/bin && \ | ||
| mv /tmp/asdf /usr/bin/asdf && \ | ||
| chmod +x /usr/bin/asdf && \ | ||
| rm -rf /tmp/asdf.tar.gz | ||
|
|
||
| # install gitsecrets | ||
| RUN git clone https://github.com/awslabs/git-secrets.git /tmp/git-secrets && \ | ||
| cd /tmp/git-secrets && \ | ||
| make install && \ | ||
| cd && \ | ||
| rm -rf /tmp/git-secrets && \ | ||
| mkdir -p /usr/share/secrets-scanner && \ | ||
| chmod 755 /usr/share/secrets-scanner && \ | ||
| curl -L https://raw.githubusercontent.com/NHSDigital/software-engineering-quality-framework/main/tools/nhsd-git-secrets/nhsd-rules-deny.txt -o /usr/share/secrets-scanner/nhsd-rules-deny.txt | ||
|
|
||
| COPY --from=build /tmp/trivy/trivy /usr/local/bin/trivy | ||
|
|
||
| USER vscode | ||
|
|
||
| ENV PATH="/home/vscode/.asdf/shims:/home/vscode/.local/bin:$PATH:/workspaces/eps-devcontainers/node_modules/.bin" | ||
| RUN \ | ||
| echo 'PATH="/home/vscode/.asdf/shims:/home/vscode/.local/bin:$PATH:/workspaces/eps-devcontainers/node_modules/.bin"' >> ~/.bashrc; \ | ||
| echo '. <(asdf completion bash)' >> ~/.bashrc; \ | ||
| echo '# Install Ruby Gems to ~/gems' >> ~/.bashrc; \ | ||
| echo 'export GEM_HOME="$HOME/gems"' >> ~/.bashrc; \ | ||
| echo 'export PATH="$HOME/gems/bin:$PATH"' >> ~/.bashrc; | ||
|
|
||
| # Install ASDF plugins | ||
| RUN asdf plugin add python; \ | ||
| asdf plugin add poetry https://github.com/asdf-community/asdf-poetry.git; \ | ||
| asdf plugin add shellcheck https://github.com/luizm/asdf-shellcheck.git; \ | ||
| asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git; \ | ||
| asdf plugin add direnv; \ | ||
| asdf plugin add actionlint; \ | ||
| asdf plugin add ruby https://github.com/asdf-vm/asdf-ruby.git; \ | ||
| asdf plugin add yq https://github.com/sudermanjr/asdf-yq.git; | ||
|
|
||
| WORKDIR /workspaces/eps-devcontainers | ||
| COPY .devcontainer/.tool-versions.bootstrap /workspaces/eps-devcontainers/.tool-versions | ||
| COPY .devcontainer/.tool-versions.bootstrap /home/vscode/.tool-versions | ||
|
|
||
| # install python before poetry to ensure correct python version is used | ||
| RUN asdf install python; \ | ||
| asdf install | ||
|
|
||
| RUN git-secrets --register-aws --global && \ | ||
| git-secrets --add-provider --global -- cat /usr/share/secrets-scanner/nhsd-rules-deny.txt |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,12 +1,15 @@ | ||||||||||||||||||
| // For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||||||||||||||||||
| // README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu | ||||||||||||||||||
| { | ||||||||||||||||||
| "name": "eps-devcontainers", | ||||||||||||||||||
| // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile | ||||||||||||||||||
| "build": { | ||||||||||||||||||
| "dockerfile": "Dockerfile", | ||||||||||||||||||
| "context": "..", | ||||||||||||||||||
| "args": {} | ||||||||||||||||||
| "args": { | ||||||||||||||||||
| "DOCKER_GID": "${env:DOCKER_GID:}", | ||||||||||||||||||
| "IMAGE_NAME": "node_24_python_3_14", | ||||||||||||||||||
| "IMAGE_VERSION": "latest", | ||||||||||||||||||
| "USER_UID": "${localEnv:USER_ID:}", | ||||||||||||||||||
| "USER_GID": "${localEnv:GROUP_ID:}" | ||||||||||||||||||
|
Comment on lines
+7
to
+11
|
||||||||||||||||||
| "DOCKER_GID": "${env:DOCKER_GID:}", | |
| "IMAGE_NAME": "node_24_python_3_14", | |
| "IMAGE_VERSION": "latest", | |
| "USER_UID": "${localEnv:USER_ID:}", | |
| "USER_GID": "${localEnv:GROUP_ID:}" | |
| "DOCKER_GID": "${localEnv:DOCKER_GID:}", | |
| "IMAGE_NAME": "node_24_python_3_14", | |
| "IMAGE_VERSION": "latest" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DOCKER_GIDis used in the RUN block but isn't declared as a build arg (ARG DOCKER_GID) anywhere in this Dockerfile, so the value passed from devcontainer.json won't be available and the docker group remap will never run. DeclareARG DOCKER_GID(and ideally validate it’s a numeric GID and quote the variable when passing it to groupadd/groupmod) before this RUN instruction.